Assembly (AVR) Cheat Sheet
- Assembler Directives
- Registers
- r0 → freely available register that can be used for temporary values
- r1 → assume to always hold value of 0; must be cleared if used
- Caller-saved: r18 → r27, r30 → r31
- Callee-saved: r2 → r17, r28 → r29
- X → r27:r26
- Y → r29:r28
- Z → r31:r30
- Jump Instructions
- breq - branch if equal (signed and unsigned)
- brne - branch if not equal (signed and unsigned)
- brlt - branch if less than (signed)
- brlo - branch if lower/branch if less than (unsigned)
- brge - branch if greater than or equal (signed)
- brsh - branch if greater than or equal/branch if same or higher (unsigned)
- Instructions (K and q represent constants)
ldi Ra, K |
lds Ra, address |
sts address, Rs |
clr Ra |
add Ra, Rb |
adc Ra, Rb |
adiw Ra, K |
sub Ra, Rb |
subi Ra, K |
sbiw Ra, K |
inc Ra |
dec Ra |
mul Ra, Rb |
movw Ra, Rb |
lsl Ra |
lsr Ra |
push Ra |
pop Ra |
call address |
mov Ra, Rb |
breq address |
brne address |
brge address |
brlt address |
brlo address |
brsh address |
cp Ra, Rb |
cpi Ra, K |
tst Ra |
ld Ra, X / Y / Z |
ld Ra, X+ / Y+ / Z+ |
ld Ra, -X, -Y, -Z |
ldd Ra, Y + q |
ldd Ra, Z + q |
nop |
st X / Y / Z, Ra |
st X+ / Y+ / Z+, Ra |
st -X / -Y / -Z, Ra |
jmp |
ret |