Top > AVR > InstructionSet

AVR Instruction Set *

Instruction Set *

Arithmetic and Logic Instructions *

MnemonicOperandsDescriptionOperationFlagsCycles
ADDRd, Rr Add without Carry Rd ← Rd + Rr Z,C,N,V,H,S 1
ADCRd, RrAdd with CarryRd ← Rd + Rr + CZ,C,N,V,H,S1
ADIWRdl, K6Add Immediate To WordRdh:Rdl ← Rdh:Rdl + K6Z,C,N,V,S2
SUBRd, RrSubtract without CarryRd ← Rd - RrZ,C,N,V,H,S1
SUBIRd, K8Subtract ImmediateRd ← Rd - K8Z,C,N,V,H,S1
SBCRd, RrSubtract with CarryRd ← Rd - Rr - CZ,C,N,V,H,S1
SBCIRd, K8Subtract with Carry ImmedtiateRd ← Rd - K8 - CZ,C,N,V,H,S1
SBIWRdl, K6Subtract Immediate from WordRdh:Rdl ← Rdh:Rdl - K6Z,C,N,V,S2
ANDRd, RrLogical ANDRd ← Rd ∧ RrZ,N,V,S 1
ANDIRd, K8Logical AND with ImmediateRd ← Rd ∧ K8Z,N,V,S1
ORRd, RrLogical ORRd ← Rd ∨ RrZ,N,V,S1
ORIRd, K8Logical OR with ImmediateRd ← Rd ∨ K8Z,N,V,S1
EORRd, RrLogical Exclusive ORRd ← Rd ⊕ RrZ,N,V,S1
COMRdOne's ComplementRd ← $FF - RdZ,C,N,V,S1
NEGRdTwo's ComplementRd ← $00 - RdZ,C,N,V,H,S1
SBRRd, K8Set Bit(s) in RegisterRd ← Rd ∨ K8Z,C,N,V,S1
CBRRd, K8Clear Bit(s) in RegisterRd ← Rd ∧ ($FF - K8)Z,C,N,V,S1
INCRdIncrement RegisterRd ← Rd + 1Z,N,V,S1
DECRdDecrement RegisterRd ← Rd - 1Z,N,V,S1
TSTRdTest for Zero or NegativeRd ← Rd ∧ RdZ,C,N,V,S1
CLRRdClear RegisterRd ← 0Z,C,N,V,S1
SERRdSet RegisterRd ← $FF1
MULRd, RrMultiply UnsignedR1:R0 ← Rd × RrZ,C2
MULSRd, RrMultiply SignedR1:R0 ← Rd × RrZ,C2
MULSURd, RrMultiply Signed with UnsignedR1:R0 ← Rd × RrZ,C2
FMULRd, RrFractional Multiply UnsignedR1:R0 ← (Rd × Rr) << 1Z,C2
FMULSRd, RrFractional Multiply SignedR1:R0 ← (Rd × Rr) << 1Z,C2
FMULSURd, RrFractional Multiply Signed with UnsignedR1:R0 ← (Rd × Rr) << 1Z,C2

Branch Instructions *

