35 Instruction Set Summary

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

PC(15:0)

PC(21:16)

←


←

Z

0

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

PC(15:0)

PC(21:16)

←


←

Z

0

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

Rd

X

←


←

(X)


X + 1

None
LDRd, -XLoad Indirect and Pre-Decrement

X

Rd

←


←

X - 1


(X)

None
LDRd, YLoad IndirectRd←(Y)None
LDRd, Y+Load Indirect and Post-Increment

Rd

Y

←


←

(Y)

Y + 1

None
LDRd, -YLoad Indirect and Pre-Decrement

Y

Rd

←


←

Y - 1


(Y)

None
LDDRd, Y+qLoad Indirect with DisplacementRd←(Y + q)None
LDRd, ZLoad IndirectRd←(Z)None
LDRd, Z+Load Indirect and Post-Increment

Rd

Z

←


←

(Z)

Z+1

None
LDRd, -ZLoad Indirect and Pre-Decrement

Z

Rd

←


←

Z - 1

(Z)

None
LDDRd, Z+qLoad Indirect with DisplacementRd←(Z + q)None
STSk, RrStore Direct to Data Space(k)←RdNone
STX, RrStore Indirect(X)←RrNone
STX+, RrStore Indirect and Post-Increment

(X)

X

←


←

Rr

X + 1

None
ST-X, RrStore Indirect and Pre-Decrement

X

(X)

←


←

X - 1


Rr

None
STY, RrStore Indirect(Y)←RrNone
STY+, RrStore Indirect and Post-Increment

(Y)

Y

←


←

Rr

Y + 1

None
ST-Y, RrStore Indirect and Pre-Decrement

Y

(Y)

←


←

Y - 1

Rr

None
STDY+q, RrStore Indirect with Displacement(Y + q)←RrNone
STZ, RrStore Indirect(Z)←RrNone
STZ+, RrStore Indirect and Post-Increment

(Z)

Z

←


←

Rr


Z + 1
None
ST-Z, RrStore Indirect and Pre-DecrementZ←Z - 1None
STDZ+q,RrStore Indirect with Displacement(Z + q)←RrNone
LPMLoad Program MemoryR0←(Z)None
INRd, AIn From I/O LocationRd←I/O(A)None
OUTA, RrOut To I/O LocationI/O(A)←RrNone
PUSHRrPush Register on StackSTACK←RrNone
POPRdPop Register from StackRd←STACKNone
Table 35-4. Bit and Bit-Test Instructions
MnemonicOperandsDescriptionOpFlags
LSLRdLogical Shift Left

Rd(n+1)

Rd(0)

C

←

←

←

Rd(n)


0

Rd(7)

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

Rd(n)

Rd(7)

C

←

←

←

Rd(n+1)


0

Rd(0)

Z,C,N,V
ROLRdRotate Left Through Carry

Rd(0)

Rd(n+1)

C

←

←

←

C

Rd(n)

Rd(7)

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

Rd(7)

Rd(n)

C

←

←

←

C

Rd(n+1)

Rd(0)

Z,C,N,V
ASRRdArithmetic Shift RightRd(n)←Rd(n+1), n=0..6Z,C,N,V
SWAPRdSwap NibblesRd(3..0)↔Rd(7..4)None
SBIA, bSet Bit in I/O RegisterI/O(A, b)←1None
CBIA, bClear Bit in I/O RegisterI/O(A, b)←0None
BSTRr, bBit Store from Register to TT←Rr(b)T
BLDRd, bBit load from T to RegisterRd(b)←TNone
BSETsFlag SetSREG(s)←1SREG(s)
BCLRsFlag ClearSREG(s)←0SREG(s)
SECSet CarryC←1C
CLCClear CarryC←0C
SENSet Negative FlagN←1N
CLNClear Negative FlagN←0N
SEZSet Zero FlagZ←1Z
CLZClear Zero FlagZ←0Z
SEIGlobal Interrupt EnableI←1I
CLIGlobal Interrupt DisableI←0I
SESSet Signed Test FlagS←1S
CLSClear Signed Test FlagS←0S
SEVSet Two’s Complement OverflowV←1V
CLVClear Two’s Complement OverflowV←0V
SETSet T in SREGT←1T
CLTClear T in SREGT←0T
SEHSet Half Carry Flag in SREGH←1H
CLHClear Half Carry Flag in SREGH←0H
Table 35-5. MCU Control Instructions
MnemonicOperandsDescriptionOperationFlags
BREAKBreak(See also in Debug interface description)None
NOPNo OperationNone
SLEEPSleep(see also power management and sleep description)None
WDRWatchdog Reset(see also Watchdog Controller description)None
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.