ARM assembler instructions
The ARM assembler supports the following ARM Thumb instructions:
Operation | Example | Flags | Action | Notes | |
Move |
Immediate Low to Low Any to Any |
($mov 'r0 23) ($mov 'r0 'r1) ($mov 'r10 'r1) |
NZ NZ |
r0 = 23 r0 = r1 r10 = r1 |
Range 0 to 255 |
Add |
Immediate All Low With carry Immediate to SP Form address from SP Any to Any |
($add 'r0 'r1 2) ($add 'r0 'r1 'r2) ($adc 'r0 'r1) ($add 'sp 8) ($add 'r0 'sp 4) ($add 'r10 'r11) |
NZCV NZCV NZCV |
r0 = r1 + 2 r0 = r1 + r2 r0 = r0 + r1 + C sp = sp + 8 r0 = sp + 4 r10 = r10 + r11 |
Range 0 to 7 All Low. All Low. Range 0 to 508 (word aligned) Range 0 to 1020 (word aligned) Not Low to Low |
Subtract |
Immediate All Low With carry Immediate from SP Negate |
($sub 'r0 'r1 2) ($sub 'r0 'r1 'r2) ($sbc 'r0 'r1) ($sub 'sp 8) ($neg 'r0 'r1) |
NZCV NZCV NZCV NZCV |
r0 = r1 - 2 r0 = r1 - r2 r0 = r0 - r1 - NOT C sp = sp - 8 r0 = -r1 |
Range to 7 All Low |
Multiply | Multiply | ($mul 'r0 'r1) | NZ?? | r0 = r0 * r1 | C and V unpredictable |
Compare |
Any to Any Immediate Negative |
($cmp r0 r1) ($cmp 'r0 100) ($cmn r0 r1) |
NZCV NZCV NZCV |
Flags: r0 - r1 Flags: r0 - 100 Flags: r0 + r1 |
Range 0 to 255 |
Logical |
AND EOR OR Bit clear Move NOT Test bits |
($and 'r0 'r1) ($eor 'r0 'r1) ($orr 'r0 'r1) ($bic 'r0 'r1) ($mvn 'r0 'r1) ($tst 'r0 'r1) |
NZ NZ NZ NZ NZ NZ |
r0 = r0 AND r1 r0 = r0 EOR r1 r0 = r0 OR r1 r0 = r0 AND NOT r1 r0 = NOT r1 Flags: r0 AND r1 |
|
Shift/ |
Logical shift left immed. Logical shift left Logical shift right immed. Logical shift right Arithmetic shift right immed. Arithmetic shift right Rotate right |
($lsl 'r0 'r1 3) ($lsl 'r0 'r2) ($lsr 'r0 'r1 3) ($lsr 'r0 'r2) ($asr 'r0 'r1 3) ($asr 'r0 'r2) ($ror 'r0 'r2) |
NZC* NZC* NZC* NZC NZC* NZC NZC* |
r0 = r1 << 3 r0 = r0 << r2[7:0] r0 = r1 >> 3 r0 = r0 >> r2[7:0] r0 = r1 ASR 3 r0 = r0 ASR r2[7:0] r0 = r0 ROR r2[7:0] |
Range 0 to 31.
Range 1 to 32.
Range 1 to 32. |
Load |
Immed. offset - word - halfword - byte Register offset - word - halfword - signed halfword - byte - signed byte PC-relative SP-relative |
($ldr 'r0 '(r1 2)) ($ldrh 'r0 '(r1 3)) ($ldrb 'r0 '(r1 4)) ($ldr 'r0 '(r1 r2)) ($ldrh 'r0 '(r1 r2)) ($ldrsh 'r0 '(r1 r2)) ($ldrb 'r0 '(r1 r2)) ($ldrsb 'r0 '(r1 r2)) ($ldr 'r0 label) ($ldr 'r0 '(sp 23)) |
r0 = [r1+2] r0 = 00CD[r1+3] r0 = 000D[r1+4] r0 = [r1+r2] r0 = 00CD[r1+r2] r0 = XXCD[r1+r2] r0 = 000D[r1+r2] r0 = XXXD[r1+r2] r0 = [label] r0 = [SP + 23] |
Range 0 to 124, multiple of 4. Range 0 to 62, even. Range 0 to 31.
Range PC to PC+1020 word-aligned Range 0 to 1020, multiple of 4 |
|
Store |
Immed. offset - word - halfword - byte Register offset - word - halfword - byte SP-relative |
($str 'r0 '(r1 5)) ($strh 'r0 '(r1 6)) ($strb 'r0 '(r1 7)) ($str 'r0 '(r1 r2)) ($strh 'r0 '(r1 r2)) ($strb 'r0 '(r1 r2)) ($str 'r0 '(sp 8)) |
[r1+5] = r0 [r1+6] = r0 [r1+7] = r0 [r1+r2] = r0 [r1+r2] = r0 [r1+r2] = r0 [SP+8] = r0 |
Range 0 to 124, multiple of 4. Range 0 to 62, even. Range 0 to 31.
Range 0 to 1020, multiple of 4 |
|
Push | Push | ($push '(r4 r5 lr)) | Push registers | Any except pc. | |
Pop | Pop | ($pop '(r4 r5 pc)) | Pop registers | Any except lr. | |
Branch |
Conditional branch Unconditional branch Long branch with link Branch and exch. Branch with link and exch. Branch with link and exch. |
($beq label) ($b label) ($bl label) ($bx 'r0) ($blx label) ($blx 'r0) |
If cond PC = label PC = label PC = label, LR = next PC = r0 PC = label, LR = next PC = r0, LR = next |
Label within -252 to +258 bytes. Label within ±2Kbytes. Label within ±4Mbytes.
Label within ±4Mbytes. |
|
Extend |
Signed, half to word Signed, byte to word Unsigned, half to word Unsigned, byte to word |
($sxth 'r0 'r1) ($sxtb 'r0 'r1) ($uxth 'r0 'r1) ($uxtb 'r0 'r1) |
ABCD -> XXCD ABCD -> XXXD ABCD -> 00CD ABCD -> 000D |
A, B, C, and D are bytes. X is sign extended. 0 is zero extended. |
|
Reverse |
Bytes in words Bytes in both halves Bytes in low half, sign extend |
($rev 'r0 'r1) ($rev16 'r0 'r1) ($revsh 'r0 'r1) |
ABCD -> DCBA ABCD -> BADC ABCD -> XXDC |
A, B, C, and D are bytes. X is sign extended. |
|
State | Not yet implemented. | ||||
No op | No operation | ($nop) | |||
Hint | Not yet implemented. |