MnemonicOperandsDescriptionOperationFlagsCycles
RJMPkRelative JumpPC ← PC + k + 12
IJMPIndirect Jump to (Z)PC ← Z2
EIJMPExtended Indirect Jump (Z)PC(15:0) ← Z
PC(21:16) ← EIND
2
JMPkJump PC ← k3
RCALLkRelative Call SubroutineSTACK ← PC + 1
PC ← PC + k + 1
3/4
ICALLIndirect Call to (Z)STACK ← PC + 1
PC ← Z
3/4
EICALLExtended Indirect Call (Z)STACK ← PC + 1
PC(15:0) ← Z
PC(21:16) ← EIND
4
CALLkCall SubroutineSTACK ← PC+2
PC ← k
4/5
RETSubroutine ReturnPC ← STACK4/5
RETIInterrupt ReturnPC ← STACKI4/5
CPSERd, RrCompare, Skip if equal if (Rd == Rr) PC ← PC + 2 or 32/3
CPRd, RrCompareRd - RrZ,C,N,V,H,S1
CPCRd, RrCompare with CarryRd - Rr - CZ,C,N,V,H,S1
CPIRd, K8Compare with ImmediateRd - KZ,C,N,V,H,S1
SBRCRr, bSkip if bit in register clearedif (Rr(b) = 0) PC ← PC + 2 or 32/3
SBRSRr, bSkip if bit in register setif (Rr(b) = 1) PC ← PC + 2 or 32/3
SBICP, bSkip if bit in I/O register clearedif (I/O(P,b) = 0) PC ← PC + 2 or 32/3
SBISP, bSkip if bit in I/O register setif (I/O(P,b) = 1) PC ← PC + 2 or 32/3
BRBCs, kBranch if Status flag clearedif (SREG(s) = 0) PC ← PC + k + 11/2
BRBSs, kBranch if Status flag setif (SREG(s) = 1) PC ← PC + k + 11/2
BREQkBranch if equalif (Z = 1) PC ← PC + k + 11/2
BRNEkBranch if not equalif (Z = 0) PC ← PC + k + 11/2
BRCSkBranch if carry setif (C = 1) PC ← PC + k + 11/2
BRCCkBranch if carry clearedif (C = 0) PC ← PC + k + 11/2
BRSHkBranch if same or higherif (C = 0) PC ← PC + k + 11/2
BRLOkBranch if lowerif (C = 1) PC ← PC + k + 11/2
BRMIkBranch if minusif (N = 1) PC ← PC + k + 11/2
BRPLkBranch if plusif (N = 0) PC ← PC + k + 11/2
BRGEkBranch if greater than or equal (signed)if (S = 0) PC ← PC + k + 11/2
BRLTkBranch if less than (signed)if (S = 1) PC ← PC + k + 11/2
BRHSkBranch if half carry flag setif (H = 1) PC ← PC + k + 11/2
BRHCkBranch if half carry flag clearedif (H = 0) PC ← PC + k + 11/2
BRTSkBranch if T flag setif (T = 1) PC ← PC + k + 11/2
BRTCkBranch if T flag clearedif (T = 0) PC ← PC + k + 11/2
BRVSkBranch if overflow flag setif (V = 1) PC ← PC + k + 11/2
BRVCkBranch if overflow flag clearedif (V = 0) PC ← PC + k + 11/2
BRIEkBranch if interrupt enabledif (I = 1) PC ← PC + k + 11/2
BRIDkBranch if interrupt disabledif (I = 0) PC ← PC + k + 11/2

Data Transfer Instructions *

