02-09-2013, 04:25 PM
ARM Processor Instruction Set
INTRODUCTION
All ARM processor instructions are conditionally executed, which means that their
execution may or may not take place depending on the values of the N, Z, C and V
flags in the CPSR.
The condition codes have meanings as detailed in Figure 5-2: Condition codes, for
instance code 0000 (EQual) executes the instruction only if the Z flag is set. This would
correspond to the case where a compare (CMP) instruction had found the two
operands to be equal. If the two operands were different, the compare instruction
would have cleared the Z flag and the instruction is not executed.
The link bit
Branch with Link (BL) writes the old PC into the link register (R14) of the current bank.
The PC value written into R14 is adjusted to allow for the prefetch, and contains
the address of the instruction following the branch and link instruction. Note that
the CPSR is not saved with the PC.
To return from a routine called by Branch with Link use MOV PC,R14 if the link register
is still valid or use LDM Rn!,{..PC} if the link register has been saved onto a stack
pointed to by Rn.
CPSR flags
The data processing operations may be classified as logical or arithmetic. The logical
operations (AND, EOR, TST, TEQ, ORR, MOV, BIC, MVN) perform the logical action
on all corresponding bits of the operand or operands to produce the result.
If the S bit is set (and Rd is not R15):
• the V flag in the CPSR will be unaffected
• the C flag will be set to the carry out from the barrel shifter (or preserved when
the shift operation is LSL #0)
• the Z flag will be set if and only if the result is all zeros
• the N flag will be set to the logical value of bit 31 of the result.
Operand restrictions
Due to the way multiplication was implemented, certain combinations of operand
registers should be avoided. (The assembler will issue a warning if these restrictions
are overlooked.)
The destination register (Rd) should not be the same as the operand register (Rm), as
Rd is used to hold intermediate values and Rm is used repeatedly during multiply. A
MUL will give a zero result if Rm=Rd, and an MLA will give a meaningless result. R15
must not be used as an operand or as the destination register.
All other register combinations will give correct results, and Rd, Rn and Rs may use
the same register when required.