Addressing Mode
Addressing Mode
Instruction Format
Effective address (EA) : EA is the actual address of the operand , where it is actually stored.
Types of Addressing modes :
1. Implied /Implicit Addressing mode
2. Immediate Addressing Mode
3. Direct Addressing Mode
4. Indirect Addressing Mode
5. Register Direct Addressing Mode
6. Register Indirect Addressing Mode
7. Indexed Addressing Mode
8. Relative Addressing Mode
1. Implied /Implicit Addressing mode:
Examples
CMA :Complement Accumulator
Operand in Ac is implied in the definition of the instruction
Advantages
• Address field of instruction uses fewer bits to select a memory address
• Large address space :
• One fewer memory access than indirect addressing
Disadvantages
Extra memory reference
Register Indirect Addressing Mode
7. Indexed Addressing Mode
Register = Index register
The content of index Register is added to the address part of the instruction to obtain the
effective address of operand .
Effective address = Content of XR + Address part of instruction
EA = A + (XR) or EA = A+ (
o A contains a constant value in the instruction
o XR/
Index register used here is either a special CPU register (XR) provided for this purpose or
commonly , it may be anyone of a set of general register (
Example : ADD R1,20(R2) // R1 R1 + M {20+R1}
ADD R1, 100(XR) // R! R1 + M{100+ XR}
Indexed Addressing Mode
8. Relative Addressing Mode
Register = Program Counter (PC) {PC keeps the address of the next register}
The content of PC is added to the address part of the instruction to obtain the
effective address of operand .
Effective address = Content of PC + Address part of instruction
EA =(PC)+ A i.e. the operand is A bytes away from current location pointed
by PC .
Example
LOAD $A or LOAD A(PC) // AC M[PC + A]
Address location is relative to “PC”, this is called Relative Mode.
Relative Addressing Mode
Example Q. For each possible mode we calculate the effective
address and the operand that must be loaded into AC.
PC 200
Address Memory • The two word instruction at address 200 and 201 is
R1 400 “load to AC”instruction with an address field equal to
200 Load to AC Mode
XR 100 500.
201 Address = 500
AC 202 Next Instruction • The first word of the instruction specifies the
operation code and mode , and the second word
PC = Program Counter specifies the address part.
399 450
R1 = Register
400 700 • PC has the value 200 , for fetching this instruction .
XR = Index Register
AC = Accumulator The content of processor register R1 is 400 , and the
500 800 content of an index register XR is 100.
702 325 • The mode field of the instruction can specify any one
of a number of modes.
800 300
Example
1. Immediate Addressing Mode
• (Operand value in address field )
PC 200
Address Memory
R1 400
200 Load to AC Mode
• As instruction contains immediate number 500.
XR 100 • It is stored as address 201.
201 Address = 500
AC 202 Next Instruction
Effective Address = 201
PC = Program Counter 399 450 Operand = 500
R1 = Register
400 650
XR = Index Register
AC = Accumulator AC 500
500 800
600 900
702 325
800 310
Example
2. Direct Addressing Mode ( Address field contains the effective address)
600 900
702 325
800 310
Example
3. Indirect Addressing Mode (Address field specifies the address where the effective address of operand is
stored in memory)
Address Memory • Instruction contains the address 500.
PC 200 200 Load to AC Mode • Address at 500 is 800.
• So effective address of operand is 800.
201 Address = 500
R1 400 • The data stored at 800 is 300.
202 Next Instruction
Effective Address = 800
XR 100
Operand = 300
399 450
AC 400 650
AC 300
500 800
600 900
702 325
800 310
Example
4. Register Addressing Mode ( Register contains operand )
PC 200
Address Memory
R1 400
200 Load to AC Mode • The operand is in R1 and 400 is loaded in AC
XR 100 • AC = 400
201 Address = 500
AC • There is no effective address in this case .
202 Next Instruction
600 900
702 325
800 310
Example
5. Register Indirect Addressing Mode (Register contains effective address of operand )
PC 200
Address Memory
R1 400
200 Load to AC Mode • Register R1 contains 400.
XR 100 • So effective address of operand is 400.
201 Address = 500
AC • The data stored at 400 is 650.
202 Next Instruction
600 900
702 325
800 310
Example
6. Relative Addressing Mode ( PC is added to address part )
Address Memory
PC 200 Load to AC Mode
• PC = 200.
200
• Offset = 500.
201 Address = 500
R1 400 • Instruction is of 2 bytes.
202 Next Instruction • So effective address = PC + 2 + offset = 200 + 500 +2 =
XR 100 702 .
399 450 • The data stored at 702 is 325.
AC 400 650
600 900
AC 325
702 325
800 310
Example
7. Index Addressing Mode (Index Register is added to address part)
Address Memory
PC 200 Load to AC Mode
• XR = 100.
200
• Base = 500.
201 Address = 500
R1 400 • So effective address = Base + XR = 500 + 100 = 600 .
202 Next Instruction • The data stored at 600 is 900.
XR 100
399 450
AC 400 650 Effective Address = 600
Operand = 900
500 800
AC 900
600 900
702 325
800 310