Reading the tables
Flags are written H S V N Z C (bits of SREG); a dash means the flag is not changed. Cycles are those of the classic cores (AVR, AVRe, AVRe+);
the others differ (overview). Rd is the destination register, Rr the source; K a constant. “All” in the last column means every core has it.
Add, subtract, compare
| Instruction | Encoding | Operation | Flags | Cycles | Cores |
|---|---|---|---|---|---|
ADD Rd,Rr | 0000 11rd dddd rrrr | Rd ← Rd + Rr. With Rd = Rr it is written LSL Rd. | H S V N Z C | 1 | All |
ADC Rd,Rr | 0001 11rd dddd rrrr | Rd ← Rd + Rr + C. With Rd = Rr it is written ROL Rd. | H S V N Z C | 1 | All |
ADIW Rd+1:Rd,K | 1001 0110 KKdd KKKK | Rd+1:Rd ← Rd+1:Rd + K (r24, r26, r28 or r30; K 0 to 63). | S V N Z C | 2 | All but avr1 and the reduced core |
SUB Rd,Rr | 0001 10rd dddd rrrr | Rd ← Rd − Rr. | H S V N Z C | 1 | All |
SUBI Rd,K | 0101 KKKK dddd KKKK | Rd ← Rd − K (r16 to r31). | H S V N Z C | 1 | All |
SBC Rd,Rr | 0000 10rd dddd rrrr | Rd ← Rd − Rr − C. Z stays clear if it was clear (for multi-byte compares). | H S V N Z C | 1 | All |
SBCI Rd,K | 0100 KKKK dddd KKKK | Rd ← Rd − K − C (r16 to r31). | H S V N Z C | 1 | All |
SBIW Rd+1:Rd,K | 1001 0111 KKdd KKKK | Rd+1:Rd ← Rd+1:Rd − K (r24, r26, r28 or r30; K 0 to 63). | S V N Z C | 2 | All but avr1 and the reduced core |
CP Rd,Rr | 0001 01rd dddd rrrr | Rd − Rr, the result discarded: sets the flags for a branch. | H S V N Z C | 1 | All |
CPC Rd,Rr | 0000 01rd dddd rrrr | Rd − Rr − C, discarded. | H S V N Z C | 1 | All |
CPI Rd,K | 0011 KKKK dddd KKKK | Rd − K, discarded (r16 to r31). | H S V N Z C | 1 | All |
NEG Rd | 1001 010d dddd 0001 | Rd ← 0 − Rd (two’s complement). | H S V N Z C | 1 | All |
INC Rd | 1001 010d dddd 0011 | Rd ← Rd + 1; C is not changed. | S V N Z | 1 | All |
DEC Rd | 1001 010d dddd 1010 | Rd ← Rd − 1; C is not changed. | S V N Z | 1 | All |
Logic
| Instruction | Encoding | Operation | Flags | Cycles | Cores |
|---|---|---|---|---|---|
AND Rd,Rr | 0010 00rd dddd rrrr | Rd ← Rd AND Rr; V is cleared. With Rd = Rr it is written TST Rd. | S V N Z | 1 | All |
ANDI Rd,K | 0111 KKKK dddd KKKK | Rd ← Rd AND K (r16 to r31). Assemblers also write it CBR with the complement of the mask. | S V N Z | 1 | All |
OR Rd,Rr | 0010 10rd dddd rrrr | Rd ← Rd OR Rr. | S V N Z | 1 | All |
ORI Rd,K | 0110 KKKK dddd KKKK | Rd ← Rd OR K (r16 to r31). Assemblers also write it SBR. | S V N Z | 1 | All |
EOR Rd,Rr | 0010 01rd dddd rrrr | Rd ← Rd XOR Rr. With Rd = Rr it is written CLR Rd (Rd ← 0). | S V N Z | 1 | All |
COM Rd | 1001 010d dddd 0000 | Rd ← 0xFF − Rd (ones’ complement); C is set. | S V N Z C | 1 | All |
SER Rd (Rd ← 0xFF) is LDI Rd,0xFF: see LDI. The shifts and rotates are on the bits page.
Multiply
The hardware multiplier (cores avr4 and above, every XMEGA and the tinyAVR 0/1/2) leaves a 16-bit result in r1:r0, two cycles for every form. Only Z and C are changed: C is bit 15 of the result.
| Instruction | Encoding | Operation | Cores |
|---|---|---|---|
MUL Rd,Rr | 1001 11rd dddd rrrr | r1:r0 ← Rd × Rr, both unsigned. | avr4 and above |
MULS Rd,Rr | 0000 0010 dddd rrrr | r1:r0 ← Rd × Rr, both signed (r16 to r31). | avr4 and above |
MULSU Rd,Rr | 0000 0011 0ddd 0rrr | r1:r0 ← Rd (signed) × Rr (unsigned); r16 to r23. | avr4 and above |
FMUL Rd,Rr | 0000 0011 0ddd 1rrr | r1:r0 ← (Rd × Rr) << 1, fractional unsigned; r16 to r23. | avr4 and above |
FMULS Rd,Rr | 0000 0011 1ddd 0rrr | r1:r0 ← (Rd × Rr) << 1, fractional signed. | avr4 and above |
FMULSU Rd,Rr | 0000 0011 1ddd 1rrr | r1:r0 ← (Rd × Rr) << 1, Rd signed, Rr unsigned. | avr4 and above |
DES
| Instruction | Encoding | Operation | Cycles | Cores |
|---|---|---|---|---|
DES K | 1001 0100 KKKK 1011 | One round of the Data Encryption Standard on the 64 bits in r7:r0 (data) and r15:r8 (key); K is the round number, 0 to 15. The half-carry flag H chooses the direction: clear encrypts, set decrypts. | 1 (2 when H is set) | XMEGA only |
Not described
- The exact flag equations (the manual gives them); the decoder lists which flags change and which are read, both checked against a running core.
- The two-cycle
DEScase when the half-carry flag is set is the manual’s statement; the decoder gives one cycle.