ADDRESSING MODES
The address field or fields in a typical instruction format are relatively small. We would like to he
able to reference alarge range of locations in main memory or for some systems, virtual memory. To
achieve this objective, a variety of addressing techniques have been employed. They all involve Some
trade-off between address range and/or addresing flexibility, on the one hand, and the number of
memory references and/or the complexity of address calculation, on the other. In this section, we
examine the most common addressing techniques :
1. Immediate
2. Direct
3. Indirect
4. Register
5. Register indirect
6. Displacement
7. Relative
8. Auto increment or decrement
9. Indexed
10. Implied
To understand the various addressing modes to be presented in this section, it is important to
nstructions andIInterrupts
297
the operation cycle of the computer. The CPUis
u n d e r s t a n d
which is divided into three phases :
designed to go through an instruction
ycle
L. Fetch the instruction
2 Decode the instruction
1, Execute the instruction
Program counter (PC) : It is the register which keeps track of instructions in the program
storedinthe memory. PC holds the address of the instruction to be executed next and is incremented
everytime an instruction is fetched from the memory.
Modefield. Mode field is used to locate the operands needed for operation. There may or may
not be an address field present in the instruction. If there is an address field it may designate a
memory
address or a processor register.
1,Immediate Addressing
The simplest form of addressing is immediate addressing, in which the operand is actually
instruction:
present inthe
Operand is part of instruction
Operand = address field
. Example ADD5:Add 5to contents of accumulator : 5is operand
Instruction
Op-code Operand
The advantage of immediate addressing is that no memory reference other than the instruction
instruction
fesch is requíred to obtain the operand, thus saving one memory or cache cycle in the
cycle.
address field, which,
The disadvantage is that the size of the number is restricted to the size of the
length.
in most instruction sets, is small compared with the word
[Link] Addressing
Avery simple form of addressing is direct addressing, in which :
" Address field contains address of operand
Instruction
Opcode Address A
Mernory
Operand
298 Instructions and Interrup
Effective address (EA) = address field (A)
Example ADD A : Add contents of cell A to accumulator
The technique was common in earlier generations of computers but is not Common
contemporary architectures. It requires only one memory reference and no special calculation.
obvious limitation is that it provides only a limited address space.
3. Indirect Addressing
With direct addressing, the length of the address field is usually less than the word length &.
limiting the address range. One solution is to have the address field refer to the address of a wo
memory, which is turn contains a full-length address of the operand. This is known as indi
addressing.
Instruction
Opcode Address A
Memory
Pointer to operand
Operand
4. Register Addressing
Register addressing is similar to direct addressing. The only difference is that the
refers to a register rather than a main memory address. address field
Instruction
Opcode Register Address R
Registers
Operand
Instructionsand
a d v a r n t a g e s
of register addressing are that: 299
The
Only asmall address field is needed in the
No
memory references are required, faster instruction.
disadvantage
of register addressing is that theinstruction fetch.
The address space is very limited.
Register
Indirect Addressing
5.
Just as
register
addressing is analogous to direct
to indirect addressing. In both cases, the
only
addressing, register indirect addressing
a n a l o g o u s
location or a register. difference is whether the is
Thus, for register indirect address
address : Operand is in field refers
memory
to a contents of register.
pointed toby memory cell
Instruction
Opcode Register Address R
Memory
Registers
Pointer to Operand
Operand
The advantages and limitations of register indirect addressing are basically the same as for
Imárect addressing. In both cases, the address space limitation (imited range of addresses) of the
adres field is overcome by having that field refer to a word-length location containing an address.
In addition, register indirect addressing
uses one less memory reference than indirect addressing.
6. Displacement Addressing
very powerful mode of addressing combines the capabilities of direct addressing and register
indirect addressing. It is known by a names depending on the context of its use but the basic
Tmechanism is the same. We will refer to this as displacement addressing,
" A=base value
R=register that holds displacement
300
Instructions and )
Instruction Interrupts
Opcode Register R
AddressA
Memory
Registers
Pointer to Operand
Operand
7. Relative Addressing
It is a version of the
displacement addressing. In this mode the content
added to the address part of the
instruction in
of the program counter is
order to obtain the
of the instruction is usually a
signed number which can either be effective address. The address part
R= Program counter, PC positive or negative.
Effective address=A+ (PC)
ie. get operand from Acells from current
location pointed by PC.
Relative addressing is often used with
branch-type instructions when the
itself. It results in shorter address field inbranch
area surrOunding the instruction word address is in the
because smaller number of bits are required the instruction format
here.
8. Auto increment or Auto decrement
Mode
This is similar to the register indirect
decremented after or before its value is used to mode except that the register is incremented or
access memory. This can be achieved by
decrement instruction. increment or
9. Indexed Addressing Mode
In this mode the content of an index
register is added to the address part of the instruction e
obtain the effective address. The index register
value. The address field of the instruction defines isthea special CPU register that contains an indet
Each operand in the array is stored in memory relative tobeginning
the
address of a data aray in memory
the beginning address and the address of the operand is the beginning address. The distance betweel
index value stored in Index register.
10. Implied Mode
In thís mode the operands are specified implicitly in the definition of the instruction. o
Instructions and lnterrupts 301
wample. the instruction complement accumulator' is an implied mode instruction. All
oference instructions that use an accumulator are implied mode register
instructions.