0% found this document useful (0 votes)
353 views

Instruction Set in 8051 Microcontroller

The document summarizes the instruction set of the 8051 microcontroller. It describes 5 categories of instructions: arithmetic, branch, data transfer, logical, and bit-oriented. The arithmetic instructions perform operations like addition, subtraction, multiplication, and division. The branch instructions include unconditional jumps, conditional jumps, and subroutine calls. The data transfer instructions move data between registers and memory.

Uploaded by

Ajnamol N R
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
353 views

Instruction Set in 8051 Microcontroller

The document summarizes the instruction set of the 8051 microcontroller. It describes 5 categories of instructions: arithmetic, branch, data transfer, logical, and bit-oriented. The arithmetic instructions perform operations like addition, subtraction, multiplication, and division. The branch instructions include unconditional jumps, conditional jumps, and subroutine calls. The data transfer instructions move data between registers and memory.

Uploaded by

Ajnamol N R
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Instruction Set in 8051 Microcontroller

1. Arithmetic instructions

2. Branch Instructions

3. Data Transfer Instructions

4. Logical Instructions

5. Bit-oriented Instructions

Arithmetic Instructions
Arithmetic instructions perform several basic operations such as addition, subtraction, division,
multiplication etc. After execution, the result is stored in the first operand.

Arithmetic Instructions

Mnemonic Description Byte Cycle

ADD A,Rn Adds the register to the accumulator 1 1

ADD
Adds the direct byte to the accumulator 2 2
A,direct

ADD
Adds the indirect RAM to the accumulator 1 2
A,@Ri

ADD
Adds the immediate data to the accumulator 2 2
A,#data

ADDC
Adds the register to the accumulator with a carry flag 1 1
A,Rn

ADDC Adds the direct byte to the accumulator with a carry


2 2
A,direct flag

ADDC Adds the indirect RAM to the accumulator with a


1 2
A,@Ri carry flag

ADDC Adds the immediate data to the accumulator with a


2 2
A,#data carry flag

SUBB Subtracts the register from the accumulator with a


1 1
A,Rn borrow

SUBB Subtracts the direct byte from the accumulator with a


2 2
A,direct borrow

SUBB Subtracts the indirect RAM from the accumulator


1 2
A,@Ri with a borrow
SUBB Subtracts the immediate data from the accumulator
2 2
A,#data with a borrow

INC A Increments the accumulator by 1 1 1

INC Rn Increments the register by 1 1 2

INC Direct Increments the direct byte by 1 2 3

INC @Ri Increments the indirect RAM by 1 1 3

DEC A Decrements the accumulator by 1 1 1

DEC Rn Decrements the register by 1 1 1

DEC Direct Decrements the direct byte by 1 1 2

DEC @Ri Decrements the indirect RAM by 1 2 3

INC DPTR Increments the Data Pointer by 1 1 3

MUL AB Multiplies A and B 1 5

DIV AB Divides A by B 1 5

Decimal adjustment of the accumulator according to


DA A 1 1
BCD code

Branch Instructions

There are two kinds of branch instructions:

Unconditional jump instructions: upon their execution a jump to a new location from where the program continues execution is
executed.

Conditional jump instructions: a jump to a new program location is executed only if a specified condition is met. Otherwise, the
program normally proceeds with the next instruction.

Branch Instructions

Mnemonic Description Byte Cycle

ACALL addr11 Absolute subroutine call 2 6

LCALL addr16 Long subroutine call 3 6

RET Returns from subroutine 1 4


RETI Returns from interrupt subroutine 1 4

AJMP addr11 Absolute jump 2 3

LJMP addr16 Long jump 3 4

Short jump (from –128 to +127 locations relative to the


SJMP rel 2 3
following instruction)

JC rel Jump if carry flag is set. Short jump. 2 3

JNC rel Jump if carry flag is not set. Short jump. 2 3

JB bit,rel Jump if direct bit is set. Short jump. 3 4

JBC bit,rel Jump if direct bit is set and clears bit. Short jump. 3 4

JMP @A+DPTR Jump indirect relative to the DPTR 1 2

JZ rel Jump if the accumulator is zero. Short jump. 2 3

JNZ rel Jump if the accumulator is not zero. Short jump. 2 3

Compares direct byte to the accumulator and jumps if not equal.


CJNE A,direct,rel 3 4
Short jump.

Compares immediate data to the accumulator and jumps if not


CJNE A,#data,rel 3 4
equal. Short jump.

Compares immediate data to the register and jumps if not equal.


CJNE Rn,#data,rel 3 4
Short jump.

CJNE Compares immediate data to indirect register and jumps if not


3 4
@Ri,#data,rel equal. Short jump.

DJNZ Rn,rel Decrements register and jumps if not 0. Short jump. 2 3

DJNZ Direct,rel Decrements direct byte and jump if not 0. Short jump. 3 4

NOP No operation 1 1
Data Transfer Instructions

