0% found this document useful (0 votes)
20 views31 pages

MPMC - 3.2 8051 Addressing Modes - 1

qvdvqevqvqe

Uploaded by

Harish
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views31 pages

MPMC - 3.2 8051 Addressing Modes - 1

qvdvqevqvqe

Uploaded by

Harish
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 31

3.

2 8051 Addressing modes

3.2 8051 Addressing modes

Module:3 Microcontroller Architecture: Intel 8051


Course: BECE204L – Microprocessors and Microcontrollers
3.2 8051 Addressing modes

Module:3 Microcontroller Architecture:


Intel 8051

• Microcontroller 8051 - Organization and Architecture, RAM-ROM


Organization, Machine Cycle, Addressing modes, Instruction set:
Data Processing - Stack, Arithmetic, Logical; Branching –
Unconditional and Conditional, Assembly programming.

Mohammad Ali Mazidi, Janice G. Mazidi, Rolin D. McKinlay, The 8051 Microcontroller and
Embedded Systems, 2014, 2nd Edition, Pearson, India.
3.2 8051 Addressing modes

1. Addressing Modes
• Addressing mode is a way to address an operand. Operand means
the data we are operating upon.
• There are five major addressing modes available in the 8051:
– Immediate
– Direct
– Register
- Register indirect
– Indexed
3.2 8051 Addressing modes

1. Addressing Modes
a. IMMEDIATE ADDRESSING MODE
• Operand is the data
• Opcode+Operand

• This addressing mode is named as “immediate” because it transfers an 8-


bit data immediately to the accumulator (destination operand).
• In general we can write MOV A, #data.
MOV A, #6AH

• The ‘#’ symbol (immediate addressing) before 6AH indicates that


operand is a data (8 bit).

If „#‟ is not present then the hexadecimal number would be taken as
address.
3.2 8051 Addressing modes

1. Addressing Modes
a. IMMEDIATE ADDRESSING MODE
3.2 8051 Addressing modes

1. Addressing Modes
a. IMMEDIATE ADDRESSING MODE
• The opcode for MOV A, # data is 74H.
The opcode is saved in program memory at 0202 address.
The data 6AH is saved in program memory 0203.
• When the opcode 74H is read, the next step taken would be to
transfer whatever data at the next program memory address
(here at 0203) to accumulator A (E0H is the address of
accumulator).
• This instruction is of two bytes. So after the execution of this
instruction, program counter will add 2 and move to 0204 of program
memory.
• This instruction is executed in one cycle
3.2 8051 Addressing modes

1. Addressing Modes
a. IMMEDIATE ADDRESSING MODE
3.2 8051 Addressing modes

1. Addressing Modes
a. IMMEDIATE ADDRESSING MODE
3.2 8051 Addressing modes

1. Addressing Modes
b. DIRECT ADDRESSING MODE
• Direct address is specified in the instruction
• Here the address of the data (source data ) is given as operand.
Lets take an example.
MOV A, 04H
• Here 04H is the address of register 4 of register bank#0.
When this instruction is executed, what ever data is stored in
register 04H is moved to accumulator.
• In the figure register 04H holds the data 1FH. So the data 1FH is
moved to accumulator.
3.2 8051 Addressing modes

1. Addressing Modes
b. DIRECT ADDRESSING MODE
3.2 8051 Addressing modes

1. Addressing Modes
b. DIRECT ADDRESSING MODE
• The opcode for instruction MOV A, address is E5H.
When the instruction at 0202 is executed (E5H),
accumulator is made active and ready to receive data.
• Then program control goes to next address that is 0203 and
look up the address of the location (04H) where the source data
(to be transferred to accumulator) is located.
• At 04H the control finds the data 1F and transfers it to accumulator
and hence the execution is completed.
3.2 8051 Addressing modes

1. Addressing Modes
b. DIRECT ADDRESSING MODE
3.2 8051 Addressing modes

1. Addressing Modes
b. DIRECT ADDRESSING MODE
3.2 8051 Addressing modes

