Atmel AVR instruction set
From Wikipedia, the free encyclopedia
Here is the basic Atmel AVR instruction set.
Arithmetic operations work on registers R0-R31 but not directly on RAM and take one clock cycle, except for multiplication and word-wide addition (ADIW and SBIW) which take two cycles.
RAM and I/O space can be accessed only by copying to or from registers. Indirect access (including optional postincrement, predecrement or constant displacement) is possible through registers X, Y, and Z. All accesses to RAM takes two clock cycles. Moving between registers and I/O is one cycle. Moving eight-bit or sixteen-between registers or constant to register is also one cycle. Reading program memory (LPM) takes three cycles.
There are two types of conditional branches: jumps to address and skips. Conditional branches (BRxx) can test ALU flag and jump to specified address. Skips (SBxx) test arbitrary bit in registers or I/O and skip the next instruction if the test was true.
Arithmetic | Bit & Others | Transfer | Jump | Branch | Call |
---|---|---|---|---|---|
ADD Rd, Rr COM Rd MUL Rd, Rr |
BSET s |
MOV Rd, Rr |
RJMP K12 |
CPSE Rd, Rr |
RCALL K12 |
[edit] Instruction set inheritance
Not all instructions are implemented in all AVR controllers. This is the case of the instructions performing multiplications, extended loads/jumps/calls, long jumps, and power control.
Family | Members | Arithmetic | Branches | Transfers | Bit-Wise |
---|---|---|---|---|---|
Minimal Core | At90s1200 Attiny10 Attiny11 Attiny12 Attiny15 Attiny28 |
ADD ADC SUB SUBI SBC SBCI AND ANDI OR ORI EOR COM NEG SBR CBR INC DEC TST CLR SER |
RJMP, RCALL, RET, RETI, CPSE, CP, CPC, CPI, SBRC, SBRS, SBIC, SBIS, BRBS, BRBC, BREQ, BRNE, BRCS, BRCC, BRSH, BRLO, BRMI, BRPL, BRGE, BRLT, BRHS, BRHC, BRTS, BRTC, BRVS, BRVC, BRIE, BRID | LD ST MOV LDI IN OUT LPM |
SBI, CBI, LSL, LSR, ROL, ROR, ASR, SWAP, BSET, BCLR, BST, BLD, SEC, CLC, SEN, CLN, SEZ, CLZ, SEI, CLI, SES, CLS, SEV, CLV, SET, CLT, SEH, CLH, NOP, SLEEP, WDR |
Classic Core up to 8K Program Space | at90s2313 at90s2323 attiny22 at90s2333 at90s2343 at90s4414 at90s4433 at90s4434 at90s8515 at90c8534 at90s8535 |
+ ADIW, SBIW | + IJMP, ICALL | + LD (now 9 modes), LDD, LDS, ST (9 modes), STD, STS, PUSH, POP | (nothing new) |
classic AVR core with up to 128K | atmega103, atmega603, at43usb320, at76c711 | + ??? | + ??? | + ??? | + ??? |
enhanced AVR core with up to 8K | atmega8, atmega83, atmega85 | + MUL, MULS, MULSU, FMUL, FMULS, FMULSU | + JMP, CALL | + MOVW, LPM (3 modes), SPM, | (nothing new) |
enhanced AVR core with up to 128K | atmega16, atmega161, atmega163, atmega32, atmega323, atmega64, atmega128, at43usb355, at94k | (nothing new) | (nothing new) | (nothing new) | + BREAK |