Presentation is loading. Please wait.

Presentation is loading. Please wait.

8051 Addressing Modes The way, using which the data source or destination addresses are specified in the instruction mnemonic for moving the data, is.

Similar presentations


Presentation on theme: "8051 Addressing Modes The way, using which the data source or destination addresses are specified in the instruction mnemonic for moving the data, is."— Presentation transcript:

1 8051 Addressing Modes The way, using which the data source or destination addresses are specified in the instruction mnemonic for moving the data, is called “Addressing Mode”. 8051 has the following addressing modes: 1) Register Addressing Mode 2) Direct Byte Addressing Mode 3) Register Indirect Addressing Mode 4) Immediate Addressing Mode 5) Register Specific Addressing Mode 6) Index Addressing Mode 7) Stack Addressing Mode

2 Register Addressing The 8051 can access eight “working registers” (R0-R7). Three bit code within the instruction selects one of the eight registers from the selected register bank. The programmer can select a register bank by modifying bits 4 and 3 in the PSW. Destination Register Source Example: Step 1: Select register bank MOV PSW, # B Step 2: Add the contents of R3 and R4 MOV A,R3 MOV B,R4 ADD R3,R4

3 Direct Byte Addressing
Direct addressing can access any on – chip variable or hardware register. i.e. on-chip RAM and special function register. The most significant bit of the address decides whether it is a location within on-chip RAM (MSB = 0) or in special function register (MSB=1). Memory Destination Register Data From Selected Location Address of Memory Within the Instruction Example: MOV A, 50H ADD A, 51H

4 Register Indirect Addressing
In this addressing mode R0 and R1 of each register bank can be used as an index or pointer register. R0 and R1 point to the contents in the RAM. The Instruction with indirect addressing uses the Sign. Indirect addressing accesses data in dynamic manner rather than static Manner. Looping is not possible in direct addressing mode In indirect addressing we can increment the index or pointer register to access successive locations.

5 Example: MOV A, @R0 ADD A, @R1 Memory Destination Register Data From
Selected Location Register Contents of registers are used to point memory Example: MOV ADD

6 Immediate Addressing In this addressing mode source operand is a constant rather than a variable. So the constant can be incorporated in the instruction. Sign “#” indicates it is a immediate addressing mode. Destination Register Data Specified In the instruction Example: MOV A, #52

7 Register Specific Inherent in the instruction, these refers to a specific register such as accumulator or DPTR. Example: SWAP A

8 Index Only program memory can be accessed in the index addressing.
Either the DPTR or PC can be used as an index register. Example: MOVC

9 + DPTR Register Program Memory Contents of DPTR Register A Register
Data From Selected Memory Address of Memory Contents of Register A

10 Stack Addressing Mode It is subtype of direct addressing mode in which stack instructions (PUSH and POP) are used. Instruction such as ‘PUSH A’ is invalid. Here, we have to specify the address of register A. thus, PUSH 0E0H is a valid instruction; it pushes/stores the contents of accumulator on the stack. Example: PUSH 04 PUSH 06 POP 02 POP OFOH


Download ppt "8051 Addressing Modes The way, using which the data source or destination addresses are specified in the instruction mnemonic for moving the data, is."

Similar presentations


Ads by Google