Twenty Three Hundred Learn Computer Systems by Hacking Hardware

ARM Assembly Cheat Sheet

Instructions

Shifts

Shift Meaning Description
LSL n Logical shift left Shift the bits left by \(n\), discarding the higher bits and filling the lower ones with 0
LSR n Logical shift right Shift the bits right by \(n\), filling the higher bits with 0 and discarding the lower ones
ASR n Arithmetic shift right Shift the bits right by \(n\), filling the higher bits with copies of bit 15 and discarding the lower ones. This preserves the sign of a signed number
ROR n Rotate right Rotate the bits right by \(n\), filling the higher bits with the lower bits being shifted out
RRX Rotate right with carry Rotate the bits right by 1, filling bit 15 with the carry flag and discarding bit 0

Flags

Flag Meaning Description
N Negative The result, viewed as a two's complement signed number, is negative
Z Zero The result equals 0
C Carry Instruction dependent. For addition, the result wrapped past 232
V Overflow Instruction dependent. For addition, the inputs have the same sign that is different than the results
Q Saturated Signed overflow (result saturated)

Conditions

Condition Meaning Flags
eq Equal Z = 1
ne Not equal Z = 0
cs, hs Carry set, unsigned higher or same C = 1
cc, lo Carry clear, unsigned lower C = 0
mi Minus, negative N = 1
pl Plus, positive or zero N = 0
vs Overflow set V = 1
vc Overflow clear V = 0
hi Unsigned higher C = 1 ∧ Z = 0
ls Unsigned lower or same C = 0 ∨ Z = 1
ge Signed greater or equal N = V
lt Signed less N ≠ V
gt Signed greater Z = 0 ∧ N = V
le Signed less or equal Z = 1 ∨ N ≠ V
al, <omit> Always any

Width

Suffix Meaning Opcode width
.n Narrow 16 bits
.w Wide 32 bits
<omit> Unset Assembler decides

The width is an optional suffix on the instruction name (after any condition).