Wednesday, January 2, 2013

ADDRESSING MODES


Addressing modes:

The different ways in which the location of an operand is specified in an instruction are referred to as addressing modes. The term "addressing mode" can be interpreted in two ways: either "effective address calculation mode" or "operand accessing mode". Effective address (EA) is the address where the operand is actually located. Addressing modes have direct impact on the instruction count and average clock cycles per instruction (CPI), so the choice of addressing mode is an important design issue.

Addressing Mode
Description
Assembler Syntax
Addressing Function
Example
Diagram
Used For
Remarks
Immediate
Operand is given explicitly in the instruction
#Value
EA= Nil
Move #30,R1
Instruction


constants
No bus cycle needed to fetch operands
Register
Register given in the instruction  contains the operand
Ri
EA=Ri
ADD R1,R2
Instruction



Frequently accessed variables
No bus cycle needed to fetch operands. Limited registers
Direct (or) absolute
Memory location given in the instruction contains the operand
LOC
EA=LOC
ADD A, B
Instruction

Variables
Requires one memory reference
Register Indirect
Register contains the address of the operand
(Ri)
EA=[Ri]
ADD (R1), R0
Instruction


 
Pointers
Requires one memory reference
Memory Indirect
Memory location given in the instruction contains the address of the operand
(LOC)
EA=[LOC]
ADD (A), B
Instruction

 
Pointers
Requires two memory references


Displacement Addressing Mode

Add displacement offset to the base/index register
Index
X(Ri)
EA = [Ri] + X
ADD 20(R1), R2
Instruction

Arrays and Lists
More flexible
Base with index
(Ri, Rj)
EA= [Ri] +[Rj];
Ri- base of array
Rj – Index amount
ADD (R1,R2), R3
Base with index and offset/displacement
X(Ri,Rj)
EA= [Ri] + [Rj] + X
ADD 20(R1,R2), R3
Relative
Add offset to PC
X(PC)
EA=[PC]+X
Branch>0 LOOP


If LOOP is 16 bytes prior to the next instruction, then EA=[PC]-16
(since -16(PC))
Used in branching
Makes branching instructions flexible
Autoincrement
Access data items  in successive memory locations
(Ri)+
EA=[Ri]
Increment Ri
Add (R1)+, R2
R2 <- [[R1]]+[R2]
Increment R1
Used in stacks (push/pop) and stepping through arrays
Additional addressing modes
Autodecrement
-(Ri)
Decrement Ri
EA=[Ri]
Add –(R1), R2
Decrement R1
R2 <- [[R1]]-[R2]

No comments:

Post a Comment