7.2 AVR Instruction Set Summary

Table 7-2. AVR Instruction Set Summary
MnemonicsOperandsDescriptionOperationFlags#Clocks
Arithmetic and Logic Instructions
ADDRd, RrAdd two RegistersRd <-- Rd + RrZ,C,N,V,H1
ADCRd, RrAdd with Carry two RegistersRd <-- Rd + Rr + CZ,C,N,V,H1
ADIWRdl,KAdd Immediate to WordRdh:Rdl <-- Rdh:Rdl + KZ,C,N,V,S2
SUBRd, RrSubtract two RegistersRd <-- Rd - RrZ,C,N,V,H1
SUBIRd, KSubtract Constant from RegisterRd <-- Rd - KZ,C,N,V,H1
SBCRd, RrSubtract with Carry two RegistersRd <-- Rd - Rr - CZ,C,N,V,H1
SBCIRd, KSubtract with Carry Constant from Reg.Rd <-- Rd - K - CZ,C,N,V,H1
SBIWRdl,KSubtract Immediate from WordRdh:Rdl <-- Rdh:Rdl - KZ,C,N,V,S2
ANDRd, RrLogical AND RegistersRd <-- Rd x RrZ,N,V1
ANDIRd, KLogical AND Register and ConstantRd <-- Rd x KZ,N,V1
ORRd, RrLogical OR RegistersRd <-- Rd v RrZ,N,V1
ORIRd, KLogical OR Register and ConstantRd <-- Rd v KZ,N,V1
EORRd, RrExclusive OR RegistersRd _ Rd _ RrZ,N,V1
COMRdOne’s ComplementRd _ 0xFF - RdZ,C,N,V1
NEGRdTwo’s ComplementRd _ 0x00 - RdZ,C,N,V,H1
SBRRd,KSet Bit(s) in RegisterRd _ Rd v KZ,N,V1
CBRRd,KClear Bit(s) in RegisterRd _ Rd x (0xFF - K)Z,N,V1
INCRdIncrementRd _ Rd + 1Z,N,V1
DECRdDecrementRd _ Rd - 1Z,N,V1
TSTRdTest for Zero or MinusRd _ Rd x RdZ,N,V1
CLRRdClear RegisterRd _ Rd _ RdZ,N,V1
SERRdSet RegisterRd _ 0xFFNone1
MULRd, RrMultiply UnsignedR1:R0 _ Rd x RrZ,C2
MULSRd, RrMultiply SignedR1:R0 _ Rd x RrZ,C2
MULSURd, RrMultiply Signed with UnsignedR1:R0 _ Rd x RrZ,C2
FMULRd, RrFractional Multiply UnsignedR1:R0 _ (Rd x Rr) << 1Z,C2
FMULSRd, RrFractional Multiply SignedR1:R0 _ (Rd x Rr) << 1Z,C2
FMULSURd, RrFractional Multiply Signed with UnsignedR1:R0 _ (Rd x Rr) << 1Z,C2
Branch Instructions
RJMPkRelative JumpPC _ PC + k + 1None2
IJMPIndirect Jump to (Z)PC _ ZNone2
JMPkDirect JumpPC _ kNone3
RCALLkRelative Subroutine CallPC _ PC + k + 1None3
ICALLIndirect Call to (Z)PC _ ZNone3
CALLkDirect Subroutine CallPC _ kNone4
RETSubroutine ReturnPC _ STACKNone4
RETIInterrupt ReturnPC _ STACKI4
CPSERd,RrCompare, Skip if Equalif (Rd = Rr) PC _ PC + 2 or 3None1/2/3
CPRd, RrCompareRd - RrZ, N,V,C,H1
CPCRd, RrCompare with CarryRd - Rr - CZ, N,V,C,H1
CPIRd, KCompare Register with ImmediateRd - KZ, N,V,C,H1
SBRCRr, bSkip if Bit in Register Clearedif (Rr(b)=0) PC _ PC + 2 or 3None1/2/3
SBRSRr, bSkip if Bit in Register is Setif (Rr(b)=1) PC _ PC + 2 or 3None1/2/3
SBICP, bSkip if Bit in I/O Register Clearedif (P(b)=0) PC _ PC + 2 or 3None1/2/3
SBISP, bSkip if Bit in I/O Register is Setif (P(b)=1) PC _ PC + 2 or 3None1/2/3
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
BREQkBranch if Equalif (Z = 1) then PC _ PC + k + 1None1/2
BRNEkBranch if Not Equalif (Z = 0) then PC _ PC + k + 1None1/2
BRCSkBranch if Carry Setif (C = 1) then PC _ PC + k + 1None1/2
BRCCkBranch if Carry Clearedif (C = 0) then PC _ PC + k + 1None1/2
BRSHkBranch if Same or Higherif (C = 0) then PC _ PC + k + 1None1/2
BRLOkBranch if Lowerif (C = 1) then PC _ PC + k + 1None1/2
BRMIkBranch if Minusif (N = 1) then PC _ PC + k + 1None1/2
BRPLkBranch if Plusif (N = 0) then PC _ PC + k + 1None1/2
BRGEkBranch if Greater or Equal, Signedif (N _ V= 0) then PC _ PC + k + 1None1/2
BRLTkBranch if Less Than Zero, Signedif (N _ V= 1) then PC _ PC + k + 1None1/2
BRHSkBranch if Half Carry Flag Setif (H = 1) then PC _ PC + k + 1None1/2
BRHCkBranch if Half Carry Flag Clearedif (H = 0) then PC _ PC + k + 1None1/2
BRTSkBranch if T Flag Setif (T = 1) then PC _ PC + k + 1None1/2
BRTCkBranch if T Flag Clearedif (T = 0) then PC _ PC + k + 1None1/2
BRVSkBranch if Overflow Flag is Setif (V = 1) then PC _ PC + k + 1None1/2
BRVCkBranch if Overflow Flag is Clearedif (V = 0) then PC _ PC + k + 1None1/2
BRIEkBranch if Interrupt Enabledif (I = 1) then PC _ PC + k + 1None1/2
BRIDkBranch if Interrupt Disabledif (I = 0) then PC _ PC + k + 1None1/2
Bit and Bit-test Instructions
SBIP, bSet Bit in I/O RegisterI/O(P,b) _ 1None2
CBIP, bClear Bit in I/O RegisterI/O(P,b) _ 0None2
LSLRdLogical Shift LeftRd(n+1) _ Rd(n), Rd(0) _ 0Z,C,N,V1
LSRRdLogical Shift RightRd(n) _ Rd(n+1), Rd(7) _ 0Z,C,N,V1
ROLRdRotate Left Through CarryRd(0)_C,Rd(n+1)_ Rd(n),C_Rd(7)Z,C,N,V1
RORRdRotate Right Through CarryRd(7)_C,Rd(n)_ Rd(n+1),C_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),Rd(7..4)_Rd(3..0)None1
BSETsFlag SetSREG(s) _ 1SREG(s)1
BCLRsFlag ClearSREG(s) _ 0SREG(s)1
BSTRr, bBit Store from Register to TT _ Rr(b)T1
BLDRd, bBit load from T to RegisterRd(b) _ TNone1
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 Complement Overflow.V _ 1V1
CLVClear Two 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
Data Transfer Instructions
MOVRd, RrMove Between RegistersRd _ RrNone1
MOVWRd, RrCopy Register WordRd+1:Rd _ Rr+1:RrNone1
LDIRd, KLoad ImmediateRd _ KNone1
LDRd, XLoad IndirectRd _ (X)None2
LDRd, X+Load Indirect and Post-Inc.Rd _ (X), X _ X + 1None2
LDRd, - XLoad Indirect and Pre-Dec.X _ X - 1, Rd _ (X)None2
LDRd, YLoad IndirectRd _ (Y)None2
LDRd, Y+Load Indirect and Post-Inc.Rd _ (Y), Y _ Y + 1None2
LDRd, - YLoad Indirect and Pre-Dec.Y _ Y - 1, Rd _ (Y)None2
LDDRd,Y+qLoad Indirect with DisplacementRd _ (Y + q)None2
LDRd, ZLoad IndirectRd _ (Z)None2
LDRd, Z+Load Indirect and Post-Inc.Rd _ (Z), Z _ Z+1None2
LDRd, -ZLoad Indirect and Pre-Dec.Z _ Z - 1, Rd _ (Z)None2
LDDRd, Z+qLoad Indirect with DisplacementRd _ (Z + q)None2
LDSRd, kLoad Direct from SRAMRd _ (k)None2
STX, RrStore Indirect(X) _ RrNone2
STX+, RrStore Indirect and Post-Inc.(X) _ Rr, X _ X + 1None2
ST- X, RrStore Indirect and Pre-Dec.X _ X - 1, (X) _ RrNone2
STY, RrStore Indirect(Y) _ RrNone2
STY+, RrStore Indirect and Post-Inc.(Y) _ Rr, Y _ Y + 1None2
ST- Y, RrStore Indirect and Pre-Dec.Y _ Y - 1, (Y) _ RrNone2
STDY+q,RrStore Indirect with Displacement(Y + q) _ RrNone2
STZ, RrStore Indirect(Z) _ RrNone2
STZ+, RrStore Indirect and Post-Inc.(Z) _ Rr, Z _ Z + 1None2
ST-Z, RrStore Indirect and Pre-Dec.Z _ Z - 1, (Z) _ RrNone2
STDZ+q,RrStore Indirect with Displacement(Z + q) _ RrNone2
STSk, RrStore Direct to SRAM(k) _ RrNone2
LPMLoad Program MemoryR0 _ (Z)None3
LPMRd, ZLoad Program MemoryRd _ (Z)None3
LPMRd, Z+Load Program Memory and Post-IncRd _ (Z), Z _ Z+1None3
SPMStore Program Memory(Z) _ R1:R0None-
INRd, PIn PortRd _ PNone1
OUTP, RrOut PortP _ RrNone1
PUSHRrPush Register on StackSTACK _ RrNone2
POPRdPop Register from StackRd _ STACKNone2
MCU Control Instructions
NOPNo OperationNone1
SLEEPSleep(see specific description for Sleep function)None1
WDRWatchdog Reset(see specific description for WDR/timer)None1
BREAKBreakFor On-chip Debug OnlyNoneN/A