Thursday, March 17, 2016

8051 Instructions and Examples

8051 Instruction Set with Examples

InstructionExample
MnemonicOperands
NOPNOP
AJMPcode addr (addr11)AJMP JMPADR
LJMPcode addr (addr16)LJMP JMPADR
RRARR A
INCAINC A
INCdata addr (direct)INC 34h
INC@R0INC @R0
INC@R1INC @R1
INCR0INC R0
INCR1INC R1
INCR2INC R2
INCR3INC R3
INCR4INC R4
INCR5INC R5
INCR6INC R6
INCR7INC R7
JBCbit addr,
code addr (rel)
JBC ACC.3,LABEL1
ACALLcode addr (addr11)ACALL SUBRTN
LCALLcode addr (addr16)LCALL SUBRTN
RRCARRC A
DECADEC A
DECdata addr (direct)DEC 35h
DEC@R0DEC @R0
DEC@R1DEC @R1
DECR0DEC R0
DECR1DEC R1
DECR2DEC R2
DECR3DEC R3
DECR4DEC R4
DECR5DEC R5
DECR6DEC R6
DECR7DEC R7
JBbit addr,
code addr (rel)
JB P1.2,LABEL1
AJMPcode addr (addr11)AJMP JMPADR
RETRET
RLARL A
ADDA, #data (immediate)ADD A, #03h
ADDA,data addr (direct)ADD A, 20h
ADDA,@R0ADD A, @R0
ADDA,@R1ADD A, @R1
ADDA,R0ADD A, R0
ADDA,R1ADD A, R1
ADDA,R2ADD A, R2
ADDA,R3ADD A, R3
ADDA,R4ADD A, R4
ADDA,R5ADD A, R5
ADDA,R6ADD A, R6
ADDA,R7ADD A, R7
JNBbit addr,
code addr (rel)
JNB P1.3,LABEL1
ACALLcode addr (addr11)ACALL SUBRTN
RETIRETI
RLCARLC A
ADDCA, #data (immediate)ADDC A, #03h
ADDCA,data addr (direct)ADDC A, 20h
ADDCA,@R0ADDC A, @R0
ADDCA,@R1ADDC A, @R1
ADDCA,R0ADDC A, R0
ADDCA,R1ADDC A, R1
ADDCA,R2ADDC A, R2
ADDCA,R3ADDC A, R3
ADDCA,R4ADDC A, R4
ADDCA,R5ADDC A, R5
ADDCA,R6ADDC A, R6
ADDCA,R7ADDC A, R7
JCcode addr (rel)JC LABEL1
AJMPcode addr (addr11)AJMP JMPADR
ORLdata addr (direct),AORL P0, A
ORLdata addr (direct),
#data (immediate)
ORL P0, #01h
ORLA, #data (immediate)ORL A, #01h
ORLA,data addr (direct)ORL A, P0
ORLA,@R0ORL A, @R0
ORLA,@R1ORL A, @R1
ORLA,R0ORL A, R0
ORLA,R1ORL A, R1
ORLA,R2ORL A, R2
ORLA,R3ORL A, R3
ORLA,R4ORL A, R4
ORLA,R5ORL A, R5
ORLA,R6ORL A, R6
ORLA,R7ORL A, R7
JNCcode addr (rel)JNC LABEL1
ACALLcode addr (addr11)ACALL SUBRTN
ANLdata addr (direct),AANL 40h, A
ANLdata addr(direct),
#data(immediate)
ANL 30h, #77h
ANLA, #data (immediate)ANL A, #3Fh
ANLA,data addr (direct)ANL A, 40h
ANLA,@R0ANL A, @R0
ANLA,@R1ANL A, @R1
ANLA,R0ANL A, R0
ANLA,R1ANL A, R1
ANLA,R2ANL A, R2
ANLA,R3ANL A, R3
ANLA,R4ANL A, R4
ANLA,R5ANL A, R5
ANLA,R6ANL A, R6
ANLA,R7ANL A, R7
JZcode addr (rel)JZ LABEL1
AJMPcode addr (addr11)AJMP JMPADR
XRLdata addr (direct),AXRL 34h, A
XRLdata addr (direct),
#data (immediate)
XRL 34h, #0FFh
XRLA, #data (immediate)XRL A, #0FFh
XRLA,data addr (direct)XRL A, 34h
XRLA,@R0XRL A, @R0
XRLA,@R1XRL A, @R1
XRLA,R0XRL A, R0
XRLA,R1XRL A, R1
XRLA,R2XRL A, R2
XRLA,R3XRL A, R3
XRLA,R4XRL A, R4
XRLA,R5XRL A, R5
XRLA,R6XRL A, R6
XRLA,R7XRL A, R7
JNZcode addr (rel)JNZ LABEL1
ACALLcode addr (addr11)ACALL SUBRTN
ORLC,bit addrORL C, 22h
JMP@A+DPTRJMP @A + DPTR
MOVA,#data (immediate)MOV A, #0FFh
MOVdata addr(direct),
#data (immediate)
MOV P2, #0FFh
MOV@R0,
#data (immediate)
MOV @R0, #10h
MOV@R1,
#data (immediate)
MOV @R1, #10h
MOVR0,
#data (immediate)
MOV R0, #10h
MOVR1,
#data (immediate)
MOV R1, #10h
MOVR2,
#data (immediate)
MOV R2, #10h
MOVR3,
#data (immediate)
MOV R3, #10h
MOVR4,
#data (immediate)
MOV R4, #10h
MOVR5,
#data (immediate)
MOV R5, #10h
MOVR6,
#data (immediate)
MOV R6, #10h
MOVR7,
#data (immediate)
MOV R7, #10h
SJMPcode addr (rel)SJMP RELADR
AJMPcode addr (addr11)AJMP JMPADR
ANLC,bit addrANL C, 22h
MOVCA,@A+PCMOV A, @A+PC
DIVAB DIV AB
MOVdata addr (direct),
data addr (direct)
MOV P1, P0
MOVdata addr (direct),@R0MOV P0, @R0
MOVdata addr (direct),@R1MOV P0, @R1
MOVdata addr (direct),R0MOV P2, R0
MOVdata addr (direct),R1MOV P2, R1
MOVdata addr (direct),R2MOV P2, R2
MOVdata addr (direct),R3MOV P2, R3
MOVdata addr (direct),R4MOV P2, R4
MOVdata addr (direct),R5MOV P2, R5
MOVdata addr (direct),R6MOV P2, R6
MOVdata addr (direct),R7MOV P2, R7
MOVDPTR,
#data16 (immediate)
MOV DPTR, # 1234H
ACALLcode addr (addr11)ACALL SUBRTN
MOVbit addr,CMOV 22h, C
MOVCA,@A+DPTRMOVC A, @A+DPTR
SUBBA,#data (immediate)SUBB A, #01h
SUBBA,data addr (direct)SUBB A, 44h
SUBBA,@R0SUBB A, @R0
SUBBA,@R1SUBB A, @R1
SUBBA,R0SUBB A, R0
SUBBA,R1SUBB A, R1
SUBBA,R2SUBB A, R2
SUBBA,R3SUBB A, R3
SUBBA,R4SUBB A, R4
SUBBA,R5SUBB A, R5
SUBBA,R6SUBB A, R6
SUBBA,R7SUBB A, R7
ORLC,/bit addrORL C, /22h
AJMPcode addr (addr11)AJMP JMPADR
MOVC,bit addrMOV C, 22h
INCDPTRINC DPTR
MULABMUL AB
reserved
MOV@R0,data addr (direct)MOV @R0, P2
MOV@R1,data addr (direct)MOV @R1, P2
MOVR0,data addr (direct)MOV R0, P1
MOVR1,data addr (direct)MOV R1, P1
MOVR2,data addr (direct)MOV R2, P1
MOVR3,data addr (direct)MOV R3, P1
MOVR4,data addr (direct)MOV R4, P1
MOVR5,data addr (direct)MOV R5, P1
MOVR6,data addr (direct)MOV R6, P1
MOVR7,data addr (direct)MOV R7, P1
ANLC,/bit addrANL C, /22h
ACALLcode addr (addr11)ACALL SUBRTN
CPLbit addrCPL P1.1
CPLCCPL C
CJNEA,#data (immediate),
code addr (rel)
CJNE A, #01H, LABEL
CJNEA,data addr (direct),
code addr (rel)
CJNE A, 60h, LABEL
CJNE@R0,#data (immediate),
code addr (rel)
CJNE @R0, #24H, LABEL
CJNE@R1,#data (immediate),
code addr (rel)
CJNE @R1, #24H, LABEL
CJNER0,#data (immediate),
code addr (rel)
CJNE R0, #12H, LABEL
CJNER1,#data (immediate),
code addr (rel)
CJNE R1, #12H, LABEL
CJNER2,#data (immediate),
code addr (rel)
CJNE R2, #12H, LABEL
CJNER3,#data (immediate),
code addr (rel)
CJNE R3, #12H, LABEL
CJNER4,#data (immediate),
code addr (rel)
CJNE R4, #12H, LABEL
CJNER5,#data (immediate),
code addr (rel)
CJNE R5, #12H, LABEL
CJNER6,#data (immediate),
code addr (rel)
CJNE R6, #12H, LABEL
CJNER7,#data (immediate),
code addr (rel)
CJNE R7, #12H, LABEL
PUSHdata addr (direct)PUSH DPL
AJMPcode addr (addr11)AJMP JMPADR
CLRbit addrCLR P1.2
CLRCCLR C
SWAPASWAP A
XCHA,data addr (direct)XCH A, 45h
XCHA,@R0XCH A, @R0
XCHA,@R1XCH A, @R1
XCHA,R0XCH A, R0
XCHA,R1XCH A, R1
XCHA,R2XCH A, R2
XCHA,R3XCH A, R3
XCHA,R4XCH A, R4
XCHA,R5XCH A, R5
XCHA,R6XCH A, R6
XCHA,R7XCH A, R7
POPdata addr (direct)POP 34h
ACALLcode addr (addr11)ACALL SUBRTN
SETBbit addrSETB 63h
SETBCSETB C
DAADA A
DJNZdata addr (direct),
code addr (rel)
DJNZ 40h, LABEL
XCHDA,@R0XCHD A,@R0
XCHDA,@R1XCHD A,@R1
DJNZR0,code addr (rel)DJNZ R0, LABEL
DJNZR1,code addr (rel)DJNZ R1, LABEL
DJNZR2,code addr (rel)DJNZ R2, LABEL
DJNZR3,code addr (rel)DJNZ R3, LABEL
DJNZR4,code addr (rel)DJNZ R4, LABEL
DJNZR5,code addr (rel)DJNZ R5, LABEL
DJNZR6,code addr (rel)DJNZ R6, LABEL
DJNZR7,code addr (rel)DJNZ R7, LABEL
MOVXA,@DPTRMOVX A, @DPTR
AJMPcode addr (addr11)AJMP JMPADR
MOVXA,@R0MOVX A, @R0
MOVXA,@R1MOVX A, @R1
CLRACLR A
MOVA,data addr (direct)MOV A, P0
MOVA,@R0MOV A, @R0
MOVA,@R1MOV A, @R1
MOVA,R0MOV A, R0
MOVA,R1MOV A, R1
MOVA,R2MOV A, R2
MOVA,R3MOV A, R3
MOVA,R4MOV A, R4
MOVA,R5MOV A, R5
MOVA,R6MOV A, R6
MOVA,R7MOV A, R7
MOVX@DPTR,AMOVX @DPTR, A
ACALLcode addr (addr11)ACALL SUBRTN
MOVX@R0,AMOVX @R0, A
MOVX@R1,AMOVX @R1, A
CPLACPL A
MOVdata addr (direct),AMOV P0, A
MOV@R0,AMOV @R0, A
MOV@R1,AMOV @R1, A
MOVR0,AMOV R0, A
MOVR1,AMOV R1, A
MOVR2,AMOV R2, A
MOVR3,AMOV R3, A
MOVR4,AMOV R4, A
MOVR5,AMOV R5, A
MOVR6,AMOV R6, A
MOVR7,AMOV R7, A



Related topics:
8051 Instruction Set Overview   |   8051 Instruction Cycle   |   8051 Machine Cycle   |   8051 Instruction Set Summary   |   8051 Arithmetic Operation Instructions   |   8051 Logical Operation Instructions   |   8051 Data Transfer Instructions   |   8051 Boolean Variable Manipulation Instructions   |   8051 Program Branching Instructions   |   8051 Instruction Opcode   |   8051 Instructions that Affect Flag Settings

List of topics: 8051

No comments:

Post a Comment