Instruction Set in 8051 Microcontroller
Instruction Set in 8051 Microcontroller
1. Arithmetic instructions
2. Branch 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
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
DIV AB Divides A by B 1 5
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
JBC bit,rel Jump if direct bit is set and clears bit. Short jump. 3 4
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.
MOVC Moves the code byte relative to the DPTR to the accumulator
1 3
A,@A+DPTR (address=A+DPTR)
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
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
ANL
AND immediae data to direct register 3 4
direct,#data
ORL
OR immediate data to direct byte 3 4
direct,#data
XORL
Exclusive OR immediate data to direct byte 3 4
direct,#data
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