8051 Instruction - Set
8051 Instruction - Set
• Immediate
• Register
• Direct
• Register Indirect
• Indexed
• Egs:
MOV A,#65H
MOV R3,#65H
MOV DPTR,#2343H
MOV R0, 40H // copy data from RAM location 40h to register R0
MOV 56H, A // copy value in A to RAM location 56h
MOV A,12H // copy data from RAM location 12h to A
MOVC A,@A+DPTR
A= content of address A +DPTR from ROM
Note:
Because the data elements are stored in the program (code ) space
ROM of the 8051, it uses the instruction MOVC instead of MOV. The
“C” means code.
MOV A, Rn register
MOV A, direct <- content of direct address
MOV A,@Ri <- content of address in Ri
MOV A,#data <- immediate data
DATA TRANSFER INSTRUCTIONS
MOV DPTR,#16 bit data <- load data pointer with 16 bit
constant
MOVC A,@A+DPTR <- code byte at ROM address
formed by(A+DPTR)
MOVC A,@A+PC <- code byte at (A+PC)
It is an indirect addressing mode where the number in
register A is added to the pointing register to form address in
ROM where the desired data is to be found
DATA TRANSFER INSTRUCTIONS
SHORT JUMP(SJMP)
TRANSFERS CONTROL WITHIN 256 BYTES
-128 TO +127 BYTES
EG: SJMP Label
TYPES OF JUMPS
ABSOLUTE JUMP(AJMP)
TRANSFERS CONTROL WITHIN 2KB
EG: AJMP 11 Bit address
TYPES OF JUMPS
LONG JUMP(LJMP)
TRANSFERS CONTROL WITHIN 64KB
EG: LJMP 16 Bit address
CALL INSTRUCTIONS
TYPES OF CALL
ABSOLUTE CALL(ACALL)
LONG CALL(LCALL)
CALL INSTRUCTIONS
PUSH & POP opcodes specifies the direct address of the data
It is a data move instruction from stack to the specified address
Register associated is Stack pointer – contains the internal RAM address where the data
will be pushed
PUSH & POP instructions
PUSH address :
Increment SP by 1 ; SP = SP+1
Copy the address specified in the instruction to the
internal RAM address in SP register
By default SP is set to 07 H (R7 of bank 0)
Eg: PUSH 40H
It would push the data to the address 08H
POP instruction
POP address :
Copy the data from internal RAM address contained in SP
to address specified in the instruction
decrement SP by 1 ; SP = SP-1
E.g.: POP 40H
It would pop the data from the address 08H to the
address 40H
PUSH & POP