Part II: Addressing Modes 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 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 Instruction Program Counter (PC) 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 47 48 49 50 51 52 53 52 74 72 73 74 75 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