Microprocessors and Microcontrollers: Unit III: (b) 8051 Instruction Set and Programming

Data Transfer instructions

8051 Instruction Set and Programming

An immediate, direct, register and indirect addressing modes are used in different MOVE instructions. Table 15.3.1 lists all types of data moving (data transfer) instructions.

Data Transfer instructions

An immediate, direct, register and indirect addressing modes are used in different MOVE instructions. Table 15.3.1 lists all types of data moving (data transfer) instructions.


 

1. Instructions to Access External Data Memory

The Table 15.3.2 explains the instruction to access external data memory.


Important Points to Remember in Accessing External Data Memory

• All external data moves with external RAM involve the A register.

• While accessing external RAM, Rp can address 256 bytes and DPTR can address 64 kbytes.

• MOVX instruction is used to access external RAM or I/O addresses.

 

2. Instructions to Access External ROM/Program Memory

The Table 15.3.3 explains the instructions to access external ROM/program memory.


Important Points to Remember in Accessing External Read Only Memory

• When PC is used to access external ROM, it is incremented by 1 (to point to the next instruction) before it is added to A to form the physical address of external ROM.

• All external data moves with external ROM involve the A register.

• MOVC is used with internal or external ROM and can address 4 K of internal code or 64 K of external code.

• The DPTR and the PC are not changed.

 

3. Data Transfer with Stack (PUSH and POP) Instructions


Important Points to Remember during PUSH and POP

• When the SP contents become FFH, for the next PUSH, the SP rolls over to 00H.

• The top of the internal RAM, i.e. it's end address is 7FH. So next PUSHes after 7FH result in errors.

• Generally the SP is set at address above the register banks.

• The PUSH and POP operations may be applied to the stack pointer (SP).

• When PUSH and POP operations are used for the registers from the register banks (bank 0 - bank 3), specify direct addresses within the instructions. Do not use register name from register bank since the register name does not specify the bank in use.

 

4. Data Exchange Instructions

When 8051 executes MOV, PUSH or POP instruction, the 'copy operation' takes place. The data from the source address is copied to the destination address. The data at the source address remains unchanged. The Exchange instructions move data from source address to destination address and vice versa. Table 15.3.4 lists all types of exchange instructions in 8051.


Important Points to Remember in Exchange Instructions

• All exchanges involve the A register.

• All exchanges take place internally within 8051.

• When XCHD A, @ Ri instruction is executed, the upper nibble of A and the upper nibble of the address in Ri do not change.

• Immediate addressing mode cannot be used in the exchange instructions.

Review Questions

1. Write the I/O related instructions in microcontroller 8051. AU : Dec.-08

2. What is the operation carried out when 8051 executes the instruction MOVC A, @ A + DPTR? AU : Dec.-07

3. Mention the I/O instructions of 8051 microcontroller. AU : Dec.-08 Marks 2 

4. Explain the data transfer instructions and program control instructions of 8051 microcontroller.

AU : May-11, Marks 8

5. Explain the operations carried out when the following instructions are executed by 8051.

i) MOVX @ R0, A

ii) MOVC A,@A + PC

iii) RLC A

iv) CJNE A, 50H, L2

v) XCH A, 30H where L2 and L3 are labels.

AU : Dec.-07, Marks 16


Microprocessors and Microcontrollers: Unit III: (b) 8051 Instruction Set and Programming : Tag: : 8051 Instruction Set and Programming - Data Transfer instructions