AVR Microcontrollers AVR Instruction Set Manual OTHER Instruction Set Nomenclature Status Register (SREG) SREG Status Register Carry Flag Zero Flag Negative Flag Two’s complement overflow indicator N ⊕ V, for signed tests Half Carry Flag Transfer bit used by BLD and BST instructions...
Description..........................33 7.2. Status Register (SREG) and Boolean Formula................33 8. AND – Logical AND....................35 8.1. Description..........................35 8.2. Status Register (SREG) and Boolean Formula................35 9. ANDI – Logical AND with Immediate............... 36 9.1. Description..........................36 Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Page 3
20. BRHC – Branch if Half Carry Flag is Cleared............47 20.1. Description..........................47 20.2. Status Register (SREG) and Boolean Formula................47 21. BRHS – Branch if Half Carry Flag is Set..............48 21.1. Description..........................48 21.2. Status Register (SREG) and Boolean Formula................48 Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Page 4
32.1. Description..........................59 32.2. Status Register (SREG) and Boolean Formula................59 33. BRVS – Branch if Overflow Set................60 33.1. Description..........................60 33.2. Status Register (SREG) and Boolean Formula................60 34. BSET – Bit Set in SREG..................61 Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Page 5
44.1. Description..........................72 44.2. Status Register (SREG) and Boolean Formula................72 45. CLT – Clear T Flag....................73 45.1. Description..........................73 45.2. Status Register (SREG) and Boolean Formula................73 46. CLV – Clear Overflow Flag..................74 46.1. Description..........................74 Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Page 6
56.2. Status Register (SREG) and Boolean Formula................88 57. ELPM – Extended Load Program Memory..............89 57.1. Description..........................89 57.2. Status Register (SREG) and Boolean Formula................90 58. EOR – Exclusive OR....................91 58.1. Description..........................91 58.2. Status Register (SREG) and Boolean Formula................91 Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Page 7
70. LD – Load Indirect from Data Space to Register using Index X......107 70.1. Description..........................107 70.2. Status Register (SREG) and Boolean Formula................108 71. LD (LDD) – Load Indirect from Data Space to Register using Index Y....109 Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Page 8
81.1. Description..........................125 81.2. Status Register (SREG) and Boolean Formula................125 82. MULS – Multiply Signed..................126 82.1. Description..........................126 82.2. Status Register (SREG) and Boolean Formula................126 83. MULSU – Multiply Signed with Unsigned.............. 127 83.1. Description..........................127 Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Page 9
93.2. Status Register (SREG) and Boolean Formula................140 94. RJMP – Relative Jump..................142 94.1. Description..........................142 94.2. Status Register (SREG) and Boolean Formula................142 95. ROL – Rotate Left trough Carry................143 95.1. Description..........................143 95.2. Status Register (SREG) and Boolean Formula................143 Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Page 10
106.1. Description..........................159 106.2. Status Register (SREG) and Boolean Formula................159 107. SEH – Set Half Carry Flag...................160 107.1. Description..........................160 107.2. Status Register (SREG) and Boolean Formula................160 108. SEI – Set Global Interrupt Flag................161 Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Page 11
119. ST (STD) – Store Indirect From Register to Data Space using Index Y....175 119.1. Description..........................175 119.2. Status Register (SREG) and Boolean Formula................176 120. ST (STD) – Store Indirect From Register to Data Space using Index Z....177 120.1. Description..........................177 Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Stack STACK Stack for return address and pushed registers Stack Pointer to STACK 1.5. Flags ⇔ Flag affected by instruction Flag cleared by instruction Flag set by instruction Flag not affected by instruction Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Program memory (Flash) and Data memory (SRAM, Register file, I/O Memory, and Extended I/O Memory). This chapter describes the various addressing modes supported by the AVR architecture. In the following figures, OP means the operation code part of the instruction word. To simplify, not all figures show the exact location of the addressing bits.
Operand address is contained in six bits of the instruction word. n is the destination or source register address. Note: Some complex AVR Microcontrollers have more peripheral units than can be supported within the 64 locations reserved in the opcode for I/O direct addressing. The extended I/O memory from address 64 to 255 can only be reached by data addressing, not I/O addressing.
Figure 2-5. Data Indirect with Displacement Operand address is the result of the Y- or Z-register contents added to the address contained in six bits of the instruction word. Rd/Rr specify the destination or source register. Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Data Indirect Figure 2-6. Data Indirect Addressing Operand address is the contents of the X-, Y-, or the Z-register. In AVR devices without SRAM, Data Indirect Addressing is called Register Indirect Addressing. Register Indirect Addressing is a subset of Data Indirect Addressing since the data space form 0 to 31 is the Register File.
LPM, the LSB selects low byte if cleared (LSB = 0) or high byte if set (LSB = 1). For SPM, the LSB should be cleared. If ELPM is used, the RAMPZ Register is used to extend the Z-register. Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
LSB selects low byte if cleared (LSB = 0) or high byte if set (LSB = 1). If ELPM Z+ is used, the RAMPZ Register is used to extend the Z-register. 2.11. Direct Program Addressing, JMP and CALL Figure 2-11. Direct Program Memory Addressing Program execution continues at the address immediate in the instruction word. Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Z-register). 2.13. Relative Program Addressing, RJMP and RCALL Figure 2-13. Relative Program Memory Addressing Program execution continues at address PC + k + 1. The relative address k is from -2048 to 2047. Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
V = 0 BRVC Simple Zero Z = 1 BREQ Not zero Z = 0 BRNE Simple Note: Interchange Rd and Rr in the operation before the test, i.e., CP Rd,Rr → CP Rr,Rd. Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Reduced Core (AVRrc), though not all instructions are included in the instruction set for all devices. The table below contains the major versions of the AVR 8-bit CPUs. In addition to the different versions, there are differences dependent of the size of the device memory map.
Page 24
1 / 2 Carry Cleared BRSH Branch if if (C = 0) then ← PC + k + 1 None 1 / 2 1 / 2 1 / 2 1 / 2 Same or Higher Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Page 25
2 / 3 and Post- ← X + 1 Increment Rd, -X Load Indirect ← X - 1 None 2 / 3 and Pre- ← Decrement Rd, Y Load Indirect ← None 1 / 2 Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Page 26
← Z - 1 None and Pre- Decrement (1)(2) (1)(2) (1)(2) Z+q,Rr Store Indirect (Z + q) ← None with Displacement Load Program ← None Memory Rd, Z Load Program ← None Memory Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Page 28
← Interrupt Disable Set Signed ← Test Flag Clear Signed ← Test Flag Set Two’s ← Complement Overflow Clear Two’s ← Complement Overflow Set T in ← SREG Clear T in ← SREG Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Page 29
NVM controller state, there may be more than one extra cycle. One extra cycle must be added when accessing lower (64 bytes of) I/O space. The instruction is not available on all devices. Device dependent. See the device specific datasheet. Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Set if there was carry from the MSB of the result; cleared otherwise. R (Result) equals Rd after the operation. Example: ; Add R1:R0 to R3:R2 add r2,r0 ; Add low byte adc r3,r1 ; Add with carry high byte Words 1 (2 bytes) Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Page 31
Cycles Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Set if there was carry from the MSB of the result; cleared otherwise. R (Result) equals Rd after the operation. Example: add r1,r2 ; Add r2 to r1 (r1=r1+r2) add r28,r28 ; Add r28 to itself (r28=r28+r28) Words 1 (2 bytes) Cycles Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Set if there was carry from the MSB of the result; cleared otherwise. R (Result) equals Rdh:Rdl after the operation (Rdh7-Rdh0 = R15-R8, Rdl7-Rdl0=R7-R0). Example: adiw r25:24,1 ; Add 1 to r25:r24 adiw ZH:ZL,63 ; Add 63 to the Z-pointer(r31:r30) Words 1 (2 bytes) Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Page 34
Cycles Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
; Bitwise and r2 and r3, result in r2 ldi r16,1 ; Set bitmask 0000 0001 in r16 and r2,r16 ; Isolate bit 0 in r2 Words 1 (2 bytes) Cycles Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
R (Result) equals Rd after the operation. Example: andi r17,$0F ; Clear upper nibble of r17 andi r18,$10 ; Isolate bit 4 in r18 andi r19,$AA ; Clear odd bits of r19 Words 1 (2 bytes) Cycles Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
R (Result) equals Rd after the operation. Example: ldi r16,$10 ; Load decimal 16 into r16 asr r16 ; r16=r16 / 2 ldi r17,$FC ; Load -4 in r17 asr r17 ; r17=r17/2 Words 1 (2 bytes) Cycles Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
0 if s = 2; Unchanged otherwise. 0 if s = 1; Unchanged otherwise. 0 if s = 0; Unchanged otherwise. Example: bclr 0 ; Clear Carry Flag bclr 7 ; Disable interrupts Words 1 (2 bytes) Cycles Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
– – Example: ; Copy bit bst r1,2 ; Store bit 2 of r1 in T Flag bld r0,4 ; Load T Flag into bit 4 of r0 Words 1 (2 bytes) Cycles Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
; Compare r20 to the value 5 brbc 1,noteq ; Branch if Zero Flag cleared noteq: nop ; Branch destination (do nothing) Words 1 (2 bytes) Cycles 1 if condition is false 2 if condition is true Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
; Load T bit with bit 3 of r0 brbs 6,bitset ; Branch T bit was set bitset: nop ; Branch destination (do nothing) Words 1 (2 bytes) Cycles 1 if condition is false 2 if condition is true Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
; Add r23 to r22 brcc nocarry ; Branch if carry cleared nocarry: nop ; Branch destination (do nothing) Words 1 (2 bytes) Cycles 1 if condition is false 2 if condition is true Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
; Compare r26 with $56 brcs carry ; Branch if carry set carry: nop ; Branch destination (do nothing) Words 1 (2 bytes) Cycles 1 if condition is false 2 if condition is true Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
The BREAK instruction is used by the On-chip Debug system, and is normally not used in the application software. When the BREAK instruction is executed, the AVR CPU is set in the Stopped Mode. This gives the On-chip Debugger access to internal resources.
; Compare registers r1 and r0 breq equal ; Branch if registers equal equal: nop ; Branch destination (do nothing) Words 1 (2 bytes) Cycles 1 if condition is false 2 if condition is true Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
; Compare registers r11 and r12 brge greateq ; Branch if r11 ≥ r12 (signed) greateq: nop ; Branch destination (do nothing) Words 1 (2 bytes) Cycles 1 if condition is false 2 if condition is true Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
– Example: brhc hclear ; Branch if Half Carry Flag cleared hclear: nop ; Branch destination (do nothing) Words 1 (2 bytes) Cycles 1 if condition is false 2 if condition is true Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
– Example: brhs hset ; Branch if Half Carry Flag set hset: nop ; Branch destination (do nothing) Words 1 (2 bytes) Cycles 1 if condition is false 2 if condition is true Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
– – – Example: brid intdis ; Branch if interrupt disabled intdis: nop ; Branch destination (do nothing) Words 1 (2 bytes) Cycles 1 if condition is false 2 if condition is true Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
– – – Example: brie inten ; Branch if interrupt enabled inten: nop ; Branch destination (do nothing) Words 1 (2 bytes) Cycles 1 if condition is false 2 if condition is true Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
; Compare r19 with $10 brlo loop ; Branch if r19 < $10 (unsigned) nop ; Exit from loop (do nothing) Words 1 (2 bytes) Cycles 1 if condition is false 2 if condition is true Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
; Compare r16 to r1 brlt less ; Branch if r16 < r1 (signed) less: nop ; Branch destination (do nothing) Words 1 (2 bytes) Cycles 1 if condition is false 2 if condition is true Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
; Subtract 4 from r18 brmi negative ; Branch if result negative negative: nop ; Branch destination (do nothing) Words 1 (2 bytes) Cycles 1 if condition is false 2 if condition is true Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
; Compare r27 to 5 brne loop ; Branch if r27<>5 nop ; Loop exit (do nothing) Words 1 (2 bytes) Cycles 1 if condition is false 2 if condition is true Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
; Subtract $50 from r26 brpl positive ; Branch if r26 positive positive: nop ; Branch destination (do nothing) Words 1 (2 bytes) Cycles 1 if condition is false 2 if condition is true Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
; Subtract 4 from r19 brsh highsm ; Branch if r19 >= 4 (unsigned) highsm: nop ; Branch destination (do nothing) Words 1 (2 bytes) Cycles 1 if condition is false 2 if condition is true Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
; Store bit 5 of r3 in T Flag brtc tclear ; Branch if this bit was cleared tclear: nop ; Branch destination (do nothing) Words 1 (2 bytes) Cycles 1 if condition is false 2 if condition is true Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
; Store bit 5 of r3 in T Flag brts tset ; Branch if this bit was set tset: nop ; Branch destination (do nothing) Words 1 (2 bytes) Cycles 1 if condition is false 2 if condition is true Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
; Add r4 to r3 brvc noover ; Branch if no overflow noover: nop ; Branch destination (do nothing) Words 1 (2 bytes) Cycles 1 if condition is false 2 if condition is true Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
; Add r4 to r3 brvs overfl ; Branch if overflow overfl: nop ; Branch destination (do nothing) Words 1 (2 bytes) Cycles 1 if condition is false 2 if condition is true Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
1 if s = 2; Unchanged otherwise. 1 if s = 1; Unchanged otherwise. 1 if s = 0; Unchanged otherwise. Example: bset 6 ; Set T Flag bset 7 ; Enable interrupt Words 1 (2 bytes) Cycles Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
0 if bit b in Rd is cleared. Set to 1 otherwise. Example: ; Copy bit bst r1,2 ; Store bit 2 of r1 in T Flag bld r0,4 ; Load T into bit 4 of r0 Words 1 (2 bytes) Cycles Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
; Check if r16 has a special value breq error ; Branch if equal ret ; Return from subroutine error: rjmp error ; Infinite loop Words 2 (4 bytes) Cycles 4 devices with 16-bit PC Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Page 64
5 devices with 22-bit PC Cycles XMEGA 3 devices with 16-bit PC 4 devices with 22-bit PC Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Status Register (SREG) and Boolean Formula – – – – – – – – Example: cbi $12,7 ; Clear bit 7 in Port D Words 1 (2 bytes) Cycles Cycles XMEGA Cycles Reduced Core tinyAVR Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Set if the result is $00; cleared otherwise. R (Result) equals Rd after the operation. Example: cbr r16,$F0 ; Clear upper nibble of r16 cbr r18,1 ; Clear bit 0 in r18 Words 1 (2 bytes) Cycles Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
1101 1000 40.2. Status Register (SREG) and Boolean Formula – – – – – – – Half Carry Flag cleared. Example: clh ; Clear the Half Carry Flag Words 1 (2 bytes) Cycles Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
SREG ; Store SREG value (temp must be defined by user) cli ; Disable interrupts during timed sequence sbi EECR, EEMWE ; Start EEPROM write sbi EECR, EEWE out SREG, temp ; Restore SREG value (I-Flag) Words 1 (2 bytes) Cycles Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Status Register (SREG) and Boolean Formula – – – – – – – Signed Flag cleared. Example: add r2,r3 ; Add r3 to r2 cls ; Clear Signed Flag Words 1 (2 bytes) Cycles Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
16-bit Opcode: 1001 0100 1110 1000 45.2. Status Register (SREG) and Boolean Formula – – – – – – – T Flag cleared. Example: clt ; Clear T Flag Words 1 (2 bytes) Cycles Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Status Register (SREG) and Boolean Formula – – – – – – – Zero Flag cleared. Example: add r2,r3 ; Add r3 to r2 clz ; Clear zero Words 1 (2 bytes) Cycles Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
R (Result) equals Rd after the operation. Example: com r4 ; Take one’s complement of r4 breq zero ; Branch if zero zero: nop ; Branch destination (do nothing) Words 1 (2 bytes) Cycles Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Set if the absolute value of the contents of Rr is larger than the absolute value of Rd; cleared otherwise. R (Result) after the operation. Example: cp r4,r19 ; Compare r4 with r19 brne noteq ; Branch if r4 <> r19 noteq: nop ; Branch destination (do nothing) Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Page 78
Words 1 (2 bytes) Cycles Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Set if the absolute value of the contents of Rr plus previous carry is larger than the absolute value of Rd; cleared otherwise. R (Result) after the operation. Example: ; Compare r3:r2 with r1:r0 cp r2,r0 ; Compare low byte cpc r3,r1 ; Compare high byte Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Page 80
; Branch if not equal noteq: nop ; Branch destination (do nothing) Words 1 (2 bytes) Cycles Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Set if the absolute value of K is larger than the absolute value of Rd; cleared otherwise. R (Result) after the operation. Example: cpi r19,3 ; Compare r19 with 3 brne error ; Branch if r19<>3 error: nop ; Branch destination (do nothing) Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Page 82
Words 1 (2 bytes) Cycles Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
1 if condition is false (no skip) 2 if condition is true (skip is executed) and the instruction skipped is 1 word 3 if condition is true (skip is executed) and the instruction skipped is 2 words Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
54.1. Description The module is an instruction set extension to the AVR CPU, performing DES iterations. The 64-bit data block (plaintext or ciphertext) is placed in the CPU register file, registers R0-R7, where LSB of data is placed in LSB of R0 and MSB of data is placed in MSB of R7. The full 64-bit key (including parity bits) is placed in registers R8-R15, organized in the register file with LSB of key in LSB of R8 and MSB of key in MSB of R15.
Z+ ; Load constant from Program ; memory pointed to by RAMPZ:Z (Z is r31:r30) Table_1: .dw 0x3738 ; 0x38 is addressed when Z ; 0x37 is addressed when Z Words 1 (2 bytes) Cycles Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Set if the result is $00; cleared otherwise. R (Result) equals Rd after the operation. Example: eor r4,r4 ; Clear r4 eor r0,r22 ; Bitwise exclusive or between r0 and r22 Words 1 (2 bytes) Cycles Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
PC ← PC + 1 (i) PC ← PC + 1 16-bit Opcode: 0000 0011 0ddd 1rrr 59.2. Status Register (SREG) and Boolean Formula ⇔ ⇔ – – – – – – C R16 Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Z R15 • R14 • R13 • R12 • R11 • R10 • R9 • R8R7 • R6 • R5 • R4 • R3 • R2 • R1 • R0 Set if the result is $0000; cleared otherwise. Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Page 95
R (Result) equals R1,R0 after the operation. Example: fmuls r23,r22 ; Multiply signed r23 and r22 in (1.7) format, result in (1.15) format mov w r23:r22,r1:r0 ; Copy result back in r23:r22 Words 1 (2 bytes) Cycles Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
16 ≤ d ≤ 23, 16 ≤ r ≤ 23 PC ← PC + 1 16-bit Opcode: 0000 0011 1ddd 1rrr 61.2. Status Register (SREG) and Boolean Formula ⇔ ⇔ – – – – – – C R16 Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
; Call routine pointed to by r31:r30 Words 1 (2 bytes) Cycles 3 devices with 16-bit PC 4 devices with 22-bit PC ® Cycles XMEGA 2 devices with 16-bit PC 3 devices with 22-bit PC Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Status Register (SREG) and Boolean Formula – – – – – – – – Example: mov r30,r0 ; Set offset to jump table ijmp ; Jump to routine pointed to by r31:r30 Words 1 (2 bytes) Cycles Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Example: in r25,$16 ; Read Port B cpi r25,4 ; Compare read value to constant breq exit ; Branch if r25=4 exit: nop ; Branch destination (do nothing) Words 1 (2 bytes) Cycles Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
PC ← PC + 1 (ii) LD Rd, X+ 0 ≤ d ≤ 31 PC ← PC + 1 (iii) LD Rd, -X 0 ≤ d ≤ 31 PC ← PC + 1 16-bit Opcode: Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
But if an interrupt occur (before the last clock cycle) no additional clock cycles are necessary when loading from the program memory. Hence, the instruction takes only one clock cycle to execute. Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Y: Unchanged, q: Displacement Syntax: Operands: Program Counter: LD Rd, Y 0 ≤ d ≤ 31 PC ← PC + 1 (ii) LD Rd, Y+ 0 ≤ d ≤ 31 PC ← PC + 1 Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Loading data from the data memory takes two clock cycles, and loading from the program memory takes three clock cycles. But if an interrupt occur (before the last clock cycle) no additional Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Page 111
Hence, the instruction takes only one clock cycle to execute. Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
But if an interrupt occur (before the last clock cycle) no additional clock cycles are necessary when loading from the program memory. Hence, the instruction takes only one clock cycle to execute. Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Page 114
But if an interrupt occur (before the last clock cycle) no additional clock cycles are necessary when loading from the program memory. Hence, the instruction takes only one clock cycle to execute. Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
; Clear Z high byte ldi r30,$F0 ; Set Z low byte to $F0 lpm ; Load constant from Program ; memory pointed to by Z Words 1 (2 bytes) Cycles Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
; add r1 to r2 sts $FF00,r2 ; Write back Words 2 (4 bytes) Cycles Cycles XMEGA 2 If the LDS instruction is accessing internal SRAM, one extra cycle is inserted Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
; Load r16 with the contents of data space location $00 add r16,r17 ; add r17 to r16 sts $00,r16 ; Write result to the same address it was fetched from Words 1 (2 bytes) Cycles Note: Registers r0...r15 are remapped to r16...r31. Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
PC ← PC + 1 16-bit Opcode: 1001 0101 1100 1000 (ii) 1001 000d dddd 0100 (iii) 1001 000d dddd 0101 76.2. Status Register (SREG) and Boolean Formula – – – – – – – – Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Page 119
Z ; Load constant from Program ; Memory pointed to by Z (r31:r30) Table_1: .dw 0x5876 ; 0x76 is addresses when Z ; 0x58 is addresses when Z Words 1 (2 bytes) Cycles Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Set if, before the shift, the MSB of Rd was set; cleared otherwise. R (Result) equals Rd after the operation. Example: add r0,r4 ; Add r4 to r0 lsl r0 ; Multiply r0 by 2 Words 1 (2 bytes) Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Page 121
Cycles Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Set if, before the shift, the LSB of Rd was set; cleared otherwise. R (Result) equals Rd after the operation. Example: add r0,r4 ; Add r4 to r0 lsr r0 ; Divide r0 by 2 Words 1 (2 bytes) Cycles Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Set if the result is $0000; cleared otherwise. R (Result) equals R1,R0 after the operation. Example: mul r5,r4 ; Multiply unsigned r5 and r4 mov w r4,r0 ; Copy result back in r5:r4 Words 1 (2 bytes) Cycles Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Set if the result is $0000; cleared otherwise. R (Result) equals R1,R0 after the operation. Example: muls r21,r20 ; Multiply signed r21 and r20 mov w r20,r0 ; Copy result back in r21:r20 Words 1 (2 bytes) Cycles Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Register after operation is $00. R (Result) equals Rd after the operation. Example: sub r11,r0 ; Subtract r0 from r11 brpl positive ; Branch if result positive Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Page 130
; Take two’s complement of r11 positive: nop ; Branch destination (do nothing) Words 1 (2 bytes) Cycles Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
; Clear r16 ser r17 ; Set r17 out $18,r16 ; Write zeros to Port B nop ; Wait (do nothing) out $18,r17 ; Write ones to Port B Words 1 (2 bytes) Cycles Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
; Do bitwise or between registers bst r15,6 ; Store bit 6 of r15 in T Flag brts ok ; Branch if T Flag set ok: nop ; Branch destination (do nothing) Words 1 (2 bytes) Cycles Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Set if the result is $00; cleared otherwise. R (Result) equals Rd after the operation. Example: ori r16,$F0 ; Set high nibble of r16 ori r17,1 ; Set bit 0 of r17 Words 1 (2 bytes) Cycles Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
; Clear r16 ser r17 ; Set r17 out $18,r16 ; Write zeros to Port B nop ; Wait (do nothing) out $18,r17 ; Write ones to Port B Words 1 (2 bytes) Cycles Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
; Save r14 on the Stack push r13 ; Save r13 on the Stack pop r13 ; Restore r13 pop r14 ; Restore r14 ret ; Return from subroutine Words 1 (2 bytes) Cycles Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
; Save r14 on the Stack push r13 ; Save r13 on the Stack pop r13 ; Restore r13 pop r14 ; Restore r14 ret ; Return from subroutine Words 1 (2 bytes) Cycles Cycles XMEGA Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Relative call to an address within PC - 2K + 1 and PC + 2K (words). The return address (the instruction after the RCALL) is stored onto the Stack. See also CALL. For AVR microcontrollers with Program memory not exceeding 4K words (8KB) this instruction can address the entire memory from every address location.
; Save r14 on the Stack pop r14 ; Restore r14 ret ; Return from subroutine Words 1 (2 bytes) Cycles 4 devices with 16-bit PC 5 devices with 22-bit PC Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
RETI is executed. In the AVR XMEGA devices, RETI will not modify the global interrupt flag in SREG Atmel AVR Instruction Set Manual [OTHER]...
Page 141
ISR. This bit should be modified using SEI and CLI instructions when needed. Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
94.1. Description Relative jump to an address within PC - 2K +1 and PC + 2K (words). For AVR microcontrollers with Program memory not exceeding 4K words (8KB) this instruction can address the entire memory from every address location. See also JMP.
Example: lsl r18 ; Multiply r19:r18 by two rol r19 ; r19:r18 is a signed or unsigned two-byte integer brcs oneenc ; Branch if carry set oneenc: nop ; Branch destination (do nothing) Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Page 144
Words 1 (2 bytes) Cycles Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
; r19:r18 is an unsigned two-byte integer brcc zeroenc1 ; Branch if carry cleared asr r17 ; Divide r17:r16 by two ror r16 ; r17:r16 is a signed two-byte integer brcc zeroenc2 ; Branch if carry cleared Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Page 146
; Branch destination (do nothing) zeroenc1: nop ; Branch destination (do nothing) Words 1 (2 bytes) Cycles Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Set if the absolute value of the contents of Rr plus previous carry is larger than the absolute value of the Rd; cleared otherwise. R (Result) equals Rd after the operation. Example: ; Subtract r1:r0 from r3:r2 sub r2,r0 ; Subtract low byte sbc r3,r1 ; Subtract with carry high byte Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Page 148
Words 1 (2 bytes) Cycles Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Set if the absolute value of the constant plus previous carry is larger than the absolute value of Rd; cleared otherwise. R (Result) equals Rd after the operation. Example: ; Subtract $4F23 from r17:r16 subi r16,$23 ; Subtract low byte sbci r17,$4F ; Subtract with carry high byte Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Page 150
Words 1 (2 bytes) Cycles Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
– Example: out $1E,r0 ; Write EEPROM address sbi $1C,0 ; Set read bit in EECR in r1,$1D ; Read EEPROM data Words 1 (2 bytes) Cycles Cycles XMEGA Cycles Reduced Core tinyAVR Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
2 if condition is false (no skip) 3 if condition is true (skip is executed) and the instruction skipped is 1 word 4 if condition is true (skip is executed) and the instruction skipped is 2 words Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
2 if condition is false (no skip) 3 if condition is true (skip is executed) and the instruction skipped is 1 word 4 if condition is true (skip is executed) and the instruction skipped is 2 words Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Set if the absolute value of K is larger than the absolute value of Rd; cleared otherwise. R (Result) equals Rdh:Rdl after the operation (Rdh7-Rdh0 = R15-R8, Rdl7-Rdl0=R7-R0). Example: sbiw r25:r24,1 ; Subtract 1 from r25:r24 sbiw YH:YL,63 ; Subtract 63 from the Y-pointer(r29:r28) Words 1 (2 bytes) Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Page 155
Cycles Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Set if the result is $00; cleared otherwise. R (Result) equals Rd after the operation. Example: sbr r16,3 ; Set bits 0 and 1 in r16 sbr r17,$F0 ; Set 4 MSB in r17 Words 1 (2 bytes) Cycles Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
1 if condition is false (no skip) 2 if condition is true (skip is executed) and the instruction skipped is 1 word 3 if condition is true (skip is executed) and the instruction skipped is 2 words Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
1 if condition is false (no skip) 2 if condition is true (skip is executed) and the instruction skipped is 1 word 3 if condition is true (skip is executed) and the instruction skipped is 2 words Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
1000 106.2. Status Register (SREG) and Boolean Formula – – – – – – – Carry Flag set. Example: sec ; Set Carry Flag adc r0,r1 ; r0=r0+r1+1 Words 1 (2 bytes) Cycles Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
0100 0101 1000 107.2. Status Register (SREG) and Boolean Formula – – – – – – – Half Carry Flag set. Example: seh ; Set Half Carry Flag Words 1 (2 bytes) Cycles Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
– Global Interrupt Flag set. Example: sei ; set global interrupt enable sleep ; enter sleep, waiting for interrupt ; note: will enter sleep before any pending interrupt(s) Words 1 (2 bytes) Cycles Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
109.2. Status Register (SREG) and Boolean Formula – – – – – – – Negative Flag set. Example: add r2,r19 ; Add r19 to r2 sen ; Set Negative Flag Words 1 (2 bytes) Cycles Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
; Clear r16 ser r17 ; Set r17 out $18,r16 ; Write zeros to Port B nop ; Delay (do nothing) out $18,r17 ; Write ones to Port B Words 1 (2 bytes) Cycles Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
111.2. Status Register (SREG) and Boolean Formula – – – – – – – Signed Flag set. Example: add r2,r19 ; Add r19 to r2 ses ; Set Negative Flag Words 1 (2 bytes) Cycles Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
16-bit Opcode: 1001 0100 0110 1000 112.2. Status Register (SREG) and Boolean Formula – – – – – – – T Flag set. Example: set ; Set T Flag Words 1 (2 bytes) Cycles Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
113.2. Status Register (SREG) and Boolean Formula – – – – – – – V: 1 Overflow Flag set. Example: add r2,r19 ; Add r19 to r2 sev ; Set Overflow Flag Words 1 (2 bytes) Cycles Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
114.2. Status Register (SREG) and Boolean Formula – – – – – – – Zero Flag set. Example: add r2,r19 ; Add r19 to r2 sez ; Set Zero Flag Words 1 (2 bytes) Cycles Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
;- error handling is not included ;- the routine must be placed inside the boot space ; (at least the do_spm sub routine) ;- registers used: r0, r1, temp1, temp2, looplo, loophi, spmcrval Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Page 170
SPMCR sbrc temp1, SPMEN rjmp wait ;SPM timed sequence out SPMCR, spmcrval ;restore SREG (to enable interrupts if originally enabled) out SREG, temp2 Words 1 (2 bytes) Cycles Depends on the operation Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
PC ← PC + 1 (ii) ST X+, Rr 0 ≤ r ≤ 31 PC ← PC + 1 (iii) ST -X, Rr 0 ≤ r ≤ 31 PC ← PC + 1 16-bit Opcode: Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
-X,r3 ; Store r3 in data space loc. $62(X pre dec) Words 1 (2 bytes) Cycles Cycles XMEGA (i) 1 (ii) 1 (iii) 2 Cycles Reduced Core tinyAVR (i) 1 (ii) 1 (iii) 2 Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
(iii) ST -Y, Rr 0 ≤ r ≤ 31 PC ← PC + 1 (iv) STD Y+q, Rr 0 ≤ r ≤ 31, 0 ≤ q ≤ 63 PC ← PC + 1 Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Z: Unchanged, q: Displacement Syntax: Operands: Program Counter: ST Z, Rr 0 ≤ r ≤ 31 PC ← PC + 1 (ii) ST Z+, Rr 0 ≤ r ≤ 31 PC ← PC + 1 Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
– – Example: lds r2,$FF00 ; Load r2 with the contents of data space location $FF00 add r2,r1 ; add r1 to r2 sts $FF00,r2 ; Write back Words 2 (4 bytes) Cycles Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
; Load r16 with the contents of data space location $00 add r16,r17 ; add r17 to r16 sts $00,r16 ; Write result to the same address it was fetched from Words 1 (2 bytes) Cycles Note: Registers r0...r15 are remapped to r16...r31 Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Set if the absolute value of the contents of Rr is larger than the absolute value of Rd; cleared otherwise. R (Result) equals Rd after the operation. Example: sub r13,r12 ; Subtract r12 from r13 brne noteq ; Branch if r12<>r13 noteq: nop ; Branch destination (do nothing) Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Page 182
Words 1 (2 bytes) Cycles Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Set if the absolute value of K is larger than the absolute value of Rd; cleared otherwise. R (Result) equals Rd after the operation. Example: subi r22,$11 ; Subtract $11 from r22 brne noteq ; Branch if r22<>$11 noteq: nop ; Branch destination (do nothing) Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Page 184
Words 1 (2 bytes) Cycles Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
; Increment r1 swap r1 ; Swap high and low nibble of r1 inc r1 ; Increment high nibble of r1 swap r1 ; Swap back Words 1 (2 bytes) Cycles Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Set if the result is $00; cleared otherwise. R (Result) equals Rd. Example: tst r0 ; Test r0 breq zero ; Branch if r0=0 zero: nop ; Branch destination (do nothing) Words 1 (2 bytes) Cycles Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
"LD – Load Indirect from Data Space to Register using Index X" Section "LD (LDD) – Load Indirect from Data Space to Register using Index Y" Section "LD (LDD) – Load Indirect From Data Space to Register using Index Z" Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
This revision is based on the AVR Instruction Set 0856E-AVR-11/05. Changes done compared to AVR Instruction Set 0856E-AVR-11/05: • Updated “Complete Instruction Set Summary” with DES and SPM #2. • Updated AVR Instruction Set with XMEGA Clock cycles and Instruction Description. Atmel AVR Instruction Set Manual [OTHER] Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016...
Page 191
DISCLAIMER: The information in this document is provided in connection with Atmel products. No license, express or implied, by estoppel or otherwise, to any intellectual property right is granted by this document or in connection with the sale of Atmel products. EXCEPT AS SET FORTH IN THE ATMEL TERMS AND...
Need help?
Do you have a question about the AVR and is the answer not in the manual?
Questions and answers