Moving data to SFRs


3.2 8051 Addressing modes
3.2 8051 Addressing modes
3.2 8051 Addressing modes

1. Addressing Modes
c. REGISTER ADDRESSING MODE
• In this addressing mode we use the register name directly one of the
eight registers (as source operand). At a time registers can take value
from R0,R1…to R7.An example is shown below.
MOV A, R4 , ORL A, R3

Opcode Rn

• In register direct addressing mode, data is transferred


from the register (based on which register bank is selected)
to accumulator.
• PSW.3 and PSW.4bits are known as register bank select bits as they
are used to select register banks.
• On reset ,default reg.bank is Bank 0
3.2 8051 Addressing modes

1. Addressing Modes
c. REGISTER ADDRESSING MODE
3.2 8051 Addressing modes

1. Addressing Modes
c. REGISTER ADDRESSING MODE
3.2 8051 Addressing modes

1. Addressing Modes
c. REGISTER ADDRESSING MODE
3.2 8051 Addressing modes

1. Addressing Modes
d. REGISTER INDIRECT ADDRESSING MODE
• Instruction performs an operation on the data whose address is
contained in the register R0 and R1
• In this addressing mode, address of the data (source data to
transfer) is given in the register operand.
MOV A, @R0
• Here the value inside R0 is considered as an address,
which holds the data to be transferred to accumulator
• If R0 holds the value 20H, and
we have a data 2F H stored at the address 20H,
then the value 2FH will get transferred to accumulator after
executing this instruction.
3.2 8051 Addressing modes

1. Addressing Modes
d. REGISTER INDIRECT ADDRESSING MODE
3.2 8051 Addressing modes

1. Addressing Modes
d. REGISTER INDIRECT ADDRESSING MODE
• The opcode for MOV A, @R0 is E6H.
Assuming that register bank #0 is selected.
So the R0 of register bank #0 holds the data 20H.
• Program control moves to 20H
where it locates the data 2FH and
it transfers 2FH to accumulator.
• This is a single byte instruction and
the program counter increments 1 and moves to 0203 of
program memory.
• Only R0 and R1 (of All register banks) are allowed to form a
register indirect addressing instruction..
3.2 8051 Addressing modes
3.2 8051 Addressing modes
3.2 8051 Addressing modes
3.2 8051 Addressing modes
3.2 8051 Addressing modes

1. Addressing Modes
e. INDEXED ADDRESSING MODE
MOVC A, @A+DPTR and MOVC A, @A+PC
• where DPTR is data pointer and PC is program counter
(both are 16 bit registers).
• The source operand is @A+DPTR and
we will get the location of the source data (to transfer).

• It is nothing but adding contents of DPTR with present content of


accumulator. This addition will result a new data which is taken as
the address of source data (to transfer).
• The data at this address is then transferred to accumulator.
3.2 8051 Addressing modes

1. Addressing Modes
e. INDEXED ADDRESSING MODE
3.2 8051 Addressing modes

1. Addressing Modes
e. INDEXED ADDRESSING MODE
• The opcode for the instruction is 93H.
DPTR holds the value 01FE, where 01 is located in DPH (higher 8 bits)
and FE is located in DPL (lower 8 bits).
• Accumulator now has the value 02H.
A 16 bit addition is performed and
now 01FE H+02 H results in 0200 H.
• What ever data is in address 0200 H will get transferred to
accumulator.
• The previous value inside accumulator (02H) will get replaced with new
data from 0200H. New data in the accumulator is shown in dotted line
box.
3.2 8051 Addressing modes

1. Addressing Modes
e. INDEXED ADDRESSING MODE
• This is a 1 byte instruction with 2 cycles needed for execution.
So, the execution time required for this instruction is high compared to
other addressing modes (which all were 1 cycle).
• The other example MOVC A, @A+PC works the same way as above
example.
The only difference is, instead of adding DPTR with accumulator, here
data inside program counter (PC) is added with accumulator to
obtain the target address

You might also like