Lecture 9: Addressing Modes
Addressing modes refers to the way in which the
operand of an instruction is specified.
The addressing mode specifies a rule for interpreting or
modifying the address field of the instruction before the
operand is actually executed.
It also shows how the operand should be accessed
Addressing modes
Immediate addressing.
Direct addressing
Indirect addressing
Register addressing
Register indirect addressing
Displacement addressing
Stack or zero addressing
Immediate addressing mode
In this mode an operand is part of an instruction
and can be used to define and use constants or set
initial values of variables
For example Z = 1 or ADDI AC, 07 which adds the
constant 7 to the contents of the accumulator
The instruction in memory is stored as follows:
Immediate addressing mode
No memory reference apart from the instruction factor required to
obtain the operand.
Advantages
• No memory reference to fetch the operand (operation data)
• Very fast evaluation
Disadvantages
• Only used for constants
• Constants are limited in size
Direct addressing mode
The address field contains the effective address of the operands. It only
requires one memory reference.
Direct Addressing mode
Example
Presentation in memory
Examples of direct addressing mode
statements
MOV DL, [2400]
MOV [3518], AL
MOV AX, 44H
MOV AX, ‘AB’
Advantages of Direct addressing
mode
• There is just one memory reference
• Performance is faster than in indirect mode
Disadvantages
• Performance is slower than immediate addressing
mode
• The length of the address field is less than the word
size
Indirect addressing mode
The address part of n instruction points to a memory
location address
The memory location address points to a memory
location where the operand is stored
Indirect addressing mode
Example of Indirect addressing
LOAD R1, @ 100
Load the content of memory address stored at memory
address 100 to register R1
Before Execution
R1 M[100] M[200]
--- 200 10
After execution of the instruction
LOAD R1, @ 100
R1 200 [10]
10 200 10
Advantages and disadvantages
Advantage
Word length has an address space of 2 n
Disadvantage
Instruction execution requires memory reference to fetch the
operands and to get the value of the operand.
Register addressing mode
This approach is similar to direct addressing.
The only difference is that the address field refers to the
register rather than a memory address.
An address field that references a register will have
three four , five, six or bits so that the total of eight,
sixteen, thirty- two or 64 general purpose registers can
be referenced
Diagram
8 bit and 16 bit registers
This is the most common form of data addressing. And
used with microprocessors.
Microprocessor contains the following 8-bit registers:
AH, AL, BH, BL,CH, CL, DH, and DL and the following 16-
bit registers:
AX, BX, CX, DX, SP, BP, SI, and DI. The 80386
micropressors uses the following 32-bit registers:
Microprocessor 80386 32-bit
registers
Examples of commands
MOV AX, 0
MOV BX,10
MOV CX, 5
MUL AX, BX
Advantages and disadvantages
Advantages
• High performance
• Only a small field is needed in the instruction.
• No memory references are required.
Disadvantage
• Address space is limited
Register indirect addressing
Operation
In operation, it is similar to direct addressing.
The only difference is that the address field refers to a
memory location or a register.
Advantages and disadvantages
Register indirect addressing has the same advantages
and disadvantages as the indirect addressing
Examples of commands
LDR R2, [R0] Comment: Load R2 with a value pointed to by R0
STR R2, [R3] Comment: Store the value pointed to by R3 in R2
LDR R0, [R1, #20] Comment: Load the value pointed to by R1 + 20 in
R0
Advantages and disadvantages
The advantages and disadvantages of Indirect addressing also apply to
this mode of addressing
Displacement Addressing mode
This addressing mode is also Indexed addressing mode
Displacement address mode
• The effective address of the operand is calculated by
adding a constant value to the contents of a register
• The address can be in a register specially for this
purpose or any of the common general purpose
registers
• In either case the register is called an index register
Example of commands
Move X (R0), R1
Comment: Contents at address X+R0 are moved to R1 .
X contains a constant value.
Move (R0, R1), R2
Contents at address R0+R1 are moved to R2.