Data transfer instructions move the content of one register to another. The register the content of which is moved remains
unchanged. If they have the suffix “X” (MOVX), the data is exchanged with external memory.

Data Transfer Instructions

Mnemonic Description Byte Cycle

MOV A,Rn Moves the register to the accumulator 1 1

MOV A,direct Moves the direct byte to the accumulator 2 2

MOV A,@Ri Moves the indirect RAM to the accumulator 1 2

MOV A,#data Moves the immediate data to the accumulator 2 2

MOV Rn,A Moves the accumulator to the register 1 2

MOV Rn,direct Moves the direct byte to the register 2 4

MOV Rn,#data Moves the immediate data to the register 2 2

MOV direct,A Moves the accumulator to the direct byte 2 3

MOV direct,Rn Moves the register to the direct byte 2 3

MOV direct,direct Moves the direct byte to the direct byte 3 4

MOV direct,@Ri Moves the indirect RAM to the direct byte 2 4

MOV direct,#data Moves the immediate data to the direct byte 3 3

MOV @Ri,A Moves the accumulator to the indirect RAM 1 3

MOV @Ri,direct Moves the direct byte to the indirect RAM 2 5

MOV @Ri,#data Moves the immediate data to the indirect RAM 2 3

MOV DPTR,#data Moves a 16-bit data to the data pointer 3 3

MOVC Moves the code byte relative to the DPTR to the accumulator
1 3
A,@A+DPTR (address=A+DPTR)

Moves the code byte relative to the PC to the accumulator


MOVC A,@A+PC 1 3
(address=A+PC)
MOVX A,@Ri Moves the external RAM (8-bit address) to the accumulator 1 3-10

MOVX A,@DPTR Moves the external RAM (16-bit address) to the accumulator 1 3-10

MOVX @Ri,A Moves the accumulator to the external RAM (8-bit address) 1 4-11

MOVX @DPTR,A Moves the accumulator to the external RAM (16-bit address) 1 4-11

PUSH direct Pushes the direct byte onto the stack 2 4

POP direct Pops the direct byte from the stack/td> 2 3

XCH A,Rn Exchanges the register with the accumulator 1 2

XCH A,direct Exchanges the direct byte with the accumulator 2 3

XCH A,@Ri Exchanges the indirect RAM with the accumulator 1 3

Exchanges the low-order nibble indirect RAM with the


XCHD A,@Ri 1 3
accumulator

Logical Instructions

Logic instructions perform logic operations upon corresponding bits of two registers. After execution, the result is stored in the
first operand.

Logic Instructions

Mnemonic Description Byte Cycle

ANL A,Rn AND register to accumulator 1 1

ANL A,direct AND direct byte to accumulator 2 2

ANL A,@Ri AND indirect RAM to accumulator 1 2

ANL A,#data AND immediate data to accumulator 2 2

ANL direct,A AND accumulator to direct byte 2 3

ANL
AND immediae data to direct register 3 4
direct,#data

ORL A,Rn OR register to accumulator 1 1

ORL A,direct OR direct byte to accumulator 2 2


ORL A,@Ri OR indirect RAM to accumulator 1 2

ORL direct,A OR accumulator to direct byte 2 3

ORL
OR immediate data to direct byte 3 4
direct,#data

XRL A,Rn Exclusive OR register to accumulator 1 1

XRL A,direct Exclusive OR direct byte to accumulator 2 2

XRL A,@Ri Exclusive OR indirect RAM to accumulator 1 2

XRL A,#data Exclusive OR immediate data to accumulator 2 2

XRL direct,A Exclusive OR accumulator to direct byte 2 3

XORL
Exclusive OR immediate data to direct byte 3 4
direct,#data

CLR A Clears the accumulator 1 1

CPL A Complements the accumulator (1=0, 0=1) 1 1

SWAP A Swaps nibbles within the accumulator 1 1

RL A Rotates bits in the accumulator left 1 1

RLC A Rotates bits in the accumulator left through carry 1 1

RR A Rotates bits in the accumulator right 1 1

RRC A Rotates bits in the accumulator right through carry 1 1

Bit-Oriented Instructions

Similar to logic instructions, bit-oriented instructions perform logic operations. The difference is that these are performed upon
single bits.

Bit-oriented Instructions

Mnemonic Description Byte Cycle

CLR C Clears the carry flag 1 1


CLR bit Clears the direct bit 2 3

SETB C Sets the carry flag 1 1

SETB bit Sets the direct bit 2 3

CPL C Complements the carry flag 1 1

CPL bit Complements the direct bit 2 3

ANL C,bit AND direct bit to the carry flag 2 2

ANL C,/bit AND complements of direct bit to the carry flag 2 2

ORL C,bit OR direct bit to the carry flag 2 2

ORL C,/bit OR complements of direct bit to the carry flag 2 2

MOV C,bit Moves the direct bit to the carry flag 2 2

MOV bit,C Moves the carry flag to the direct bit 2 3

You might also like