Each instruction requires certain operands on which it has
to operate. There are various technique to specify the operand of an
instruction. These techniques are called addressing modes. The most common
addressing techniques, or modes are:
1. Immediate Addressing:
The simplest form of addressing is immediate addressing, in
which the operand value is present in the instruction itself. This mode can be
used to define and use constants or set initial values of variables.
The advantage of immediate addressing is that 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. The
disadvantage is that 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.
2. Direct
Addressing:
In this modes of addressing the address of the operand is
specified in the instruction. The operand will be in memory. Thus, the address
field contains the effective address of the operand.
It requires only one memory reference and no special calculation.
The obvious limitation is that it provides only a limited address space.
3. Indirect Addressing:
In this mode the address field of the instruction gives the
address where the effective address is stored in the memory.
With direct addressing, the length of the address field is
usually less than the word length, thus limiting the address range. One
solution is to have the address field refer to the address of a word in memory,
which in turn contains a full-length address of the operand. This is known as
indirect addressing.
There does not appear to be any particular advantage to this
approach, and its disadvantage is that three or more memory references could be
required to fetch an operand.
4. Register
Addressing:
In this modes of addressing, the instruction specifies the
name of the register in which the operand is available.
The advantages of register addressing are that (1) only a
small address field is needed in the instruction, and (2) no time-consuming
memory references are required. The disadvantage of register addressing is that
the address space is very limited.
5. Register
Indirect Addressing:
In this mode of addressing, the instruction specifies the
register in which address of data is available. Here, operand will be in the
memory and address in register pair.
The advantages and limitations of register indirect
addressing are basically the same as for indirect addressing. In both cases,
the address space limitation (limited range of addresses) of the address 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:
Displacement addressing is a very powerful mode of
addressing that combines the capabilities of direct addressing and register
indirect addressing.
Displacement addressing requires that the instruction have
two address fields, at least one of which is explicit. The value contained in
one address field (value = A) is used directly. The other address field, or an
implicit reference based on opcode, refers to a register whose contents are
added to A to produce the effective address.
7. Stack
Addressing:
A stack is a linear array of locations. It is sometimes
referred to as a pushdown list or last-in-first-out queue. Items are appended to the top of the stack. Associated
with the stack is a pointer whose value is the address of the top of the stack.
Alternatively, the top two elements of the stack may be in processor registers,
in which case the stack pointer references the third element of the stack. The
stack pointer is maintained in a register. Thus, references to stack locations
in memory are in fact register indirect addresses.
The stack mode of addressing is a form of implied
addressing. The machine instructions need not include a memory reference but
implicitly operate on the top of the stack.
No comments:
Post a Comment