0% found this document useful (0 votes)
68 views2 pages

8051 Instruction Set

The document summarizes the instruction set of the 8051 microcontroller. It lists arithmetic, logical, data transfer, program branching, and other operations supported. Key operations include adding, subtracting, ANDing, ORing, moving data between registers and memory, conditional jumps, subroutine calls, and no operation instructions.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
68 views2 pages

8051 Instruction Set

The document summarizes the instruction set of the 8051 microcontroller. It lists arithmetic, logical, data transfer, program branching, and other operations supported. Key operations include adding, subtracting, ANDing, ORing, moving data between registers and memory, conditional jumps, subroutine calls, and no operation instructions.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

8051 Instruction Set

Byte Clk Byte Clk

Arithmetic operations
ADD A,Rn ADD A,direct ADD A,@Ri ADD A,#data ADDC A,Rn ADDC A,direct ADDC A,@Ri ADDC A,#data SUBB A,Rn
Add register to accumulator (A) <-- (A) + (Rn) Add direct byte to Acc (A) <-- (A) + (direct) Add indirect Ram to Acc (A) <-- (A) + (( Ri )) Add immediate data to acc (A) <-- (A) + #data Add register to acc with carry (A) <-- (A) + ( C ) + ( Rn ) Add dir. byte to Acc with Carry (A) <-- (A) + ( C )+ (direct) Add indir Ram to Acc with carry (A) <-- (A) + (C) + (( Ri )) Add imm. data to acc with carry (A) <-- (A) + (C) + #data Subtract Register from Acc with borrow (A) <-- (A) - ( C ) - ( Rn ) borrow (A) <-- (A) - ( C ) - (direct )

Logical operations
1 2 1 2 1 2 1 2 1 2 1 2 1 1 2 1 1 1 2 1 1 1 1 1 1 2 1 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 24 48 48 12 12 12 12 SWAP A ANL A,Rn ANL A,direct ANL A,@Ri ANL A,#data ANL direct,A ANL direct,#data ORL A,Rn ORL A,direct ORL A,@Ri ORL A,#data ORL direct,A ORL direct,#data XRL A,Rn XRL A,direct XRL A,@Ri XRL A,#data XRL direct,A XRL direct,#data CLR A CPL A RL A RLC A RR A RRC A
AND register to Acc (A) <-- (A) AND (Rn) AND direct byte to Acc (A) <-- (A) AND (direct) AND indirect RAM to Acc (A) <-- (A) AND (( Ri )) AND immediate data to Acc (A) <-- (A) AND #data AND Acc to direct byte (direct) <-- (direct) AND (A) AND imm. data to direct byte (direct) <-- (direct) AND #data OR register to Acc (A) <-- (A) OR (Rn) OR direct byte to Acc (A) <-- (A) OR (direct) OR indirect RAM to Acc (A) <-- (A) OR (( Ri )) OR immediate data to Acc (A) <-- (A) OR #data OR Acc to direct byte (direct) <-- (direct) OR (A) OR imm. data to direct byte (direct) <-- (direct) OR #data Exclusive OR register to Acc (A) <-- (A) XOR (Rn) Exclusive OR direct byte to Acc (A) <-- (A) XOR (direct) Exclusive OR indir. RAM to Acc (A) <-- (A) XOR (( Ri )) Exclusive OR imm. data to Acc (A) <-- (A) XOR #data Exclusive OR Acc to direct byte (direct) <-- (direct) XOR (A) Exclusive OR imm.data to dir. byte (direct) <-- (direct ) XOR #data Clear Accumulator (A) <--- #0 Complement A (A) <---( A) Rotate Acc left (An+1)<-(An) n=0-6 (A0) <- (A7) Rotate Acc left with carry (An+1)<-(An) n=0-6 (A0) <- (C) (C) <--(A7) Rotate Acc Right (An)<-(An+1) n=0-6 (A7) <- (A0) Rotate Acc Right with carry (An) <-(An+1) n=0-6 (A7) <- (C) (C) <--(A0) Swap nibbles within the Acc (A3-0) <--> (A7-4)

1 2 1 2 2 3 1 2 1 2 2 3 1 2 1 2 2 3 1 1 1 1 1 1 1

12 12 12 12 12 24 12 12 12 12 12 24 12 12 12 12 12 24 12 12 12 12 12 12 12

SUBB A,direct Subtract direct byte from Acc with SUBB A,@Ri
Subtract indirect RAM from Acc with borrow (A) <-- (A) - ( C ) - ( Ri ) with borrow (A) <-- (A) - ( C ) - #data Increment Accumulator (A) <-- (A) + 1 Increment Register (Rn) <-- (Rn) + 1 Increment Direct byte (direct) <-- (direct) + 1 Increment ndirect RAM (( Ri )) <-- (( Ri )) + 1 Decrement Accumulator (A) <-- (A) - 1 Decrement Register (Rn) <-- (Rn) - 1 Decrement Direct byte (direct) <-- (direct) - 1 Decrement ndirect RAM (( Ri )) <-- (( Ri )) - 1 Increment Data Pointer (DPTR) <-- (DPTR) + 1 Multiply A & B (A) 7-0 (B) 15-8 <-- (A) x (B) Divide A by B (A) <-- (A) / (B) (B) <-- Carry Decimal Adjust Accumulator

SUBB A,#data Subtract immediate data from Acc INC A INC Rn INC direct INC @Ri DEC A DEC Rn DEC direct DEC @Ri INC DPTR MUL AB DIV AB DA A MOV A,Rn MOV A,direct MOV A,@Ri

