1 william stallings computer organization and architecture chapter 10 instruction sets: addressing...

Post on 14-Dec-2015

238 Views

Category:

Documents

2 Downloads

Preview:

Click to see full reader

TRANSCRIPT

1

William Stallings Computer Organization and Architecture

Chapter 10Instruction Sets:Addressing Modesand Formats

2

Addressing Modes

ImmediateDirectIndirectRegisterRegister IndirectDisplacement (Indexed) Stack

3

Immediate Addressing

Operand is part of instructionOperand = address fielde.g. ADD 5

Add 5 to contents of accumulator 5 is operand

No memory reference to fetch dataFastLimited range

4

Immediate Addressing Diagram

OperandOpcode

Instruction

5

Direct AddressingAddress field contains address of operandEffective address (EA) = address field (A)e.g. ADD A

Add contents of cell A to accumulator Look in memory at address A for operand

Single memory reference to access data

No additional calculations to work out effective address

Limited address space

6

Direct Addressing Diagram

Address AOpcode

Instruction

Memory

Operand

7

Indirect Addressing (1)

Memory cell pointed to by address field contains the address of (pointer to) the operand

EA = (A) Look in A, find address (A) and look there for

operand e.g. ADD (A)

Add contents of cell pointed to by contents of A to accumulator

8

Indirect Addressing (2)

Large address space 2n where n = word lengthMay be nested, multilevel, cascaded

e.g. EA = (((A)))Draw the diagram yourself

Multiple memory accesses to find operandHence slower

9

Indirect Addressing Diagram

Address AOpcode

Instruction

Memory

Operand

Pointer to operand

10

Register Addressing (1)

Operand is held in register named in address filed

EA = RLimited number of registersVery small address field needed

Shorter instructions Faster instruction fetch

11

Register Addressing (2)No memory accessVery fast executionVery limited address spaceMultiple registers helps performance

Requires good assembly programming or compiler writing

N.B. C programming register int a;

c.f. Direct addressing

12

Register Addressing Diagram

Register Address ROpcode

Instruction

Registers

Operand

13

Register Indirect Addressing

C.f. indirect addressingEA = (R)Operand is in memory cell pointed to by

contents of register RLarge address space (2n)One fewer memory access than indirect

addressing

14

Register Indirect Addressing Diagram

Register Address ROpcode

Instruction

Memory

OperandPointer to Operand

Registers

15

Displacement Addressing

EA = A + (R)Address field hold two values

A = base value R = register that holds displacement or vice versa

16

Displacement Addressing Diagram

Register ROpcode

Instruction

Memory

OperandPointer to Operand

Registers

Address A

+

17

Relative Addressing

A version of displacement addressingR = Program counter, PCEA = A + (PC)i.e. get operand from A cells from current

location pointed to by PCc.f locality of reference & cache usage

18

Base-Register Addressing

A holds displacementR holds pointer to base addressR may be explicit or implicite.g. segment registers in 80x86

19

Indexed Addressing

A = baseR = displacementEA = A + RGood for accessing arrays

EA = A + R R++

20

Combinations

PostindexEA = (A) + (R)

PreindexEA = (A+(R))

(Draw the diagrams)

21

Stack Addressing

Operand is (implicitly) on top of stacke.g.

ADD Pop top two items from stackand add

22

Instruction Formats

Layout of bits in an instructionIncludes opcodeIncludes (implicit or explicit) operand(s)Usually more than one instruction format

in an instruction set

23

Instruction Length

Affected by and affects: Memory size Memory organization Bus structure CPU complexity CPU speed

Trade off between powerful instruction repertoire and saving space

24

Allocation of Bits

Number of addressing modesNumber of operandsRegister versus memoryNumber of register setsAddress rangeAddress granularity

25

Foreground Reading

Stallings chapter 10Intel and PowerPC Web sites

top related