MnemonicOperandsDescriptionOperationFlagsCycles
MOVRd, RrCopy registerRd ← Rr1
MOVWRdl, RrlCopy register pairRdh:Rdl ← Rrh:Rrl
※dl, rl even
1
LDIRd, K8Load ImmediateRd ← K1
LDSRd, kLoad DirectRd ← (k)2
LDRd, XLoad IndirectRd ← (X)2
LDRd, X+Load Indirect and Post-IncrementRd ← (X)
X ← X + 1
2
LDRd, -XLoad Indirect and Pre-DecrementX ← X - 1
Rd ← (X)
2
LDRd, YLoad IndirectRd ← (Y)2
LDRd, Y+Load Indirect and Post-IncrementRd ← (Y)
Y ← Y + 1
2
LDRd, -YLoad Indirect and Pre-DecrementY ← Y - 1
Rd ← (Y)
2
LDDRd, Y+qLoad Indirect with displacementRd ← (Y + q)2
LDRd, ZLoad Indirect Rd ← (Z)2
LDRd, Z+Load Indirect and Post-IncrementRd ← (Z)
Z ← Z + 1
2
LDRd, -ZLoad Indirect and Pre-DecrementZ ← Z - 1
Rd ← (Z)
2
LDDRd, Z+qLoad Indirect with displacementRd ← (Z + q)2
STSk, RrStore Direct(k) ← Rr2
STX, RrStore Indirect(X) ← Rr2
STX+, RrStore Indirect and Post-Increment(X) ← Rr
X ← X + 1
2
ST-X, RrStore Indirect and Pre-DecrementX ← X - 1
(X) ← Rr
2
STY, RrStore Indirect(Y) ← Rr2
STY+, RrStore Indirect and Post-Increment(Y) ← Rr
Y ← Y + 1
2
ST-Y, RrStore Indirect and Pre-DecrementY ← Y - 1
(Y) ← Rr
2
STDY+q, RrStore Indirect with displacement(Y + q) ← Rr2
STZ, RrStore Indirect(Z) ← Rr2
STZ+, RrStore Indirect and Post-Increment(Z) ← Rr
Z ← Z + 1
2
ST-Z, RrStore Indirect and Pre-DecrementZ ← Z - 1
(Z) ← Rr
2
STDZ+q, RrStore Indirect with displacement(Z + q) ← Rr2
LPMLoad Program MemoryR0 ← (Z)3
LPMRd, ZLoad Program MemoryRd ← (Z)3
LPMRd, Z+Load Program Memory and Post-IncrementRd ← (Z)
Z ← Z + 1
3
ELPMExtended Load Program MemoryR0 ← (RAMPZ:Z)3
ELPMRd, ZExtended Load Program MemoryRd ← (RAMPZ:Z)3
ELPMRd, Z+Extended Load Program Memory and Post-IncrementRd ← (RAMPZ:Z)
Z ← Z + 1
3
SPMStore Program Memory(Z) ← R1:R0-
INRd, PIn PortRd ← P1
OUTP, RrOut PortP ← Rr1
PUSHRrPush register on StackSTACK ← Rr2
POPRdPop register from StackRd ← STACK2

Bit and Bit-test Instructions *

MnemonicOperandsDescriptionOperationFlagsCycles
LSLRdLogical shift leftC ← Rd(7)
Rd(7..1) ← Rd(6..0)
Rd(0) ← 0
Z,C,N,V,H,S1
LSRRdLogical shift rightC ← Rd(0)
Rd(6..0) ← Rd(7..1)
Rd(7) ← 0
Z,C,N,V,S1
ROLRdRotate left through carryC ← Rd(7)
Rd(7..1) ← Rd(6..0)
Rd(0) ← C
Z,C,N,V,H,S1
RORRdRotate right through carryC ← Rd(0)
Rd(6..0) ← Rd(7..1)
Rd(7) ← C
Z,C,N,V,S1
ASRRdArithmetic shift rightC ← Rd(0)
Rd(6..0) ← Rd(7..1)
Z,C,N,V,S1
SWAPRdSwap nibblesRd(3..0) ← Rd(7..4)
Rd(7..4) ← Rd(3..0)
1
BSETsSet flagSREG(s) ← 1SREG(s)1
BCLRsClear flagSREG(s) ← 0SREG(s)1
SBIP, bSet bit in I/O registerI/O(P,b) ← 12
CBIP, bClear bit in I/O registerI/O(P,b) ← 02
BSTRr, bBit store from register to TT ← Rr(b)T1
BLDRd, bBit load from register to TRd(b) ← T1
SECSet carry flagC ←1C1
CLCClear carry flagC ← 0C1
SENSet negative flagN ← 1N1
CLNClear negative flagN ← 0N1
SEZSet zero flagZ ← 1Z1
CLZClear zero flagZ ← 0Z1
SEISet interrupt flagI ← 1I1
CLIClear interrupt flagI ← 0I1
SESSet signed flagS ← 1S1
CLSClear signed flagS ← 0S1
SEVSet overflow flagV ← 1V1
CLVClear overflow flagV ← 0V1
SETSet T-flagT ← 1T1
CLTClear T-flagT ← 0T1
SEHSet half carry flagH ← 1H1
CLHClear half carry flagH ← 0H1

MCU Control Instructions *

MnemonicOperandsDescriptionOperationFlagsCycles
NOPNo operation1
SLEEPSleepSee instruction manual1
WDRWatchdog ResetSee instruction manual1
BREAKExecution BreakSee instruction manual1

MPU Instructions *