Data Transfer
Move register to Accumulator (A) <--- (Rn) Move direct byte to Acc. (A) <--- (direct) Move indirect byte to Acc. (A) <--- (( Ri ))

Boolean variable manipulation (Bit)


CLR C CLR bit SETB C
Clear Carry Clear direct bit Set Carry (C) <-- 0 (bit) <-- 0 (C) <-- 1

1 2 1

12 12 12

MOV A,#data MOV Rn,A MOV Rn,direct MOV Rn,#data MOV direct,A MOV direct,Rn MOV direct,direct MOV direct,@Ri MOV direct,#data MOV @Ri,A MOV @Ri,direct MOV @Ri,#data MOV DPTR,#data16 MOVC A,@A+DPTR MOVC A,@A+PC MOVX A,@Ri

Move immediate data to Acc (A) <--- #data Move Accumulator to Register (Rn) <--- (A) Move direct byte to Register (Rn) <--- (direct) Move imm. data to Register (Rn) <--- #data Move Acc. to Direct byte (direct) <--- (A) Move register to direct byte (direct) <--- (Rn) Move direct byte to direct (direct) <--- (direct) Move indirect RAM to direct (direct) <--- (( Ri )) Move imm. data to direct byte (direct) <--- #data Move Acc. to indirect RAM (( Ri )) <--- (A) Move direct byte to indir.RAM (( Ri )) <--- (direct) Move imm. data to indir RAM (( Ri )) <--- #data Move Data Pointer 16 bit constant (DPTR) <--- #data 15-0 Move Relative DPTR to Acc (A) <--- ( (A)+(DPTR) ) Move relative PC to ACC (PC)<- (PC)+1 (A)<--((A)+(PC)) Move External RAM (8 bit addr) to Acc (A) <--- (( Ri )) Acc (A) <--- (( DPTR ))

2 1 2 2 2 2 3 2 3 1 2 2 3 1 1 1 1 1 1 2 2 1 2 1 1

12 12 24 12 12 24 24 24 24 12 24 12 24 24 24 24 24 24 24 24 24 12 12 12 12

SETB bit CPL C CPL bit ANL C,bit ANL C,/bit ORL C,bit ORL C,/bit MOV C,bit MOV bit,C JC rel JNC rel JB bit,rel JNB bit,rel JBC bit,rel

Set direct bit

(bit) <-- 1

2 1 2 2 2 2 2 2 2 2 2 3 3 3

12 12 12 24 24 24 24 12 24 24 24 24 24 24

Complement Carry (C) <-- (C) Complement direct bit (bit) <-- (bit) And direct bit to carry (C) <--- (C) and (bit) And complement of direct bit to carry (C) <--- (C) and (/bit) Or direct bit to carry (C) <--- (C) or (bit) Or complement of direct bit to carry (C) <--- (C) or (/bit) Mov direct bit to carry (C) <--- (bit) Mov carry to direct bit (bit) <--- (C) Jump if carry is set (PC)<-(PC)+2 If C=1 Then (PC) <-- (PC) + rel Jump if carry is not set (PC)<-(PC)+2 If C=0 Then (PC) <-- (PC) + rel Jump if direct bit is set (PC)<-(PC)+3 If bit=1 Then (PC) <-- (PC) + rel Jump if direct bit is not set (PC)<-(PC)+3 If bit=0 Then (PC) <-- (PC) + rel Jump if direct bit is set & clear bit (PC)<-(PC)+3 If bit=1 Then (PC) <-- (PC) + rel (bit) <-- 0

Program Branching
ACALLK addr11 ACALL addr16 RET RETI AJMP addr11 LJMP addr16 SJMP rel JMP A@A+DPTR JZ rel JNZ rel
Absolute Subroutine Call Long Subroutine Call Return from Subroutine Return from Interrupt Absolute Jump Long Jump Short Jump relative addr. Jump indirect relative Jump if Acc is zero Jump if Acc is not zero

MOVX A,@DPTR Mov External RAM (16 bit addr) to MOVX @Ri,A MOVX @DPTR,A PUSH direct POP direct XCH A,Rn XCH A,direct XCH A,@Ri XCHD A,@Ri
Mov Acc to External RAM (8 bit addr) (( Ri )) <-- (A) Mov Acc toExternal RAM (16 bit addr) (( DPTR )) <--- (A) Push direct byte to stack (SP)<--(SP)+1 ((SP))<--(direct) Pop direct byte from stack (direct)<-- ((SP)) (SP)<--(SP)-1 Exchange register with Acc (A) <--> (Rn) Exchange dir.byte with Acc (A) <--> (direct) Exchange ind.RAM with Acc (A) <--> (( Ri )) Exchange register with Acc (A)4-0 <--> ((Ri))4-0

2 3 1 1 2 3 2 1 2 2 3 3 3 3 2 3 1

24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 12

Compare direct byte to Acc and CJNE A,direct,rel jump if not equal

CJNE A,#data,rel CJNE Rn,#data,rel CJNE @Ri,#data,rel DJNZ Rn,rel DJNZ direct,rel NOP

Compare immediate to Acc and jump if not equal Compare immediate to register and jump if not equal Compare immediate to indirect and jump if not equal Decrement register and jump is not zero Decrement direct byte and jump is not zero No operation

1 Machine = 12 Clock

You might also like