Professional Documents
Culture Documents
8051InstructionSet
8051InstructionSet
Instructionsbyopcode
0x00 0x01 0x02
0x00 NOP AJMP LJMP
ACALL LCALL
0x10 JBC
AJMP RET
0x20 JB
0x30
0x40
0x50
0x60
0x70
0x80
0x90
0xa0
0xb0
0xc0
0xd0
0xe0
0xf0
0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x0a 0x0b 0x0c 0x0d 0x0e 0x0f
RR
INC
INC
INC
INC
INC
INC
INC
INC
INC
INC
INC
INC
RRC
DEC
DEC
DEC
DEC
DEC
DEC
DEC
DEC
DEC
DEC
DEC
DEC
RL
ADD
ADD
ADD
ADD
ADD
ADD
ADD
ADD
ADD
ADD
ADD
ADD
JNB
ACALL RETI
RLC
ADDC ADDC ADDC ADDC ADDC ADDC ADDC ADDC ADDC ADDC ADDC ADDC
JC
AJMP
ORL
ORL
ORL
ORL
ORL
ORL
ORL
ORL
ORL
ORL
ORL
ORL
ORL
ORL
JNC
ACALL ANL
ANL
ANL
ANL
ANL
ANL
ANL
ANL
ANL
ANL
ANL
ANL
ANL
ANL
JZ
AJMP
XRL
XRL
XRL
XRL
XRL
XRL
XRL
XRL
XRL
XRL
XRL
XRL
XRL
XRL
JNZ
ACALL ORL
JMP
MOV
MOV
MOV
MOV
MOV
MOV
MOV
MOV
MOV
MOV
MOV
MOV
SJMP
AJMP
MOVC DIV
MOV
MOV
MOV
MOV
MOV
MOV
MOV
MOV
MOV
MOV
MOV
MOV
ACALL MOV
MOVC SUBB SUBB SUBB SUBB SUBB SUBB SUBB SUBB SUBB SUBB SUBB SUBB
ORL
AJMP
INC
MUL
ANL
ACALL CPL
CPL
CJNE CJNE CJNE CJNE CJNE CJNE CJNE CJNE CJNE CJNE CJNE CJNE
PUSH
AJMP
CLR
SWAP XCH
POP
ACALL SETB
SETB
DA
MOVX AJMP
ANL
MOV
CLR
MOV
XCH
MOV
XCH
MOV
XCH
MOV
XCH
MOV
XCH
MOV
XCH
MOV
XCH
MOV
XCH
MOV
XCH
MOV
XCH
DJNZ XCHD XCHD DJNZ DJNZ DJNZ DJNZ DJNZ DJNZ DJNZ DJNZ
MOV
MOV
MOV
MOV
MOV
MOV
MOV
MOV
MOV
MOV
MOV
MOV
MOV
MOV
MOV
MOV
MOV
MOV
MOV
MOV
MOV
MOV
AlphabeticalListofInstructions
ACALLAbsoluteCall
ADD,ADDCAddAccumulator(WithCarry)
AJMPAbsoluteJump
ANLBitwiseAND
CJNECompareandJumpifNotEqual
CLRClearRegister
CPLComplementRegister
DADecimalAdjust
DECDecrementRegister
DIVDivideAccumulatorbyB
DJNZDecrementRegisterandJumpifNotZero
INCIncrementRegister
JBJumpifBitSet
JBCJumpifBitSetandClearBit
JCJumpifCarrySet
JMPJumptoAddress
JNBJumpifBitNotSet
JNCJumpifCarryNotSet
JNZJumpifAccumulatorNotZero
JZJumpifAccumulatorZero
LCALLLongCall
LJMPLongJump
MOVMoveMemory
MOVCMoveCodeMemory
MOVXMoveExtendedMemory
MULMultiplyAccumulatorbyB
NOPNoOperation
ORLBitwiseOR
POPPopValueFromStack
PUSHPushValueOntoStack
RETReturnFromSubroutine
RETIReturnFromInterrupt
file:///C:/Users/Osmair/Downloads/8051%20Instruction%20Set.html
1/21
06/10/2016
8051InstructionSet
RLRotateAccumulatorLeft
RLCRotateAccumulatorLeftThroughCarry
RRRotateAccumulatorRight
RRCRotateAccumulatorRightThroughCarry
SETBSetBit
SJMPShortJump
SUBBSubtractFromAccumulatorWithBorrow
SWAPSwapAccumulatorNibbles
XCHExchangeBytes
XCHDExchangeDigits
XRLBitwiseExclusiveOR
UndefinedUndefinedInstruction
8051InstructionSet:ACALL
Operation: ACALL
Function: AbsoluteCallWithin2KBlock
Syntax:
ACALLcodeaddress
Instructions
ACALLpage0
0x11
None
ACALLpage1
0x31
None
ACALLpage2
0x51
None
ACALLpage3
0x71
None
ACALLpage4
0x91
None
ACALLpage5
0xB1
None
ACALLpage6
0xD1
None
ACALLpage7
0xF1
None
Description:ACALLunconditionallycallsasubroutineattheindicatedcodeaddress.ACALLpushestheaddressof
theinstructionthatfollowsACALLontothestack,leastsignificantbytefirst,mostsignificantbytesecond.The
ProgramCounteristhenupdatedsothatprogramexecutioncontinuesattheindicatedaddress.
ThenewvaluefortheProgramCounteriscalculatedbyreplacingtheleastsignificantbyteoftheProgramCounter
withthesecondbyteoftheACALLinstruction,andreplacingbits02ofthemostsignificantbyteoftheProgram
Counterwith3bitsthatindicatethepage.Bits37ofthemostsignificantbyteoftheProgramCounterremain
unchaged.
Sinceonly11bitsoftheProgramCounterareaffectedbyACALL,callsmayonlybemadetoroutineslocatedwithin
thesame2kblockasthefirstbytethatfollowsACALL.
SeeAlso:LCALL,RET
8051InstructionSet:ADD
Operation: ADD,ADDC
Function: AddAccumulator,AddAccumulatorWithCarry
Syntax:
ADDA,operand
ADDCA,operand
Instructions
OpCode Bytes
Flags
file:///C:/Users/Osmair/Downloads/8051%20Instruction%20Set.html
Instructions
OpCode Bytes
Flags
2/21
06/10/2016
8051InstructionSet
ADDA,#data
0x24
C,AC,OV
ADDCA,#data
0x34
C,AC,OV
ADDA,iramaddr
0x25
C,AC,OV
ADDCA,iramaddr
0x35
C,AC,OV
ADDA,@R0
0x26
C,AC,OV
ADDCA,@R0
0x36
C,AC,OV
ADDA,@R1
0x27
C,AC,OV
ADDCA,@R1
0x37
C,AC,OV
ADDA,R0
0x28
C,AC,OV
ADDCA,R0
0x38
C,AC,OV
ADDA,R1
0x29
C,AC,OV
ADDCA,R1
0x39
C,AC,OV
ADDA,R2
0x2A
C,AC,OV
ADDCA,R2
0x3A
C,AC,OV
ADDA,R3
0x2B
C,AC,OV
ADDCA,R3
0x3B
C,AC,OV
ADDA,R4
0x2C
C,AC,OV
ADDCA,R4
0x3C
C,AC,OV
ADDA,R5
0x2D
C,AC,OV
ADDCA,R5
0x3D
C,AC,OV
ADDA,R6
0x2E
C,AC,OV
ADDCA,R6
0x3E
C,AC,OV
ADDA,R7
0x2F
C,AC,OV
ADDCA,R7
0x3F
C,AC,OV
Description:Description:ADDandADDCbothaddthevalueoperandtothevalueoftheAccumulator,leavingthe
resultingvalueintheAccumulator.Thevalueoperandisnotaffected.ADDandADDCfunctionidenticallyexceptthat
ADDCaddsthevalueofoperandaswellasthevalueoftheCarryflagwhereasADDdoesnotaddtheCarryflagtothe
result.
TheCarrybit(C)issetifthereisacarryoutofbit7.Inotherwords,iftheunsignedsummedvalueofthe
Accumulator,operandand(inthecaseofADDC)theCarryflagexceeds255Carryisset.Otherwise,theCarrybitis
cleared.
TheAuxillaryCarry(AC)bitissetifthereisacarryoutofbit3.Inotherwords,iftheunsignedsummedvalueofthe
lownibbleoftheAccumulator,operandand(inthecaseofADDC)theCarryflagexceeds15theAuxillaryCarryflag
isset.Otherwise,theAuxillaryCarryflagiscleared.
TheOverflow(OV)bitissetifthereisacarryoutofbit6oroutofbit7,butnotboth.Inotherwords,iftheadditionof
theAccumulator,operandand(inthecaseofADDC)theCarryflagtreatedassignedvaluesresultsinavaluethatis
outoftherangeofasignedbyte(128through+127)theOverflowflagisset.Otherwise,theOverflowflagiscleared.
SeeAlso:SUBB,DA,INC,DEC
8051InstructionSet:AJMP
Operation: AJMP
Function: AbsoluteJumpWithin2KBlock
Syntax:
AJMPcodeaddress
Instructions OpCode Bytes Flags
AJMPpage0
0x01
None
AJMPpage1
0x21
None
AJMPpage2
0x41
None
AJMPpage3
0x61
None
AJMPpage4
0x81
None
AJMPpage5
0xA1
None
AJMPpage6
0xC1
None
AJMPpage7
0xE1
None
file:///C:/Users/Osmair/Downloads/8051%20Instruction%20Set.html
3/21
06/10/2016
8051InstructionSet
Description:AJMPunconditionallyjumpstotheindicatedcodeaddress.ThenewvaluefortheProgramCounteris
calculatedbyreplacingtheleastsignificantbyteoftheProgramCounterwiththesecondbyteoftheAJMPinstruction,
andreplacingbits02ofthemostsignificantbyteoftheProgramCounterwith3bitsthatindicatethepageofthebyte
followingtheAJMPinstruction.Bits37ofthemostsignificantbyteoftheProgramCounterremainunchaged.
Sinceonly11bitsoftheProgramCounterareaffectedbyAJMP,jumpsmayonlybemadetocodelocatedwithinthe
same2kblockasthefirstbytethatfollowsAJMP.
SeeAlso:LJMP,SJMP
8051InstructionSet:ANL
Operation: ANL
Function: BitwiseAND
Syntax:
ANLoperand1,operand2
Instructions
ANLiramaddr,A
0x52
None
ANLiramaddr,#data
0x53
None
ANLA,#data
0x54
None
ANLA,iramaddr
0x55
None
ANLA,@R0
0x56
None
ANLA,@R1
0x57
None
ANLA,R0
0x58
None
ANLA,R1
0x59
None
ANLA,R2
0x5A
None
ANLA,R3
0x5B
None
ANLA,R4
0x5C
None
ANLA,R5
0x5D
None
ANLA,R6
0x5E
None
ANLA,R7
0x5F
None
ANLC,bitaddr
0x82
ANLC,/bitaddr
0xB0
Description:ANLdoesabitwise"AND"operationbetweenoperand1andoperand2,leavingtheresultingvaluein
operand1.Thevalueofoperand2isnotaffected.Alogical"AND"comparesthebitsofeachoperandandsetsthe
correspondingbitintheresultingbyteonlyifthebitwassetinbothoftheoriginaloperands,otherwisetheresultingbit
iscleared.
SeeAlso:ORL,XRL
8051InstructionSet:CJNE
Operation: CJNE
Function: CompareandJumpIfNotEqual
Syntax:
CJNEoperand1,operand2,reladdr
file:///C:/Users/Osmair/Downloads/8051%20Instruction%20Set.html
4/21
06/10/2016
8051InstructionSet
Instructions
CJNEA,#data,reladdr
0xB4
CJNEA,iramaddr,reladdr
0xB5
CJNE@R0,#data,reladdr
0xB6
CJNE@R1,#data,reladdr
0xB7
CJNER0,#data,reladdr
0xB8
CJNER1,#data,reladdr
0xB9
CJNER2,#data,reladdr
0xBA
CJNER3,#data,reladdr
0xBB
CJNER4,#data,reladdr
0xBC
CJNER5,#data,reladdr
0xBD
CJNER6,#data,reladdr
0xBE
CJNER7,#data,reladdr
0xBF
Description:CJNEcomparesthevalueofoperand1andoperand2andbranchestotheindicatedrelativeaddressif
operand1andoperand2arenotequal.Ifthetwooperandsareequalprogramflowcontinueswiththeinstruction
followingtheCJNEinstruction.
TheCarrybit(C)issetifoperand1islessthanoperand2,otherwiseitiscleared.
SeeAlso:DJNZ
8051InstructionSet:CLR
Operation: CLR
Function: ClearRegister
Syntax:
CLRregister
Instructions OpCode Bytes Flags
CLRbitaddr
0xC2
None
CLRC
0xC3
CLRA
0xE4
None
Description:CLRclears(setsto0)allthebit(s)oftheindicatedregister.Iftheregisterisabit(includingthecarrybit),
onlythespecifiedbitisaffected.ClearingtheAccumulatorsetstheAccumulator'svalueto0.
SeeAlso:SETB
8051InstructionSet:CPL
Operation: CPL
Function: ComplementRegister
Syntax:
CPLoperand
Instructions OpCode Bytes Flags
CPLA
0xF4
None
file:///C:/Users/Osmair/Downloads/8051%20Instruction%20Set.html
5/21
06/10/2016
8051InstructionSet
CPLC
0xB3
CPLbitaddr
0xB2
None
Description:CPLcomplementsoperand,leavingtheresultinoperand.Ifoperandisasinglebitthenthestateofthe
bitwillbereversed.IfoperandistheAccumulatorthenallthebitsintheAccumulatorwillbereversed.Thiscanbe
thoughtofas"AccumulatorLogicalExclusiveOR255"oras"255Accumulator."Iftheoperandreferstoabitofan
outputPort,thevaluethatwillbecomplementedisbasedonthelastvaluewrittentothatbit,notthelastvalueread
fromit.
SeeAlso:CLR,SETB
8051InstructionSet:DA
Operation: DA
Function: DecimalAdjustAccumulator
Syntax:
DAA
Instructions OpCode Bytes Flags
DA
0xD4
Description:DAadjuststhecontentsoftheAccumulatortocorrespondtoaBCD(BinaryCodedDecimal)number
aftertwoBCDnumbershavebeenaddedbytheADDorADDCinstruction.Ifthecarrybitissetorifthevalueofbits
03exceed9,0x06isaddedtotheaccumulator.Ifthecarrybitwassetwhentheinstructionbegan,orif0x06wasadded
totheaccumulatorinthefirststep,0x60isaddedtotheaccumulator.
TheCarrybit(C)issetiftheresultingvalueisgreaterthan0x99,otherwiseitiscleared.
SeeAlso:ADD,ADDC
8051InstructionSet:DEC
Operation: DEC
Function: DecrementRegister
Syntax:
DECregister
Instructions
DECA
0x14
None
DECiramaddr
0x15
None
DEC@R0
0x16
None
DEC@R1
0x17
None
DECR0
0x18
None
DECR1
0x19
None
DECR2
0x1A
None
DECR3
0x1B
None
DECR4
0x1C
None
DECR5
0x1D
None
DECR6
0x1E
None
DECR7
0x1F
None
file:///C:/Users/Osmair/Downloads/8051%20Instruction%20Set.html
6/21
06/10/2016
8051InstructionSet
Description:DECdecrementsthevalueofregisterby1.Iftheinitialvalueofregisteris0,decrementingthevaluewill
causeittoresetto255(0xFFHex).Note:TheCarryFlagisNOTsetwhenthevalue"rollsover"from0to255.
SeeAlso:INC,SUBB
8051InstructionSet:DIV
Operation: DIV
Function: DivideAccumulatorbyB
Syntax:
DIVAB
Instructions OpCode Bytes Flags
DIVAB
0x84
C,OV
Description:DividestheunsignedvalueoftheAccumulatorbytheunsignedvalueofthe"B"register.Theresulting
quotientisplacedintheAccumulatorandtheremainderisplacedinthe"B"register.
TheCarryflag(C)isalwayscleared.
TheOverflowflag(OV)issetifdivisionby0wasattempted,otherwiseitiscleared.
SeeAlso:MULAB
8051InstructionSet:DJNZ
Operation: DJNZ
Function: DecrementandJumpifNotZero
Syntax:
DJNZregister,reladdr
Instructions
DJNZiramaddr,reladdr
0xD5
None
DJNZR0,reladdr
0xD8
None
DJNZR1,reladdr
0xD9
None
DJNZR2,reladdr
0xDA
None
DJNZR3,reladdr
0xDB
None
DJNZR4,reladdr
0xDC
None
DJNZR5,reladdr
0xDD
None
DJNZR6,reladdr
0xDE
None
DJNZR7,reladdr
0xDF
None
Description:DJNZdecrementsthevalueofregisterby1.Iftheinitialvalueofregisteris0,decrementingthevalue
willcauseittoresetto255(0xFFHex).Ifthenewvalueofregisterisnot0theprogramwillbranchtotheaddress
indicatedbyrelativeaddr.Ifthenewvalueofregisteris0programflowcontinueswiththeinstructionfollowingthe
DJNZinstruction.
SeeAlso:DEC,JZ,JNZ
8051InstructionSet:INC
file:///C:/Users/Osmair/Downloads/8051%20Instruction%20Set.html
7/21
06/10/2016
8051InstructionSet
Operation: INC
Function: IncrementRegister
Syntax:
INCregister
Instructions
INCA
0x04
None
INCiramaddr
0x05
None
INC@R0
0x06
None
INC@R1
0x07
None
INCR0
0x08
None
INCR1
0x09
None
INCR2
0x0A
None
INCR3
0x0B
None
INCR4
0x0C
None
INCR5
0x0D
None
INCR6
0x0E
None
INCR7
0x0F
None
INCDPTR
0xA3
None
Description:INCincrementsthevalueofregisterby1.Iftheinitialvalueofregisteris255(0xFFHex),incrementing
thevaluewillcauseittoresetto0.Note:TheCarryFlagisNOTsetwhenthevalue"rollsover"from255to0.
Inthecaseof"INCDPTR",thevaluetwobyteunsignedintegervalueofDPTRisincremented.Iftheinitialvalueof
DPTRis65535(0xFFFFHex),incrementingthevaluewillcauseittoresetto0.Again,theCarryFlagisNOTsetwhen
thevalueofDPTR"rollsover"from65535to0.
SeeAlso:ADD,ADDC,DEC
8051InstructionSet:JB
Operation: JB
Function: JumpifBitSet
Syntax:
JBbitaddr,reladdr
Instructions
JBbitaddr,reladdr
None
Description:JBbranchestotheaddressindicatedbyreladdrifthebitindicatedbybitaddrisset.Ifthebitisnotset
programexecutioncontinueswiththeinstructionfollowingtheJBinstruction.
SeeAlso:JBC,JNB
8051InstructionSet:JBC
Operation: JBC
Function: JumpifBitSetandClearBit
Syntax:
JBbitaddr,reladdr
file:///C:/Users/Osmair/Downloads/8051%20Instruction%20Set.html
8/21
06/10/2016
8051InstructionSet
Instructions
JBCbitaddr,reladdr
0x10
None
Description:JBCwillbranchtotheaddressindicatedbyreladdrifthebitindicatedbybitaddrisset.Beforebranching
toreladdrtheinstructionwillcleartheindicatedbit.Ifthebitisnotsetprogramexecutioncontinueswiththe
instructionfollowingtheJBCinstruction.
SeeAlso:JB,JNB
8051InstructionSet:JC
Operation: JC
Function: JumpifCarrySet
Syntax:
JCreladdr
Instructions OpCode Bytes Flags
JCreladdr
0x40
None
Description:JCwillbranchtotheaddressindicatedbyreladdriftheCarryBitisset.IftheCarryBitisnotsetprogram
executioncontinueswiththeinstructionfollowingtheJCinstruction.
SeeAlso:JNC
8051InstructionSet:JMP
Operation: JMP
Function: JumptoDataPointer+Accumulator
Syntax:
JMP@A+DPTR
Instructions
JMP@A+DPTR
None
Description:JMPjumpsunconditionallytotheaddressrepresentedbythesumofthevalueofDPTRandthevalueof
theAccumulator.
SeeAlso:LJMP,AJMP,SJMP
8051InstructionSet:JNB
Operation: JNB
Function: JumpifBitNotSet
Syntax:
JNBbitaddr,reladdr
Instructions
JNBbitaddr,reladdr
None
Description:JNBwillbranchtotheaddressindicatedbyreladdressiftheindicatedbitisnotset.Ifthebitisset
programexecutioncontinueswiththeinstructionfollowingtheJNBinstruction.
SeeAlso:JB,JBC
file:///C:/Users/Osmair/Downloads/8051%20Instruction%20Set.html
9/21
06/10/2016
8051InstructionSet
8051InstructionSet:JNC
Operation: JNC
Function: JumpifCarryNotSet
Syntax:
JNCreladdr
Instructions OpCode Bytes Flags
JNCreladdr
0x50
None
Description:JNCbranchestotheaddressindicatedbyreladdrifthecarrybitisnotset.Ifthecarrybitissetprogram
executioncontinueswiththeinstructionfollowingtheJNBinstruction.
SeeAlso:JC
8051InstructionSet:JNZ
Operation: JNZ
Function: JumpifAccumulatorNotZero
Syntax:
JNZreladdr
Instructions OpCode Bytes Flags
JNZreladdr
0x70
None
Description:JNZwillbranchtotheaddressindicatedbyreladdriftheAccumulatorcontainsanyvalueexcept0.Ifthe
valueoftheAccumulatoriszeroprogramexecutioncontinueswiththeinstructionfollowingtheJNZinstruction.
SeeAlso:JZ
8051InstructionSet:JZ
Operation: JZ
Function: JumpifAccumulatorZero
Syntax:
JNZreladdr
Instructions OpCode Bytes Flags
JZreladdr
0x60
None
Description:JZbranchestotheaddressindicatedbyreladdriftheAccumulatorcontainsthevalue0.Ifthevalueofthe
AccumulatorisnonzeroprogramexecutioncontinueswiththeinstructionfollowingtheJNZinstruction.
SeeAlso:JNZ
8051InstructionSet:LCALL
Operation: LCALL
Function: LongCall
Syntax:
LCALLcodeaddr
Instructions
LCALLcodeaddr
None
file:///C:/Users/Osmair/Downloads/8051%20Instruction%20Set.html
10/21
06/10/2016
8051InstructionSet
Description:LCALLcallsaprogramsubroutine.LCALLincrementstheprogramcounterby3(topointtothe
instructionfollowingLCALL)andpushesthatvalueontothestack(lowbytefirst,highbytesecond).TheProgram
Counteristhensettothe16bitvaluewhichfollowstheLCALLopcode,causingprogramexecutiontocontinueatthat
address.
SeeAlso:ACALL,RET
8051InstructionSet:LJMP
Operation: LJMP
Function: LongJump
Syntax:
LJMPcodeaddr
Instructions
LJMPcodeaddr
0x02
None
Description:LJMPjumpsunconditionallytothespecifiedcodeaddr.
SeeAlso:AJMP,SJMP,JMP
8051InstructionSet:MOV
Operation: MOV
Function: MoveMemory
Syntax:
MOVoperand1,operand2
Instructions
MOV@R0,#data
0x76
None
MOV@R1,#data
0x77
None
MOV@R0,A
0xF6
None
MOV@R1,A
0xF7
None
MOV@R0,iramaddr
0xA6
None
MOV@R1,iramaddr
0xA7
None
MOVA,#data
0x74
None
MOVA,@R0
0xE6
None
MOVA,@R1
0xE7
None
MOVA,R0
0xE8
None
MOVA,R1
0xE9
None
MOVA,R2
0xEA
None
MOVA,R3
0xEB
None
MOVA,R4
0xEC
None
MOVA,R5
0xED
None
MOVA,R6
0xEE
None
MOVA,R7
0xEF
None
file:///C:/Users/Osmair/Downloads/8051%20Instruction%20Set.html
11/21
06/10/2016
8051InstructionSet
MOVA,iramaddr
0xE5
None
MOVC,bitaddr
0xA2
MOVDPTR,#data16
0x90
None
MOVR0,#data
0x78
None
MOVR1,#data
0x79
None
MOVR2,#data
0x7A
None
MOVR3,#data
0x7B
None
MOVR4,#data
0x7C
None
MOVR5,#data
0x7D
None
MOVR6,#data
0x7E
None
MOVR7,#data
0x7F
None
MOVR0,A
0xF8
None
MOVR1,A
0xF9
None
MOVR2,A
0xFA
None
MOVR3,A
0xFB
None
MOVR4,A
0xFC
None
MOVR5,A
0xFD
None
MOVR6,A
0xFE
None
MOVR7,A
0xFF
None
MOVR0,iramaddr
0xA8
None
MOVR1,iramaddr
0xA9
None
MOVR2,iramaddr
0xAA
None
MOVR3,iramaddr
0xAB
None
MOVR4,iramaddr
0xAC
None
MOVR5,iramaddr
0xAD
None
MOVR6,iramaddr
0xAE
None
MOVR7,iramaddr
0xAF
None
MOVbitaddr,C
0x92
None
MOViramaddr,#data
0x75
None
MOViramaddr,@R0
0x86
None
MOViramaddr,@R1
0x87
None
MOViramaddr,R0
0x88
None
MOViramaddr,R1
0x89
None
MOViramaddr,R2
0x8A
None
MOViramaddr,R3
0x8B
None
MOViramaddr,R4
0x8C
None
MOViramaddr,R5
0x8D
None
MOViramaddr,R6
0x8E
None
file:///C:/Users/Osmair/Downloads/8051%20Instruction%20Set.html
12/21
06/10/2016
8051InstructionSet
MOViramaddr,R7
0x8F
None
MOViramaddr,A
0xF5
None
MOViramaddr,iramaddr
0x85
None
Description:MOVcopiesthevalueofoperand2intooperand1.Thevalueofoperand2isnotaffected.Bothoperand1
andoperand2mustbeinInternalRAM.Noflagsareaffectedunlesstheinstructionismovingthevalueofabitintothe
carrybitinwhichcasethecarrybitisaffectedorunlesstheinstructionismovingavalueintothePSWregister(which
containsalltheprogramflags).
**Note:Inthecaseof"MOViramaddr,iramaddr",theoperandbytesoftheinstructionarestoredinreverseorder.
Thatis,theinstructionconsistingofthebytes0x85,0x20,0x50means"MovethecontentsofInternalRAMlocation
0x20toInternalRAMlocation0x50"whereastheoppositewouldbegenerallypresumed.
SeeAlso:MOVC,MOVX,XCH,XCHD,PUSH,POP
8051InstructionSet:MOVC
Operation: MOVC
Function: MoveCodeBytetoAccumulator
Syntax:
MOVCA,@A+register
Instructions
MOVCA,@A+DPTR
0x93
None
MOVCA,@A+PC
0x83
None
Description:MOVCmovesabytefromCodeMemoryintotheAccumulator.TheCodeMemoryaddressfromwhich
thebytewillbemovediscalculatedbysummingthevalueoftheAccumulatorwitheitherDPTRortheProgram
Counter(PC).InthecaseoftheProgramCounter,PCisfirstincrementedby1beforebeingsummedwiththe
Accumulator.
SeeAlso:MOV,MOVX
8051InstructionSet:MOVX
Operation: MOVX
Function: MoveDataTo/FromExternalMemory(XRAM)
Syntax:
MOVXoperand1,operand2
Instructions
MOVX@DPTR,A
0xF0
None
MOVX@R0,A
0xF2
None
MOVX@R1,A
0xF3
None
MOVXA,@DPTR
0xE0
None
MOVXA,@R0
0xE2
None
MOVXA,@R1
0xE3
None
Description:MOVXmovesabytetoorfromExternalMemoryintoorfromtheAccumulator.
Ifoperand1is@DPTR,theAccumulatorismovedtothe16bitExternalMemoryaddressindicatedbyDPTR.This
instructionusesbothP0(port0)andP2(port2)tooutputthe16bitaddressanddata.Ifoperand2isDPTRthenthe
file:///C:/Users/Osmair/Downloads/8051%20Instruction%20Set.html
13/21
06/10/2016
8051InstructionSet
byteismovedfromExternalMemoryintotheAccumulator.
Ifoperand1is@R0or@R1,theAccumulatorismovedtothe8bitExternalMemoryaddressindicatedbythe
specifiedRegister.ThisinstructionusesonlyP0(port0)tooutputthe8bitaddressanddata.P2(port2)isnotaffected.
Ifoperand2is@R0or@R1thenthebyteismovedfromExternalMemoryintotheAccumulator.
SeeAlso:MOV,MOVC
8051InstructionSet:MUL
Operation: MUL
Function: MultiplyAccumulatorbyB
Syntax:
MULAB
Instructions OpCode Bytes Flags
MULAB
0xA4
C,OV
Description:MultiplestheunsignedvalueoftheAccumulatorbytheunsignedvalueofthe"B"register.Theleast
significantbyteoftheresultisplacedintheAccumulatorandthemostsignificantbyteisplacedinthe"B"register.
TheCarryFlag(C)isalwayscleared.
TheOverflowFlag(OV)issetiftheresultisgreaterthan255(ifthemostsignificantbyteisnotzero),otherwiseitis
cleared.
SeeAlso:DIV
8051InstructionSet:NOP
Operation: NOP
Function: None,wastetime
Syntax:
NoOperation
Instructions OpCode Bytes Flags
NOP
0x00
None
Description:NOP,asit'snamesuggests,causesNoOperationtotakeplaceforonemachinecycle.NOPisgenerally
usedonlyfortimingpurposes.Absolutelynoflagsorregistersareaffected.
8051InstructionSet:ORL
Operation: ORL
Function: BitwiseOR
Syntax:
ORLoperand1,operand2
Instructions
ORLiramaddr,A
0x42
None
ORLiramaddr,#data
0x43
None
ORLA,#data
0x44
None
ORLA,iramaddr
0x45
None
file:///C:/Users/Osmair/Downloads/8051%20Instruction%20Set.html
14/21
06/10/2016
8051InstructionSet
ORLA,@R0
0x46
None
ORLA,@R1
0x47
None
ORLA,R0
0x48
None
ORLA,R1
0x49
None
ORLA,R2
0x4A
None
ORLA,R3
0x4B
None
ORLA,R4
0x4C
None
ORLA,R5
0x4D
None
ORLA,R6
0x4E
None
ORLA,R7
0x4F
None
ORLC,bitaddr
0x72
ORLC,/bitaddr
0xA0
Description:ORLdoesabitwise"OR"operationbetweenoperand1andoperand2,leavingtheresultingvaluein
operand1.Thevalueofoperand2isnotaffected.Alogical"OR"comparesthebitsofeachoperandandsetsthe
correspondingbitintheresultingbyteifthebitwassetineitheroftheoriginaloperands,otherwisetheresultingbitis
cleared.
SeeAlso:ANL,XRL
8051InstructionSet:POP
Operation: POP
Function: PopValueFromStack
Syntax:
POP
Instructions
POPiramaddr
None
Description:POP"pops"thelastvalueplacedonthestackintotheiramaddrspecified.Inotherwords,POPwillload
iramaddrwiththevalueoftheInternalRAMaddresspointedtobythecurrentStackPointer.Thestackpointeristhen
decrementedby1.
SeeAlso:PUSH
8051InstructionSet:PUSH
Operation: PUSH
Function: PushValueOntoStack
Syntax:
PUSH
Instructions
PUSHiramaddr
None
Description:PUSH"pushes"thevalueofthespecifiediramaddrontothestack.PUSHfirstincrementsthevalueof
theStackPointerby1,thentakesthevaluestorediniramaddrandstoresitinInternalRAMatthelocationpointedto
bytheincrementedStackPointer.
file:///C:/Users/Osmair/Downloads/8051%20Instruction%20Set.html
15/21
06/10/2016
8051InstructionSet
SeeAlso:POP
8051InstructionSet:RET
Operation: RET
Function: ReturnFromSubroutine
Syntax:
RET
Instructions OpCode Bytes Flags
RET
0x22
None
Description:RETisusedtoreturnfromasubroutinepreviouslycalledbyLCALLorACALL.Programexecution
continuesattheaddressthatiscalculatedbypoppingthetopmost2bytesoffthestack.Themostsignificantbyteis
poppedoffthestackfirst,followedbytheleastsignificantbyte.
SeeAlso:LCALL,ACALL,RETI
8051InstructionSet:RETI
Operation: RETI
Function: ReturnFromInterrupt
Syntax:
RETI
Instructions OpCode Bytes Flags
RETI
0x32
None
Description:RETIisusedtoreturnfromaninterruptserviceroutine.RETIfirstenablesinterruptsofequalandlower
prioritiestotheinterruptthatisterminating.Programexecutioncontinuesattheaddressthatiscalculatedbypopping
thetopmost2bytesoffthestack.Themostsignificantbyteispoppedoffthestackfirst,followedbytheleast
significantbyte.
RETIfunctionsidenticallytoRETifitisexecutedoutsideofaninterruptserviceroutine.
SeeAlso:RET
8051InstructionSet:RL
Operation: RL
Function: RotateAccumulatorLeft
Syntax:
RLA
Instructions OpCode Bytes Flags
RLA
0x23
Description:ShiftsthebitsoftheAccumulatortotheleft.Theleftmostbit(bit7)oftheAccumulatorisloadedintobit
0.
SeeAlso:RLC,RR,RRC
8051InstructionSet:RLC
file:///C:/Users/Osmair/Downloads/8051%20Instruction%20Set.html
16/21
06/10/2016
8051InstructionSet
Operation: RLC
Function: RotateAccumulatorLeftThroughCarry
Syntax:
RLCA
Instructions OpCode Bytes Flags
RLCA
0x33
Description:ShiftsthebitsoftheAccumulatortotheleft.Theleftmostbit(bit7)oftheAccumulatorisloadedinto
theCarryFlag,andtheoriginalCarryFlagisloadedintobit0oftheAccumulator.Thisfunctioncanbeusedtoquickly
multiplyabyteby2.
SeeAlso:RL,RR,RRC
8051InstructionSet:RR
Operation: RR
Function: RotateAccumulatorRight
Syntax:
RRA
Instructions OpCode Bytes Flags
RRA
0x03
None
Description:ShiftsthebitsoftheAccumulatortotheright.Therightmostbit(bit0)oftheAccumulatorisloadedinto
bit7.
SeeAlso:RL,RLC,RRC
8051InstructionSet:RRC
Operation: RRC
Function: RotateAccumulatorRightThroughCarry
Syntax:
RRCA
Instructions OpCode Bytes Flags
RRCA
0x13
Description:ShiftsthebitsoftheAccumulatortotheright.Therightmostbit(bit0)oftheAccumulatorisloadedinto
theCarryFlag,andtheoriginalCarryFlagisloadedintobit7.Thisfunctioncanbeusedtoquicklydivideabyteby2.
SeeAlso:RL,RLC,RR
8051InstructionSet:SETB
Operation: SETB
Function: SetBit
Syntax:
SETBbitaddr
Instructions
SETBC
0xD3
SETBbitaddr
0xD2
None
file:///C:/Users/Osmair/Downloads/8051%20Instruction%20Set.html
17/21
06/10/2016
8051InstructionSet
Description:Setsthespecifiedbit.
SeeAlso:CLR
8051InstructionSet:SJMP
Operation: SJMP
Function: ShortJump
Syntax:
SJMPreladdr
Instructions OpCode Bytes Flags
SJMPreladdr
0x80
None
Description:SJMPjumpsunconditionallytotheaddressspecifiedreladdr.Reladdrmustbewithin128or+127bytes
oftheinstructionthatfollowstheSJMPinstruction.
SeeAlso:LJMP,AJMP
8051InstructionSet:SUBB
Operation: SUBB
Function: SubtractfromAccumulatorWithBorrow
Syntax:
SUBBA,operand
Instructions
OpCode Bytes
Flags
SUBBA,#data
0x94
C,AC,OV
SUBBA,iramaddr
0x95
C,AC,OV
SUBBA,@R0
0x96
C,AC,OV
SUBBA,@R1
0x97
C,AC,OV
SUBBA,R0
0x98
C,AC,OV
SUBBA,R1
0x99
C,AC,OV
SUBBA,R2
0x9A
C,AC,OV
SUBBA,R3
0x9B
C,AC,OV
SUBBA,R4
0x9C
C,AC,OV
SUBBA,R5
0x9D
C,AC,OV
SUBBA,R6
0x9E
C,AC,OV
SUBBA,R7
0x9F
C,AC,OV
Description:SUBBsubtractthevalueofoperandfromthevalueoftheAccumulator,leavingtheresultingvalueinthe
Accumulator.Thevalueoperandisnotaffected.
TheCarryBit(C)issetifaborrowwasrequiredforbit7,otherwiseitiscleared.Inotherwords,iftheunsignedvalue
beingsubtractedisgreaterthantheAccumulatortheCarryFlagisset.
TheAuxillaryCarry(AC)bitissetifaborrowwasrequiredforbit3,otherwiseitiscleared.Inotherwords,thebitis
setifthelownibbleofthevaluebeingsubtractedwasgreaterthanthelownibbleoftheAccumulator.
file:///C:/Users/Osmair/Downloads/8051%20Instruction%20Set.html
18/21
06/10/2016
8051InstructionSet
TheOverflow(OV)bitissetifaborrowwasrequiredforbit6orforbit7,butnotboth.Inotherwords,thesubtraction
oftwosignedbytesresultedinavalueoutsidetherangeofasignedbyte(128to127).Otherwiseitiscleared.
SeeAlso:ADD,ADDC,DEC
8051InstructionSet:SWAP
Operation: SWAP
Function: SwapAccumulatorNibbles
Syntax:
SWAPA
Instructions OpCode Bytes Flags
SWAPA
0xC4
None
Description:SWAPswapsbits03oftheAccumulatorwithbits47oftheAccumulator.Thisinstructionisidenticalto
executing"RRA"or"RLA"fourtimes.
SeeAlso:RL,RLC,RR,RRC
8051InstructionSet:UndefinedInstruction
Operation: UndefinedInstruction
Function: Undefined
Syntax:
???
Instructions OpCode Bytes Flags
???
0xA5
Description:The"Undefined"instructionis,asthenamesuggests,notadocumentedinstruction.The8051supports
255instructionsandOpCode0xA5isthesingleOpCodethatisnotusedbyanydocumentedfunction.Sinceitisnot
documentednordefineditisnotrecommendedthatitbeexecuted.However,basedonmyresearch,executingthis
undefinedinstructiontakes1machinecycleandappearstohavenoeffectonthesystemexceptthattheCarryBit
alwaysseemstobeset.
Note:Wereceivedinputfroman8052.comuserthattheundefinedinstructionreallyhasaformatofUndefinedbit1,bit2
andeffectivelycopiesthevalueofbit2tobit1.Inthiscase,itwouldbeathreebyteinstruction.Wehaven'thadan
opportunitytoverifyordisprovethisreport,sowepresentittotheworldas"additionalinformation."
Note:IthasbeenreportedthatPhilips8051modelP89C669usesinstructionprefix0xA5tolettheuseraccessa
different(extended)SFRarea.
8051InstructionSet:XCH
Operation: XCH
Function: ExchangeBytes
Syntax:
XCHA,register
Instructions
XCHA,@R0
0xC6
None
XCHA,@R1
0xC7
None
XCHA,R0
0xC8
None
file:///C:/Users/Osmair/Downloads/8051%20Instruction%20Set.html
19/21
06/10/2016
8051InstructionSet
XCHA,R1
0xC9
None
XCHA,R2
0xCA
None
XCHA,R3
0xCB
None
XCHA,R4
0xCC
None
XCHA,R5
0xCD
None
XCHA,R6
0xCE
None
XCHA,R7
0xCF
None
XCHA,iramaddr
0xC5
None
Description:ExchangesthevalueoftheAccumulatorwiththevaluecontainedinregister.
SeeAlso:MOV
8051InstructionSet:XCHD
Operation: XCHD
Function: ExchangeDigit
Syntax:
XCHDA,[@R0/@R1]
Instructions
XCHDA,@R0
0xD6
None
XCHDA,@R1
0xD7
None
Description:Exchangesbits03oftheAccumulatorwithbits03oftheInternalRAMaddresspointedtoindirectlyby
R0orR1.Bits47ofeachregisterareunaffected.
SeeAlso:DA
8051InstructionSet:XRL
Operation: XRL
Function: BitwiseExclusiveOR
Syntax:
XRLoperand1,operand2
Instructions
XRLiramaddr,A
0x62
None
XRLiramaddr,#data
0x63
None
XRLA,#data
0x64
None
XRLA,iramaddr
0x65
None
XRLA,@R0
0x66
None
XRLA,@R1
0x67
None
XRLA,R0
0x68
None
XRLA,R1
0x69
None
XRLA,R2
0x6A
None
file:///C:/Users/Osmair/Downloads/8051%20Instruction%20Set.html
20/21
06/10/2016
8051InstructionSet
XRLA,R3
0x6B
None
XRLA,R4
0x6C
None
XRLA,R5
0x6D
None
XRLA,R6
0x6E
None
XRLA,R7
0x6F
None
Description:XRLdoesabitwise"EXCLUSIVEOR"operationbetweenoperand1andoperand2,leavingtheresulting
valueinoperand1.Thevalueofoperand2isnotaffected.Alogical"EXCLUSIVEOR"comparesthebitsofeach
operandandsetsthecorrespondingbitintheresultingbyteifthebitwassetineither(butnotboth)oftheoriginal
operands,otherwisethebitiscleared.
SeeAlso:ANL,ORL
file:///C:/Users/Osmair/Downloads/8051%20Instruction%20Set.html
21/21