ARM V7 Assembly

#folder

PSR Flags

PSR: program status register

Info

These bits are set based on the result of an operation iff the S flag is included

List

  • N: negative
  • Z: zero
  • C: carry out
  • V: overflow

Conditions

Table

Code Meaning Flag Tested
eq Equal Z == 1
ne Not Equal Z == 0
cs or hs Carry set (unsigned higher or same) C == 1
cc or lo Carry clear (unsigned lower) C == 0
mi Minus (negative) N == 1
pl Plus (positive or 0) N == 0
vs V set (signed overflow) V == 1
vc V clear (no signed overflow) V == 0
hi Unsigned higher C == 1 && Z == 0
ls Unsigned lower or same C == 0 || Z == 1
ge Signed greater than or equal N == V
lt Signed less than N != V
gt Signed greater than N == V && Z == 0
le Signed less than or equal N != V || Z == 1
al (or omitted) Always executed None

PC-Relative Addressing

Used by PC-relative loads and ADR

Definition

PC-relative addressing generates an address by adding an offset to the program counter ().

Note that the PC is incremented by 8 twice before adding the offset.

Note

In the case where the offset falls outside of the of the allowed range (i.e the label is too far from the current instruction), we can use a pseudo-instruction.

LDR, =LABEL

which is converted to a MOV or MVN if possible, or stores the value near the instruction and does a PC-relative load.