Addressing Modes
Addressing Modes
REGISTERS
It performs operations on floating point
numbers.
ALU
• Memory Unit (MU)
It stores the set of instructions.
MU • Registers
Temporary storage area, which holds the
data during the execution of an instruction.
Prerequisite - Registers inside CPU
Accumulator Flag Register / Program Status Word (PSW)
A C S = Sign, Z = Zero, CY = Carry,
A (8-bit) S Z P
AC = Auxiliary Carry, P = Parity,
C Y
B (8-bit) C (8-bit)
H (8-bit) L (8-bit)
PC (16-bit)
Index Registers
SP (16-bit)
Addressing Modes
• Microprocessor executes the instructions stored in memory (RAM).
• It executes one instruction at a time.
• Each of the instruction contains operations and operands.
• Operation specifies the type of action to be performed.
• For example: ADD, SUB, MOV, INC, LOAD, STORE
• Operands are the data on which the operation is to be performed.
B
Addressing Modes
• Operand can be place either in one of the processor register or in
memory.
Add Immediate
ADI 3Eh A ← A + 3Eh Here 3Eh is the immediate operand
2. Register Addressing Mode
• The operand is specified with in one of the processor register.
• Instruction specifies the register in which the operand is stored.
Move
MOV C , A C←A Here A is the operand specified in register
Add
ADD B A← A+B Here B is the operand specified in register
3. Register Indirect Addressing Mode
• The instruction specifies the register in which the memory
address of operand is placed.
• It do not specify the operand itself but its location with in the
memory where operand is placed.
Move
MOV A , M A ← [[H][L]]
Before
After
2807 A A9 2807
2806 2806
H
A 28 2805 A9 H 28 2805 A9
2804 2804
L 05 2803
L 05 2803
2802 2802
2801 2801
A ← [2805] A ← A9
2800 2800
4. Direct Addressing Mode
• The instruction specifies the direct address of the operand.
• The memory address is specified where the actual operand is.
Load Accumulator
LDA 2805h A ← [2805]
It loads the data from memory location 2805 to A.
Store Accumulator
STA 2803h [2803] ← A
It stores the data from A to memory location 2803.
4. Direct Addressing Mode
LDA 2805h A ← [2805]
It loads the data from memory location 2805 to A.
Before After
A 2807 A 5C 2807
2806 2806
2805 5C 2805 5C
A ← [2805] 2804 A ← 5C 2804
2803 2803
2802 2802
2801 2801
2800 2800
4. Direct Addressing Mode
STA 2803h [2803] ← A
It stores the data from A to memory location 2803.
Before After
A 9B 2807 A 9B 2807
2806 2806
2805 2805
[2803] ← A 2804 [2803] ← 9B 2804
2803 2803 9B
2802 2802
2801 2801
2800 2800
5. Indirect Addressing Mode
• The instruction specifies the indirect address where the effective
address of the operand is placed.
• The memory address is specified where the actual address of
operand is placed.
Move
MOV A, 2802h A ← [[2802]]
It moves the data from memory location specified by the location 2802 to A.
5. Indirect Addressing Mode
MOV A, 2802h A ← [[2802]]
It moves the data from memory location specified by the location
2802 to A.
Before After
A 2807 A FF 2807
2806 FF 2806 FF
2805 2805
A ← [[2802]] 2804 A ← FF 2804
2803 06 2803 06
2802 28 2802 28
2801 2801
2800 2800
6. Implied Addressing Mode
• It is also called inherent addressing mode.
• The operand is implied by the instruction.
• The operand is hidden/fixed inside the instruction.
• The address part of the instruction is called as offset and it can +ve
or –ve.
2807 22 2807 22
2806 FF 2806 FF Actual Operand
Offset = 04h 2805 6D 2805 6D
2804 59 2804 59
PC 2801 2803 08 2803 08
2802 2E 2802 2E
2801 F3 2801 F3
2800 9F 2800 9F
• When the base is added to the index register the resultant number is
the memory location where the operand will be placed.
8. Indexed Addressing Mode
Base = 2800h
Effective address of operand = Base + IX
2807 22 2807 22 2807 22 2807 22
2806 FF 2806 FF 2806 FF 2806 FF
2805 6D 2805 6D 2805 6D 2805 6D
2804 59 2804 59 2804 59 2804 59
2803 08 2803 08 2803 08 2803 08
2802 2E 2802 2E 2802 2E 2802 2E
2801 F3 2801 F3 2801 F3 2801 F3
2800 9F 2800 9F 2800 9F 2800 9F
• It is similar to the indexed addressing mode except the register now is called as base
instead of index.
• When the offset is added to the base register the resultant number is the memory
location where the operand will be placed.
9. Base Register Addressing Mode
Offset= 0001h
Effective address of operand = Base Register + offset
2807 22 2807 22 2807 22 2807 22
2806 FF 2806 FF 2806 FF 2806 FF
2805 6D 2805 6D 2805 6D 2805 6D
2804 59 2804 59 2804 59 2804 59
2803 08 2803 08 2803 08 2803 08
2802 2E 2802 2E 2802 2E 2802 2E
2801 F3 2801 F3 2801 F3 2801 F3
2800 9F 2800 9F 2800 9F 2800 9F
2800h + 0001h = 2801h 2801h + 0001h = 2802h 2802h + 0001h = 2803h 2803h + 0001h = 2804h
9. Base Register Addressing Mode
Offset= 0003h
Effective address of operand = Base Register + offset
2807 22 2807 22 2807 22 2807 22
2806 FF 2806 FF 2806 FF 2806 FF
2805 6D 2805 6D 2805 6D 2805 6D
2804 59 2804 59 2804 59 2804 59
2803 08 2803 08 2803 08 2803 08
2802 2E 2802 2E 2802 2E 2802 2E
2801 F3 2801 F3 2801 F3 2801 F3
2800 9F 2800 9F 2800 9F 2800 9F
2800h + 0003h = 2803h 2801h + 0003h = 2804h 2802h + 0003h = 2805h 2803h + 0003h = 2806h
10. Autoincrement or Autodecrement Addressing Mode
At start: HL 2802
At start: HL 2803
500 800
800 300
Example problem
Address Memory
PC 200 200 Load to AC Mode 1. Immediate Addressing Mode
201 Address = 500
R1 400 • As instruction contains immediate number 500.
202 Next Instruction
• It is stored as address 201.
XR 100
399 450
AC 400 700 Effective Address = 201
Operand = 500
500 800
AC 500
600 900
702 325
800 300
Example problem
Address Memory
PC 200 200 Load to AC Mode 2. Register Addressing Mode
201 Address = 500
R1 400 • Register R1 contains 400.
202 Next Instruction
• As operand is in register so no any memory location.
XR 100
399 450
AC 400 700 Effective Address = Nil
Operand = 400
500 800
AC 400
600 900
702 325
800 300
Example problem
Address Memory
PC 200 200 Load to AC Mode 3. Register Indirect Addressing Mode
201 Address = 500
R1 400 • Register R1 contains 400.
202 Next Instruction
• So effective address of operand is 400.
XR 100 • The data stored at 400 is 700.
399 450
AC 400 700
Effective Address = 400
500 800
Operand = 700
AC 700
600 900
702 325
800 300
Example problem
Address Memory
PC 200 200 Load to AC Mode 4. Direct Addressing Mode
201 Address = 500
R1 400 • Instruction contains the address 500.
202 Next Instruction
• So effective address of operand is 500.
XR 100 • The data stored at 500 is 800.
399 450
AC 400 700
Effective Address = 500
500 800
Operand = 800
AC 800
600 900
702 325
800 300
Example problem
Address Memory
PC 200 200 Load to AC Mode 5. Indirect Addressing Mode
201 Address = 500
R1 400 • Instruction contains the address 500.
202 Next Instruction
• Address at 500 is 800.
XR 100 • So effective address of operand is 800.
399 450 • The data stored at 800 is 300.
AC 400 700
600 900
AC 300
702 325
800 300
Example problem
Address Memory
PC 200 200 Load to AC Mode 6. Relative Addressing Mode
201 Address = 500
R1 400 • PC = 200.
202 Next Instruction
• Offset = 500.
XR 100 • Instruction is of 2 bytes.
399 450 • So effective address = PC + 2 + offset = 200 + 500 +2 =
AC 400 700 702 .
• The data stored at 702 is 325.
500 800
702 325
AC 325
800 300
Example problem
Address Memory
PC 200 200 Load to AC Mode 7. Index Addressing Mode
201 Address = 500
R1 400 • XR = 100.
202 Next Instruction
• Base = 500.
XR 100 • So effective address = Base + XR = 500 + 100 = 600 .
399 450 • The data stored at 600 is 900.
AC 400 700
600 900
AC 900
702 325
800 300
Example problem
Address Memory
PC 200 200 Load to AC Mode 8. Autoincrement Addressing Mode
201 Address = 500
R1 400 • It is same as register indirect addressing mode except
202 Next Instruction
the contents of R1 are incremented after the execution.
XR 100 • R1 contains 400.
399 450 • So effective address of operand is 400.
AC 400 700 • The data stored at 400 is 700.
500 800
Effective Address = 400
Operand = 700
600 900
R1 401
702 325
AC 700
800 300
Example problem
Address Memory
PC 200 200 Load to AC Mode 9. Autodecrement Addressing Mode
201 Address = 500
R1 400 • It is same as register indirect addressing mode except
202 Next Instruction
the contents of R1 are decremented before the
XR 100
execution.
399 450 • R1 contains 400.
AC 400 700 • R1 is first decremented to 399.
• So effective address of operand is 399.
• The data stored at 399 is 450.
500 800