Chapter 10 Part II: Addressing Modes. LMC Addressing Mode l uses direct, absolute addressing l...

18
Chapter 10 Part II: Addressing Modes

Transcript of Chapter 10 Part II: Addressing Modes. LMC Addressing Mode l uses direct, absolute addressing l...

Page 1: Chapter 10 Part II: Addressing Modes. LMC Addressing Mode l uses direct, absolute addressing l direct address: the address of the data being referenced.

Chapter 10

Part II: Addressing Modes

Page 2: Chapter 10 Part II: Addressing Modes. LMC Addressing Mode l uses direct, absolute addressing l direct address: the address of the data being referenced.

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

Page 3: Chapter 10 Part II: Addressing Modes. LMC Addressing Mode l uses direct, absolute addressing l direct address: the address of the data being referenced.

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

Page 4: Chapter 10 Part II: Addressing Modes. LMC Addressing Mode l uses direct, absolute addressing l direct address: the address of the data being referenced.

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

Page 5: Chapter 10 Part II: Addressing Modes. LMC Addressing Mode l uses direct, absolute addressing l direct address: the address of the data being referenced.

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

Page 6: Chapter 10 Part II: Addressing Modes. LMC Addressing Mode l uses direct, absolute addressing l direct address: the address of the data being referenced.

Base Register Example

Page 7: Chapter 10 Part II: Addressing Modes. LMC Addressing Mode l uses direct, absolute addressing l direct address: the address of the data being referenced.

IBM S/390 Load Instruction

Data value is loaded into destination register.

Data address is found via indexed base addressing.

Page 8: Chapter 10 Part II: Addressing Modes. LMC Addressing Mode l uses direct, absolute addressing l direct address: the address of the data being referenced.

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

Page 9: Chapter 10 Part II: Addressing Modes. LMC Addressing Mode l uses direct, absolute addressing l direct address: the address of the data being referenced.

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

Page 10: Chapter 10 Part II: Addressing Modes. LMC Addressing Mode l uses direct, absolute addressing l direct address: the address of the data being referenced.

Immediate Addressing

Data operand is stored within the instruction itself

Useful for constants No memory access is required

Page 11: Chapter 10 Part II: Addressing Modes. LMC Addressing Mode l uses direct, absolute addressing l direct address: the address of the data being referenced.

LMC Immediate Addressing

Page 12: Chapter 10 Part II: Addressing Modes. LMC Addressing Mode l uses direct, absolute addressing l direct address: the address of the data being referenced.

INDIRECT ADDRESSING

separates the location of the data from the instruction itself

OPCODE OPERANDS

52

47484950515253

72737475

74

DATA

Page 13: Chapter 10 Part II: Addressing Modes. LMC Addressing Mode l uses direct, absolute addressing l direct address: the address of the data being referenced.

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

Page 14: Chapter 10 Part II: Addressing Modes. LMC Addressing Mode l uses direct, absolute addressing l direct address: the address of the data being referenced.

Register Indirect Addressing

Page 15: Chapter 10 Part II: Addressing Modes. LMC Addressing Mode l uses direct, absolute addressing l direct address: the address of the data being referenced.

Advantages

Very efficient access to memory Utilized in most processors Usually auto-incrementing or

decrementing of register is supported

Page 16: Chapter 10 Part II: Addressing Modes. LMC Addressing Mode l uses direct, absolute addressing l direct address: the address of the data being referenced.

Indexed Addressing

Similar to base register addressing Index register is used as a offset

for handling subscripting of arrays

Page 17: Chapter 10 Part II: Addressing Modes. LMC Addressing Mode l uses direct, absolute addressing l direct address: the address of the data being referenced.

Indexed Addressing

Page 18: Chapter 10 Part II: Addressing Modes. LMC Addressing Mode l uses direct, absolute addressing l direct address: the address of the data being referenced.

Indexed Addressing w/Base Register