25 Instruction Set Summary

Table 25-1. Arithmetic and Logic Instructions
MnemonicOperandsDescriptionOpFlags#Clocks AVRrc
ADDRd, RrAdd without CarryRd←Rd + RrZ,C,N,V,S,H1
ADCRd, RrAdd with CarryRd←Rd + Rr + CZ,C,N,V,S,H1
ADIWRd, KAdd Immediate to WordRd←Rd + 1:Rd + KZ,C,N,V,SN/A
SUBRd, RrSubtract without CarryRd←Rd - RrZ,C,N,V,S,H1
SUBIRd, KSubtract ImmediateRd←Rd - KZ,C,N,V,S,H1
SBCRd, RrSubtract with CarryRd←Rd - Rr - CZ,C,N,V,S,H1
SBCIRd, KSubtract Immediate with CarryRd←Rd - K - CZ,C,N,V,S,H1
SBIWRd, KSubtract Immediate from WordRd + 1:Rd←Rd + 1:Rd - KZ,C,N,V,SN/A
ANDRd, RrLogical ANDRd←Rd • RrZ,N,V,S1
ANDIRd, KLogical AND with ImmediateRd←Rd • KZ,N,V,S1
ORRd, RrLogical ORRd←Rd v RrZ,N,V,S1
ORIRd, KLogical OR with ImmediateRd←Rd v KZ,N,V,S1
EORRd, RrExclusive ORRd←Rd ⊕ RrZ,N,V,S1
COMRdOne’s ComplementRd←$FF - RdZ,C,N,V,S1
NEGRdTwo’s ComplementRd←$00 - RdZ,C,N,V,S,H1
SBRRd,KSet Bit(s) in RegisterRd←Rd v KZ,N,V,S1
CBRRd,KClear Bit(s) in RegisterRd←Rd • ($FFh - K)Z,N,V,S1
INCRdIncrementRd←Rd + 1Z,N,V,S1
DECRdDecrementRd←Rd - 1Z,N,V,S1
TSTRdTest for Zero or MinusRd←Rd • RdZ,N,V,S1
CLRRdClear RegisterRd←Rd ⊕ RdZ,N,V,S1
SERRdSet RegisterRd←$FFNone1
Table 25-2. Branch Instructions
MnemonicOperandsDescriptionOpFlags#Clocks AVRrc
RJMPkRelative JumpPC←PC + k + 1None2
IJMPIndirect Jump to (Z)

PC(15:0)

PC(21:16)

←


←

Z

0

None2
RCALLkRelative Call SubroutinePC←PC + k + 1None3(1)
ICALLIndirect Call to (Z)

PC(15:0)

PC(21:16)

←


←

Z

0

None3(1)
RETSubroutine ReturnPC←STACKNone6(1)
RETIInterrupt ReturnPC←STACKI6(1)
CPSERd,RrCompare, Skip if Equalif (Rd = Rr) PC←PC + 2 or 3None1 / 2
CPRd,RrCompareRd - RrZ,C,N,V,S,H1
CPCRd,RrCompare with CarryRd - Rr - CZ,C,N,V,S,H1
CPIRd,KCompare with ImmediateRd - KZ,C,N,V,S,H1
SBRCRr, bSkip if Bit in Register Clearedif (Rr(b) = 0) PC←PC + 2 or 3None1 / 2
SBRSRr, bSkip if Bit in Register Setif (Rr(b) = 1) PC←PC + 2 or 3None1 / 2
SBICA, bSkip if Bit in I/O Register Clearedif (I/O(A,b) = 0) PC←PC + 2 or 3None1 / 2
SBISA, bSkip if Bit in I/O Register SetIf (I/O(A,b) =1) PC←PC + 2 or 3None1 / 2
BRBSs, kBranch if Status Flag Setif (SREG(s) = 1) then PC←PC + k + 1None1 / 2
BRBCs, kBranch if Status Flag Clearedif (SREG(s) = 0) then PC←PC + k + 1None1 / 2
BREQ kBranch if Equalif (Z = 1) then PC←PC + k + 1None1 / 2
BRNE kBranch if Not Equalif (Z = 0) then PC←PC + k + 1None1 / 2
BRCS kBranch if Carry Setif (C = 1) then PC←PC + k + 1None1 / 2
BRCC kBranch if Carry Clearedif (C = 0) then PC←PC + k + 1None1 / 2
BRSH kBranch if Same or Higherif (C = 0) then PC←PC + k + 1None1 / 2
BRLO kBranch if Lowerif (C = 1) then PC←PC + k + 1None1 / 2
BRMI kBranch if Minusif (N = 1) then PC←PC + k + 1None1 / 2
BRPL kBranch if Plusif (N = 0) then PC←PC + k + 1None1 / 2
BRGE kBranch if Greater or Equal, Signedif (N ⊕ V= 0) then PC←PC + k + 1None1 / 2
BRLT kBranch if Less Than, Signedif (N ⊕ V= 1) then PC←PC + k + 1None1 / 2
BRHS kBranch if Half Carry Flag Setif (H = 1) then PC←PC + k + 1None1 / 2
BRHC kBranch if Half Carry Flag Clearedif (H = 0) then PC←PC + k + 1None1 / 2
BRTS kBranch if T Flag Setif (T = 1) then PC←PC + k + 1None1 / 2
BRTC kBranch if T Flag Clearedif (T = 0) then PC←PC + k + 1None1 / 2
BRVS kBranch if Overflow Flag is Setif (V = 1) then PC←PC + k + 1None1 / 2
BRVC kBranch if Overflow Flag is Clearedif (V = 0) then PC←PC + k + 1None1 / 2
BRIE kBranch if Interrupt Enabledif (I = 1) then PC←PC + k + 1None1 / 2
BRID kBranch if Interrupt Disabledif (I = 0) then PC←PC + k + 1None1 / 2
Table 25-3. Data Transfer Instructions
MnemonicOperandsDescriptionOpFlags#Clocks AVRrc
MOVRd, RrCopy RegisterRd←RrNone1
LDIRd, KLoad ImmediateRd←KNone1
LDSRd, kLoad Direct from data spaceRd←(k)None2
LDRd, XLoad IndirectRd←(X)None1 / 2
LDRd, X+Load Indirect and Post-Increment

