Assembler and Instruction Set of 8051 microcontroller

Arithmetic Operations

ADD A,RnAdd register to A11
ADD A,directAdd direct byte to A21
ADD A,@RiAdd indirect RAM to A11
ADD A,#dataAdd immediate data to A21
ADDC A,RnAdd register to A with Carry11
ADDC A,directAdd direct byte to A with Carry21
ADDC A,@RiAdd indirect RAM to A with Carry11
ADDC A,#dataAdd immediate data to A with Carry21
SUBB A,RnSubtract register from A with Borrow11
SUBB A,directSubtract direct byte from A with Borrow21
SUBB A,@RiSubtract indirect RAM from A with Borrow11
SUBB A,#dataSubtract immediate data from A with Borrow21
INC AIncrement A11
INC RnIncrement register11
INC directIncrement direct byte21
INC @RiIncrement indirect RAM11
DEC ADecrement A11
DEC RnDecrement register11
DEC directDecrement direct byte21
DEC @RiDecrement indirect RAM11
INC DPTRIncrement Data Pointer12
MUL ABMultiply A and B (A x B => BA)14
DIV ABDivide A by B (A/B => A + B)14
DA ADecimal Adjust A11

Logical Operations

ANL A,RnAND register to A11
ANL A,directAND direct byte to A21
ANL A,@RiAND indirect RAM to A11
ANL A,#dataAND immediate data to A21
ANL direct,AAND A to direct byte21
ANL direct,#dataAND immediate data to direct byte32
ORL A,RnOR register to A11
ORL A,directOR direct byte to A21
ORL A,@RiOR indirect RAM to A11
ORL A,#dataOR immediate data to A21
ORL direct,AOR A to direct byte21
ORL direct,#dataOR immediate data to direct byte32
XRL A,RnExclusive-OR register to A11
XRL A,directExclusive-OR direct byte to A21
XRL A,@RiExclusive-OR indirect RAM to A11
XRL A,#dataExclusive-OR immediate data to A21
XRL direct,AExclusive-OR A to direct byte21
XRL direct,#dataExclusive-OR immediate data to direct byte32
CLR AClear A11
CPL AComplement A11
RL ARotate A Left11
RLC ARotate A Left through Carry11
RR ARotate A Right11
RRC ARotate A Right through Carry11
SWAP ASwap nibbles within A11

Data Transfer Operations

MOV A,RnMove register to A11
MOV A,directMove direct byte to A21
MOV A,@RiMove indirect RAM to A11
MOV A,#dataMove immediate data to A21
MOV Rn,AMove A to register11
MOV Rn,directMove direct byte to register22
MOV Rn,#dataMove immediate data to register21
MOV direct,AMove A to direct byte21
MOV direct,RnMove register to direct byte22
MOV direct,directMove direct byte to direct byte32
MOV direct,@RiMove indirect RAM to direct byte22
MOV direct,#dataMove immediate data to direct byte32
MOV @Ri,AMove A to indirect RAM11
MOV @Ri,directMove direct byte to indirect RAM22
MOV @Ri,#dataMove immediate data to indirect RAM21
MOV DPTR,#data16Load Data Pointer with 16-bit constant21
MOVC A,@A+DPTRMove Code byte relative to DPTR to A12
MOVC A,@A+PCMove Code byte relative to PC to A12
MOVX A,@RiMove External RAM (8-bit addr) to A12
MOVX A,@DPTRMove External RAM (16-bit addr) to A12
MOVX @Ri,AMove A to External RAM (8-bit addr)12
MOVX @DPTR,AMove A to External RAM (16-bit addr)12
PUSH directPush direct byte onto stack22
POP directPop direct byte from stack22
XCH A,RnExchange register with A11
XCH A,directExchange direct byte with A21
XCH A,@RiExchange indirect RAM with A11
XCHD A,@RiExchange low-order Digit indirect RAM with A11

Single Bit (Boolean Variable) Operations

CLR CClear Carry flag11
CLR bitClear direct bit21
SETB CSet Carry flag11
SETB bitSet direct bit21
CPL CComplement Carry flag11
CPL bitComplement direct bit21
ANL C,bitAND direct bit to Carry flag22
ANL C,/bitAND complement of direct bit to Carry flag22
ORL C,bitOR direct bit to Carry flag22
ORL C,/bitOR complement of direct bit to Carry flag22
MOV C,bitMove direct bit to Carry flag21
MOV bit,CMove Carry flag to direct bit22

Program Flow Control

ACALL addr11Absolute subroutine call22
LCALL addr16Long subroutine call32
RETReturn from subroutine12
RETIReturn from interrupt12
AJMP addr11Absolute Jump22
LJMP addr16Long Jump32
SJMP relShort Jump at relative address22
JMP @A+DPTRJump indirect relative to DPTR12
JZ relJump if A is Zero22
JNZ relJump if A is Not Zero22
JC relJump if Carry flag is set22
JNC relJump if No Carry flag22
JB bit,relJump if direct Bit is set32
JNB bit,relJump if direct Bit is Not set32
JBC bit,relJump if direct Bit is set and Clear bit32
CJNE A,direct,relCompare direct to A and Jump if Not Equal32
CJNE A,#data,relCompare immediate to A and Jump if Not Equal32
CJNE Rn,#data,relCompare immediate to register and Jump if Not Equal32
CJNE @Ri,#data,relCompare immediate to indirect and Jump if Not Equal32
DJNZ Rn,relDecrement register and Jump if Not Zero22
DJNZ direct,relDecrement direct byte and Jump if Not Zero32
NOPNo operation11


RnWorking register R0-R7
direct128 internal RAM locations, any I/O port, control or status register
@RiIndirect internal RAM location addressed by register R0 or R1
#data8-bit constant included in instruction
#data1616-bit constant included in instruction
bit128 software flags, any I/O pin, control or status bit
addr16Destination address may be anywhere in 64-kByte program address space
addr11Destination address will be within same 2-kByte page of program address space as first byte of the following instruction
rel8-bit offset relative to first byte of following instruction (+127, -128)

All mnemonics copyrighted (C) Intel Corporation 1979

Copyright (C) 2006,2007