0% found this document useful (0 votes)
11 views7 pages

Mod 21

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1/ 7

Addressing Modes

Generating Memory Addresses


 How to specify the address of branch target?
 Can we give the memory operand address directly in a single

Add instruction in the loop?


 Use a register to hold the address of NUM1; then increment

by 4 on each pass through the loop.


 The different ways in which the operand and address of the

operand are specified in the instruction are referred to as


“addressing modes”.
Addressing Modes

Opcode Mode ...

 Immediate mode
 The operand is given explicitly in the instruction
 The use of a constant in “MOVE #5,R1 ”,
i.e. R1 ← 5
 Register mode
 The operand is the content of a processor register
 The name (address) of register is given in the instruction.
 MOVE R1,R2
Addressing Modes
 Direct
mode
The operand is in the memory location and the address of the

location is given explicitly in the instruction.


Ex: MOVE R1, LOC
A=B+6
Move B,R1
Add #6,R1
Move R1,A
Addressing Modes
 Indirect mode
The effective address of the operand is
the contents of a register or memory
location whose address appears in the
instruction.

Indicate the register that holds the address of the


memory location that holds the data

ADD (R1), R0
Addressing Modes
Indirect mode

Indicate the memory location that holds the


address of the memory location that holds the
data.
 Addition of N numbers using indirect addressing mode.
Move N,R1
MOVE #NUM1,R2
CLEAR R0
LOOP ADD (R2),R0
ADD #4,R2
DEC R1
BRANCH>0 LOOP
MOVE R0,SUM

You might also like