Rd

X

←


←

(X)


X + 1

None2 / 3
LDRd, -XLoad Indirect and Pre-Decrement

X

Rd

←


←

X - 1


(X)

None2 / 3
LDRd, YLoad IndirectRd←(Y)None1 / 2
LDRd, Y+Load Indirect and Post-Increment

Rd

Y

←


←

(Y)

Y + 1

None2 / 3
LDRd, -YLoad Indirect and Pre-Decrement

Y

Rd

←


←

Y - 1


(Y)

None2 / 3
LDDRd, Y+qLoad Indirect with DisplacementRd←(Y + q)NoneN/A
LDRd, ZLoad IndirectRd←(Z)None1 / 2
LDRd, Z+Load Indirect and Post-Increment

Rd

Z

←


←

(Z)

Z+1

None2 / 3
LDRd, -ZLoad Indirect and Pre-Decrement

Z

Rd

←


←

Z - 1

(Z)

None2 / 3
LDDRd, Z+qLoad Indirect with DisplacementRd←(Z + q)NoneN/A
STSk, RrStore Direct to Data Space(k)←RdNone1
STX, RrStore Indirect(X)←RrNone1
STX+, RrStore Indirect and Post-Increment

(X)

X

←


←

Rr

X + 1

None1
ST-X, RrStore Indirect and Pre-Decrement

X

(X)

←


←

X - 1


Rr

None2
STY, RrStore Indirect(Y)←RrNone1
STY+, RrStore Indirect and Post-Increment

(Y)

Y

←


←

Rr

Y + 1

None1
ST-Y, RrStore Indirect and Pre-Decrement

Y

(Y)

←


←

Y - 1

Rr

None2
STDY+q, RrStore Indirect with Displacement(Y + q)←RrNoneN/A
STZ, RrStore Indirect(Z)←RrNone1
STZ+, RrStore Indirect and Post-Increment

(Z)

Z

←


←

Rr


Z + 1
None1
ST-Z, RrStore Indirect and Pre-DecrementZ←Z - 1None2
STDZ+q,RrStore Indirect with Displacement(Z + q)←RrNoneN/A
LPMLoad Program MemoryR0←(Z)NoneN/A
INRd, AIn From I/O LocationRd←I/O(A)None1
OUTA, RrOut To I/O LocationI/O(A)←RrNone1
PUSHRrPush Register on StackSTACK←RrNone1(1)
POPRdPop Register from StackRd←STACKNone3(1)
Table 25-4. Bit and Bit-test Instructions
MnemonicOperandsDescriptionOpFlags#Clocks AVRrc
LSLRdLogical Shift Left

Rd(n+1)

Rd(0)

C

←

←

←

Rd(n)


0

Rd(7)

Z,C,N,V,H1
LSRRdLogical Shift Right

Rd(n)

Rd(7)

C

←

←

←

Rd(n+1)


0

Rd(0)

Z,C,N,V1
ROLRdRotate Left Through Carry

Rd(0)

Rd(n+1)

C

←

←

←

C

Rd(n)

Rd(7)

Z,C,N,V,H1
RORRdRotate Right Through Carry

Rd(7)

Rd(n)

C

←

←

←

C

Rd(n+1)

Rd(0)

Z,C,N,V1
ASRRdArithmetic Shift RightRd(n)←Rd(n+1), n=0..6Z,C,N,V1
SWAPRdSwap NibblesRd(3..0)↔Rd(7..4)None1
SBIA, bSet Bit in I/O RegisterI/O(A, b)←1None1
CBIA, bClear Bit in I/O RegisterI/O(A, b)←0None1
BSTRr, bBit Store from Register to TT←Rr(b)T1
BLDRd, bBit load from T to RegisterRd(b)←TNone1
BSETsFlag SetSREG(s)←1SREG(s)1
BCLRsFlag ClearSREG(s)←0SREG(s)1
SECSet CarryC←1C1
CLCClear CarryC←0C1
SENSet Negative FlagN←1N1
CLNClear Negative FlagN←0N1
SEZSet Zero FlagZ←1Z1
CLZClear Zero FlagZ←0Z1
SEIGlobal Interrupt EnableI←1I1
CLIGlobal Interrupt DisableI←0I1
SESSet Signed Test FlagS←1S1
CLSClear Signed Test FlagS←0S1
SEVSet Two’s Complement OverflowV←1V1
CLVClear Two’s Complement OverflowV←0V1
SETSet T in SREGT←1T1
CLTClear T in SREGT←0T1
SEHSet Half Carry Flag in SREGH←1H1
CLHClear Half Carry Flag in SREGH←0H1
Table 25-5. MCU Control Instructions
MnemonicOperandsDescriptionOperationFlags#Clocks AVRrc
BREAKBreak(See also in Debug interface description)None1
NOPNo OperationNone1
SLEEPSleep(see also power management and sleep description)None1
WDRWatchdog Reset(see also Watchdog Controller description)None1
Note:
  1. Cycle time for data memory accesses assume internal RAM access, and are not valid for accesses through the NVM controller. A minimum of one extra cycle must be added when accessing memory through the NVM controller (such as Flash and EEPROM), but depending on simultaneous accesses by other masters or the NVM controller state, there may be more than one extra cycle.