L23-AddressingModes
-
Upload
domainname9 -
Category
Documents
-
view
220 -
download
0
Transcript of L23-AddressingModes
-
8/6/2019 L23-AddressingModes
1/17
Addressing mode
In an instruction opcode & operands ( no of addresses)are mentioned.
Once we have determined the number of addresses
contained in an instruction, the manner in which each
address field specifies memory location must be
determined i.e. how to specify operands in an
instruction should be determined.
So addressing modes have been devised. These are the set of syntaxes or methods used to specify
a memory address in an instruction.
-
8/6/2019 L23-AddressingModes
2/17
Addressing mode
Common addressing techniques are:
Immediate
Direct
Indirect
Register
Register indirect
Displacement
Relative Base register
Indexing
stack
-
8/6/2019 L23-AddressingModes
3/17
Addressing mode
All computer architecture provide more than one ofthese addressing modes.
Different opcode use different addressing modes.
One or more bits in the instruction format can be usedas a mode field.
Value of mode field determines which addressing mode
is to be used.
-
8/6/2019 L23-AddressingModes
4/17
Immediate Addressing
Simplest form of addressing
The operand doesnt specifies address, but operand
value is present in the instruction.
Operand =A
No memory reference to fetch data
Fast, no memory access to bring the operand
Size of the operand (thus its range of values) is
limited
-
8/6/2019 L23-AddressingModes
5/17
Direct Addressing
EA = A
Instruction includes the a memory address
No calculations are required. Requires only one additional
memory reference to fetch the operand
Address is a constant at run time but data itself can be changed
during program execution
Provides a limited address space
Address AOpcode
Instruction Memory
Operand
-
8/6/2019 L23-AddressingModes
6/17
Indirect Addressing
Starts like the direct mode, but
it makes an extra memory
access. The address specified
in the instruction is not theaddress of the operand, it is the
address of a memory location
that contains the address of the
operand.
Address AOpcode
Instruction Memory
Pointer to operand
operand
-
8/6/2019 L23-AddressingModes
7/17
Two memory accesses are required
The first to fetch the effective address
The second to fetch the operand itself
EA=(A)
-
8/6/2019 L23-AddressingModes
8/17
Register Addressing
EA=R
It specifies a register instead a memory address
No memory access
Very fast execution
Very limited address space
Register Address ROpcode
Instruction Registers
Operand
-
8/6/2019 L23-AddressingModes
9/17
Register indirect Addressing
EA = ( R )
Register contains the address of the operand in the memory Register R , contains value which represents the address of
the operand in the memory
One fewer memory access than indirect addressing
Register Address ROpcode
Instruction Memory
Operand
Registers
Pointer to
operand
-
8/6/2019 L23-AddressingModes
10/17
Displacement addressing
Effective Address = A + (content of R)
Address field hold two values
A = base value
R = register that holds displacement
or vice versa
Register ROpcode
InstructionMemory
OperandPointer to
Operand
Registers
Address A
+
-
8/6/2019 L23-AddressingModes
11/17
Relative addressing
Also called as PC-relative addressing, as implicitly referenced registeris Program Counter (PC)
It is a particular case of the displacement addressing, where the
register is the program counter
Effective Address = A + (PC)
Thus Effective address is a displacement relative to the address of the
instruction
If memory references are relatively ear to the instruction being
executed, then the use of this addressing saves address bits in the
instruction.
E.g. Consider that the address A is 5 and the next instruction is at
location 12, so the operand is actually located at (12 +5) 17; the
instruction loads the operand at address 17 and stores it in the CPUs
accumulator
-
8/6/2019 L23-AddressingModes
12/17
Indexed addressing
Address field references a main memory address &referenced register contains a positive displacement
from that address.
A acts as abase R acts as displacement
Use of indexing is to provide an efficient
mechanism for performing iterative operations. Good for accessing arrays
-
8/6/2019 L23-AddressingModes
13/17
Base-register addressing
R holds a main memory address (acts as Base)
A holds displacement which is usually an unsigned
integer representation Effective Address = A + (R)
Register reference may be explicit or implicit
Convenient means of implementing segmentation
-
8/6/2019 L23-AddressingModes
14/17
Instruction
Implicit
Top of stack
register
Stack Addressing
The machine instructions need not include a memory referencebut implicitly operate on the top of stack.
Stack pointer is maintained in a register, so references to stack
locations in memory are in fact register indirect addresses.
Stack is a linear array of
locations
Also referred asPushdown list
orlast-in-first-out queue
-
8/6/2019 L23-AddressingModes
15/17
Instruction formats (1)
An instruction is represented as a binary value with specificformat, called the instruction code
It is made out of different groups of bits, with different
significations:
Opcode represents the operation to be performed (it is theinstruction identifier)
Operands one, two or three represent the operands of the
operation to be performed
A microprocessor can have one format for all theinstructions or can have several different formats
An instruction is represented by a single instruction code
-
8/6/2019 L23-AddressingModes
16/17
Instruction formats (2)
-
8/6/2019 L23-AddressingModes
17/17
Instruction formats (3)
Fewer operands translates into more instructions toaccomplish the same task
The hardware required to implement the microprocessor
becomes less complex with fewer operands;
microprocessors whose instructions specify a fewer numberof operands can execute instructions more quickly than
those that specify more operands
The example was simplified to show the difference between
three, two, one and zero operands instructions; in practice,
the instructions require many more bits than used in these
examples; an operand field may specify an arbitrary
memory address, rather than one of the four registers; this
could require 16, 32 or even more bits per operand