Chapter 10
Part II: Addressing Modes
LMC Addressing Mode
uses direct, absolute addressing direct address: the address of the data being
referenced can be reached directly from the address contained in the instruction word
absolute address: the address given in the instruction is the actual memory location where the data is stored
too limited for real computer systems to use only this method
Why alternative modes?
Allow a much larger range of addressable memory locations while using reasonable number of bits in the instruction word
Facilitate implementation of certain frequently occurring program statements - such as loops
Facilitate use of registers and moving data between registers
Register Addressing
Both operands are registers Significantly speeds up the execution Reduces memory accesses RISC machines provide instruction sets
that consist almost entirely of registers
Base Register Addressing
Base Register addressing• use a register to hold the initial
address• include the offset and the R# in the
instruction• address from register and offset are
added to get final address
Base Register Example
IBM S/390 Load Instruction
Data value is loaded into destination register.
Data address is found via indexed base addressing.
Advantages
Provides larger address space - usually up to several GBs
Supports relocatability of program from one memory block to another
Some systems have special base register - others permit use of general purpose registers
Relative Addressing - generate an address relative to the location of the current instruction-similar to base addressing but uses Program Counter instead of base register.
Useful for branching to n locations before or after an instruction => complement arithmetic
Relative Addressing
The desired address consists of the value in the address field added to the value in the program counter
Program Counter (PC)Instruction
OPCODE OPERANDS
1326 42
1326 + 42
1368 Actual (absolute) address in memory
Immediate Addressing
Data operand is stored within the instruction itself
Useful for constants No memory access is required
LMC Immediate Addressing
INDIRECT ADDRESSING
separates the location of the data from the instruction itself
OPCODE OPERANDS
52
47484950515253
72737475
74
DATA
Indirect Addressing
Indirect addressing is useful if one needs to reference a location outside the range of absolute address values
More commonly, register indirect addressing is provided
Register Indirect Addressing
Advantages
Very efficient access to memory Utilized in most processors Usually auto-incrementing or
decrementing of register is supported
Indexed Addressing
Similar to base register addressing Index register is used as a offset
for handling subscripting of arrays
Indexed Addressing
Indexed Addressing w/Base Register