MnemonicOperandsAT90S1200ATtiny11/12
ATtiny15
ATtiny28
AT90S2323/2343
AT90S4414/8515
AT90S4434/8535
ATtiny22
ATtiny26ATmega103ATtiny13
ATtiny2313
ATtiny25/45/85
ATtiny24/44/84
ATtiny261/461/861
ATmega8
ATmega48/88/168
ATmega8515
ATmega8535
AT90PWM2/3
ATmega16/32
ATmega406
ATmega161
ATmega163/323
ATmega169/165/329/325/3250/649/645
ATmega162
ATmega64/644/640
AT90CAN32/64
ATmega128/1280/1281
AT90CAN128
ATmega2560/2561
ADDRd, Rr 
ADCRd, Rr
ADIWRdl, K6
SUBRd, Rr
SUBIRd, K8
SBCRd, Rr
SBCIRd, K8
SBIWRdl, K6
ANDRd, Rr
ANDIRd, K8
ORRd, Rr
ORIRd, K8
EORRd, Rr
COMRd
NEGRd
SBRRd, K8
CBRRd, K8
INCRd
DECRd
TSTRd
CLRRd
SERRd
MULRd, Rr
MULSRd, Rr
MULSURd, Rr
FMULRd, Rr
FMULSRd, Rr
FMULSURd, Rr
RJMPk
IJMP
EIJMP
JMPk
RCALLk
ICALL
EICALL
CALLk
RET
RETI
CPSERd, Rr
CPRd, Rr
CPCRd, Rr
CPIRd, K8
SBRCRr, b
SBRSRr, b
SBICP, b
SBISP, b
BRBCs, k
BRBSs, k
BREQk
BRNEk
BRCSk
BRCCk
BRSHk
BRLOk
BRMIk
BRPLk
BRGEk
BRLTk
BRHSk
BRHCk
BRTSk
BRTCk
BRVSk
BRVCk
BRIEk
BRIDk
MOVRd, Rr
MOVWRdl, Rrl
LDIRd, K8
LDSRd, k
LDRd, X
LDRd, X+
LDRd, -X
LDRd, Y
LDRd, Y+
LDRd, -Y
LDDRd, Y+q
LDRd, Z
LDRd, Z+
LDRd, -Z
LDDRd, Z+q
STSk, Rr
STX, Rr
STX+, Rr
ST-X, Rr
STY, Rr
STY+, Rr
ST-Y, Rr
STDY+q, Rr
STZ, Rr
STZ+, Rr
ST-Z, Rr
STDZ+q, Rr
LPM
LPMRd, Z
LPMRd, Z+
ELPM
ELPMRd, Z
ELPMRd, Z+
SPM
INRd, P
OUTP, Rr
PUSHRr
POPRd
LSLRd
LSRRd
ROLRd
RORRd
ASRRd
SWAPRd
BSETs
BCLRs
SBIP, b
CBIP, b
BSTRr, b
BLDRd, b
SEC
CLC
SEN
CLN
SEZ
CLZ
SEI
CLI
SES
CLS
SEV
CLV
SET
CLT
SEH
CLH
NOP
SLEEP
WDR
BREAK

Instruction Set Nomenclature *

Status Register (SREG) *

  • SREG : Status register
  • C : Carry flag in status register
  • Z : Zero flag in status register
  • N : Negative flag in status register
  • V : Two's complement overflow indicator
  • S : N [+] V, For signed tests
  • H : Half Carry flag in the status register
  • T : Transfer bit used by BLD and BST instructions
  • I : Global interrupt enable/disable flag

Registers and Operands *

  • Rd : Destination (and source) register in the register file
  • Rr : Source register in the register file
  • R : Result after instruction is executed
  • K : Constant data (K8 = 8 bit, K6 = 6 bit)
  • k : Constant address
  • b : Bit in the register file or I/O register (3 bit)
  • s: Bit in the status register (3 bit)
  • X, Y, Z : Indirect address register (X = R27:R26, Y = R29:R28, Z = R31:R30)
  • A : I/O location address
  • q : Displacement for direct addressing (6 bit)

参照・引用ページ *


コメントはありません。 コメント/AVR/InstructionSet?

お名前: