AVR单片机汇编指令合集-
- 格式:pdf
- 大小:341.22 KB
- 文档页数:9
Instructionmnemonics
TheAssembleracceptsmnemonicinstructionsfromtheinstructionset.Asummaryoftheinstructionsetmnemonicsandtheirparametersisgivenhere.ForadetaileddescriptionoftheInstructionset,refertotheAVRDataBook.
ArithmeticandLogicInstructionsMnemonicOperandsDescriptionOperationFlagsCyclesADD聽Rd,Rr聽AddwithoutCarry聽Rd=Rd+Rr聽Z,C,N,V,H,S聽1
ADCRd,RrAddwithCarryRd=Rd+Rr+CZ,C,N,V,H,S1
ADIWRd,KAddImmediateToWordRd+1:Rd,KZ,C,N,V,S2
SUBRd,RrSubtractwithoutCarryRd=Rd-RrZ,C,N,V,H,S1SUBIRd,K8SubtractImmediateRd=Rd-K8Z,C,N,V,H,S1
SBCRd,RrSubtractwithCarryRd=Rd-Rr-CZ,C,N,V,H,S1
SBCIRd,K8SubtractwithCarryImmedtiateRd=Rd-K8-CZ,C,N,V,H,S1
ANDRd,RrLogicalANDRd=Rd路RrZ,N,V,S聽1
ANDIRd,K8LogicalANDwithImmediateRd=Rd路K8Z,N,V,S1
ORRd,RrLogicalORRd=RdVRrZ,N,V,S1
ORIRd,K8LogicalORwithImmediateRd=RdVK8Z,N,V,S1
EORRd,RrLogicalExclusiveORRd=RdEORRrZ,N,V,S1
COMRdOne'sComplementRd=$FF-RdZ,C,N,V,S1NEGRdTwo'sComplementRd=$00-RdZ,C,N,V,H,S1SBRRd,K8SetBit(s)inRegisterRd=RdVK8Z,C,N,V,S1CBRRd,K8ClearBit(s)inRegisterRd=Rd路($FF-K8)Z,C,N,V,S1
INCRdIncrementRegisterRd=Rd+1Z,N,V,S1DECRdDecrementRegisterRd=Rd-1Z,N,V,S1
TSTRdTestforZeroorNegativeRd=Rd路RdZ,C,N,V,S1
CLRRdClearRegisterRd=0Z,N,V,S1SERRdSetRegisterRd=$FFNone1
SBIWRdl,K6SubtractImmediatefromWordRdh:Rdl=Rdh:Rdl-K6Z,C,N,V,S2
MULRd,RrMultiplyUnsignedR1:R0=Rd*RrZ,C2
MULSRd,RrMultiplySignedR1:R0=Rd*RrZ,C2
MULSURd,RrMultiplySignedwithUnsignedR1:R0=Rd*RrZ,C2
FMULRd,RrFractionalMultiplyUnsignedR1:R0=(Rd*Rr)<<1Z,C2
FMULSRd,RrFractionalMultiplySignedR1:R0=(Rd*Rr)<<1Z,C2
FMULSURd,RrFractionalMultiplySignedwithUnsignedR1:R0=(Rd*Rr)<<1Z,C2
聽
BranchInstructions
MnemonicOperandsDescriptionOperationFlagsCyclesRJMPkRelativeJumpPC=PC+k+1None2
IJMPNoneIndirectJumpto(Z)PC=ZNone2
EIJMPNoneExtendedIndirectJump(Z)STACK=PC+1,PC(15:0)=Z,PC(21:16)=EINDNone2JMPkJump聽PC=kNone3
RCALLkRelativeCallSubroutineSTACK=PC+1,PC=PC+k+1None3/4*
ICALLNoneIndirectCallto(Z)STACK=PC+1,PC=Z聽None3/4*
EICALLNoneExtendedIndirectCallto(Z)STACK=PC+1,PC(15:0)=Z,PC(21:16)=EINDNone4*
CALLkCallSubroutineSTACK=PC+2,PC=kNone4/5*
RETNoneSubroutineReturnPC=STACKNone4/5*
RETINoneInterruptReturnPC=STACKI4/5*
CPSERd,RrCompare,Skipifequal聽if(Rd==Rr)PC=PC2or3None1/2/3
CPRd,RrCompareRd-RrZ,C,N,V,H,S1
CPCRd,RrComparewithCarryRd-Rr-CZ,C,N,V,H,S1
CPIRd,K8ComparewithImmediateRd-KZ,C,N,V,H,S1
SBRCRr,bSkipifbitinregisterclearedif(Rr(b)==0)PC=PC+2or3None1/2/3
SBRSRr,bSkipifbitinregistersetif(Rr(b)==1)PC=PC+2or3None1/2/3
SBICP,bSkipifbitinI/Oregisterclearedif(I/O(P,b)==0)PC=PC+2or3None1/2/3
SBISP,bSkipifbitinI/Oregistersetif(I/O(P,b)==1)PC=PC+2or3None1/2/3
BRBCs,kBranchifStatusflagclearedif(SREG(s)==0)PC=PC+k+1None1/2
BRBSs,kBranchifStatusflagsetif(SREG(s)==1)PC=PC+k+1None1/2BREQkBranchifequalif(Z==1)PC=PC+k+1None1/2
BRNEkBranchifnotequalif(Z==0)PC=PC+k+1None1/2
BRCSkBranchifcarrysetif(C==1)PC=PC+k+1None1/2
BRCCkBranchifcarryclearedif(C==0)PC=PC+k+1None1/2
BRSHkBranchifsameorhigherif(C==0)PC=PC+k+1None1/2
BRLOkBranchiflowerif(C==1)PC=PC+k+1None1/2
BRMIkBranchifminusif(N==1)PC=PC+k+1None1/2
BRPLkBranchifplusif(N==0)PC=PC+k+1None1/2
BRGEkBranchifgreaterthanorequal(signed)if(S==0)PC=PC+k+1None1/2
BRLTkBranchiflessthan(signed)if(S==1)PC=PC+k+1None1/2
BRHSkBranchifhalfcarryflagsetif(H==1)PC=PC+k+1None1/2
BRHCkBranchifhalfcarryflagclearedif(H==0)PC=PC+k+1None1/2
BRTSkBranchifTflagsetif(T==1)PC=PC+k+1None1/2
BRTCkBranchifTflagclearedif(T==0)PC=PC+k+1None1/2
BRVSkBranchifoverflowflagsetif(V==1)PC=PC+k+1None1/2
BRVCkBranchifoverflowflagclearedif(V==0)PC=PC+k+1None1/2
BRIEkBranchifinterruptif(I==1)PC=PC+k+None1/2enabled1
BRIDkBranchifinterruptdisabledif(I==0)PC=PC+k+1None1/2*Cycletimesfordatamemoryaccessesassumeinternalmemoryaccesses,andarenotvalidforaccessesthroughtheexternalRAMinterface.FortheinstructionsCALL,ICALL,EICALL,RCALL,RETandRETI,addthreecyclesplustwocyclesforeachwaitstateindeviceswithupto16bitPC(128KBprogrammemory).Fordeviceswithmorethan128KBprogrammemory,addfivecyclesplusthreecyclesforeachwaitstate.
DataTransferInstructionsMnemonicOperandsDescriptionOperationFlagsCyclesMOVRd,RrCopyregisterRd=RrNone1
MOVWRd,RrCopyregisterpairRd+1:Rd=Rr+1:Rr,r,devenNone1
LDIRd,K8LoadImmediateRd=KNone1LDSRd,kLoadDirectRd=(k)None2*LDRd,XLoadIndirectRd=(X)None2*
LDRd,X+LoadIndirectandPost-IncrementRd=(X),X=X+1None2*
LDRd,-XLoadIndirectandPre-DecrementX=X-1,Rd=(X)None2*
LDRd,YLoadIndirectRd=(Y)None2*
LDRd,Y+LoadIndirectandPost-IncrementRd=(Y),Y=Y+1None2*
LDRd,-YLoadIndirectandPre-DecrementY=Y-1,Rd=(Y)None2*
LDDRd,Y+qLoadIndirectwithdisplacementRd=(Y+q)None2*
LDRd,ZLoadIndirect聽Rd=(Z)None2*
LDRd,Z+LoadIndirectandPost-IncrementRd=(Z),Z=Z+1None2*
LDRd,-ZLoadIndirectandZ=Z-1,Rd=(Z)None2*