Navi

Addressing Modes and Formats

These are the type of  Addressing Modes :

i) Immediate
ii) Direct
iii) Indirect
iv) Register
v) Register Indirect
iv) Displacement (Indexed)
iiv) Stack

Immediate Addressing 

This "addressing mode" does not have an effective address, and is not considered to be an addressing mode on some computers. This addressing is the simplest form of addressing which operand is part of instruction.
( Operand = address field )

Example: ADD 5
Add 5 to contents of accumulator
5 is operand

This mode can be used to define and use constants or set initial values of variables
Typically the number will be stored in twos complement form
The leftmost bit of the operand field is used as a sign bit

Advantage:
no memory reference other than the instruction fetch is required to obtain the operand, thus saving one memory or cache cycle in the instruction cycle

Disadvantage:
The size of the number is restricted to the size of the address field, which, in most instruction sets, is small compared with the word length



Direct Addressing

This requires space in an instruction for quite a large address. It is often available on Complex instruction set computing (CISC) machines which have variable-length instructions, such as x86.

Address field contains address of operand
Effective address (EA) = address field (A)

Example:  ADD A
Add contents of cell A to accumulator
Look in memory at address A for operand
Single memory reference to access data
No additional calculations to work out effective address
Limited address space




Indirect Addressing

Any of the addressing modes mentioned in this article could have an extra bit to indicate indirect addressing. Indirect addressing may be used for code or data. It can make implementation of pointers or references or handles much easier, and can also make it easier to call subroutines which are not otherwise addressable. Indirect addressing does carry a performance penalty due to the extra memory access involved.

Memory cell pointed to by address field contains the address of (pointer to) the operand
EA = (A)
Look in A, find address (A) and look there for operand

Example: ADD (A)
Add contents of cell pointed to by contents of A to accumulator

Advantage:
For a word length of N an address space of 2N is now available

Disadvantage:
Instruction execution requires two memory references to fetch the operand
One to get its address and a second to get its value
May be nested, multilevel, cascaded

Example: EA = (((A)))
Disadvantage is that three or more memory references could be required to fetch an operand
Hence slower




Register Addressing 

This "addressing mode" does not have an effective address and is not considered to be an addressing mode on some computers. Similar to direct addressing, the only difference is that the address field refers to a register rather than a main memory address.
Operand is held in register named in address filed
EA = R
Advantages:
Only a small address field is needed in the instruction
No time-consuming memory references are required
Disadvantage:
The address space is very limited



Register Indirect Addressing

The effective address for a Register indirect instruction is the address in the specified register.Similar to indirect addressing. The only difference is whether the address field refers to a memory location or a register

EA = (R)
Operand is in memory cell pointed to by contents of register R

Advantages and limitations:
-Basically same as indirect addressign
-Address space limitation of the address field is overcome by having that field refer to a word-length location containing an address
-Uses one less memory reference than indirect addressing


Relative Addressing

A version of displacement addressing. The effective address for a relative instruction address is the offset parameter added to the address of the next instruction. This offset is usually signed to allow reference to code both before and after the instruction.

R = Program counter, PC
EA = A + (PC)
i.e. get operand from A cells from current location pointed to by PC
c.f locality of reference & cache usage

Base-Register Addressing ( Displacement)

The base register could contain the start address of an array or vector, and the index could select the particular array element required. The processor may scale the index register to allow for the size of each array element. This could be used for accessing elements of an array passed as a parameter.

A- holds displacement
R- holds pointer to base address
R- may be explicit or implicit

Example: segment registers in 80x86

Indexed Addressing

This also requires space in an instruction for quite a large address. The address could be the start of an array or vector, and the index could select the particular array element required. The processor may scale the index register to allow for the size of each array element.

A = base
R = displacement
EA = A + R
Good for accessing arrays (iterative operations)
EA = A + R
R++ (increment R after each operation)


+------+-----+-----+--------------------------------+
   | load | reg |index|         address                | 
   +------+-----+-----+--------------------------------+
   
   (Effective address = address + contents of specified index register)


Stack Addressing

Operand is (implicitly) on top of stack
A stack is a reserved block of locations
e.g.
ADD
Pop top two items from stack and add



Instruction Formats

-Define the layout of the bits of an instruction, in terms of its constituent fields
-Must include an opcode and, implicitly or explicitly, indicate the addressing mode for each operand
-For most instruction sets more than one instruction format is used


For Instruction Length:

-Should be equal to the memory-transfer length or one should be a multiple of the other
-Should be a multiple of the character length, which is usually 8 bits, and of the length of fixed-point numbers


Instruction length can affected by : Memory size, Memory organization, Bus structure, CPU complexity, CPU ,speed .

0 comments: