Top Banner
William Stallings Computer Organization and Architecture 6 th Edition Chapter 11 Instruction Sets: Addressing Modes and Formats
44

William Stallings Computer Organization and Architecture 6 th Edition Chapter 11 Instruction Sets: Addressing Modes and Formats.

Dec 14, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: William Stallings Computer Organization and Architecture 6 th Edition Chapter 11 Instruction Sets: Addressing Modes and Formats.

William Stallings Computer Organization and Architecture6th Edition

Chapter 11Instruction Sets:Addressing Modesand Formats

Page 2: William Stallings Computer Organization and Architecture 6 th Edition Chapter 11 Instruction Sets: Addressing Modes and Formats.

Addressing Modes

Teknik Teknik Pengalamatan (Addressing) :

• Immediate• Direct• Indirect• Register• Register Indirect• Displacement (Indexed) • Stack

Page 3: William Stallings Computer Organization and Architecture 6 th Edition Chapter 11 Instruction Sets: Addressing Modes and Formats.

Immediate Addressing

• Operand is part of instruction• Operand = address field• Address field atau operand berisi Nilai

Konstan• e.g. ADD 5

—Add 5 to contents of accumulator—5 is operand

• No memory reference to fetch data• Fast• Limited range

Page 4: William Stallings Computer Organization and Architecture 6 th Edition Chapter 11 Instruction Sets: Addressing Modes and Formats.

Immediate Addressing Diagram

OperandOpcode

Instruction

Page 5: William Stallings Computer Organization and Architecture 6 th Edition Chapter 11 Instruction Sets: Addressing Modes and Formats.

Direct Addressing

• Address field contains address of operand• EA (Effective Address) adalah alamat

aktual dari lokasi yang berisi operand • Effective address (EA) = address 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• Tidak ada kalkulasi tambahan selain

effective address• Limited address space

Page 6: William Stallings Computer Organization and Architecture 6 th Edition Chapter 11 Instruction Sets: Addressing Modes and Formats.

Direct Addressing Diagram

Address AOpcode

Instruction

Memory

Operand

Page 7: William Stallings Computer Organization and Architecture 6 th Edition Chapter 11 Instruction Sets: Addressing Modes and Formats.

Indirect Addressing (1)

• Pengalamatan tidak langsung• address field berisi alamat dari alamat

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

Page 8: William Stallings Computer Organization and Architecture 6 th Edition Chapter 11 Instruction Sets: Addressing Modes and Formats.

Indirect Addressing (2)

• Large address space • May be nested, multilevel, cascaded

—e.g. EA = (((A)))

• Multiple memory accesses to find operand• slower

Page 9: William Stallings Computer Organization and Architecture 6 th Edition Chapter 11 Instruction Sets: Addressing Modes and Formats.

Indirect Addressing Diagram

Address AOpcode

Instruction

Memory

Operand

Pointer to operand

Page 10: William Stallings Computer Organization and Architecture 6 th Edition Chapter 11 Instruction Sets: Addressing Modes and Formats.

Register Addressing (1)

• Operand is held in register• EA = R• Limited number of registers• Very small address field needed (Nama

register punya kode sendiri)—Shorter instructions—Faster instruction fetch

Page 11: William Stallings Computer Organization and Architecture 6 th Edition Chapter 11 Instruction Sets: Addressing Modes and Formats.

Register Addressing (2)

• No memory access• Very fast execution• Very limited address space• Multiple registers helps performance

—Requires good assembly programming or compiler writing

—N.B. C programming – register int a;

• Hampir sama dgn Direct addressing

Page 12: William Stallings Computer Organization and Architecture 6 th Edition Chapter 11 Instruction Sets: Addressing Modes and Formats.

Register Addressing Diagram

Register Address ROpcode

Instruction

Registers

Operand

Page 13: William Stallings Computer Organization and Architecture 6 th Edition Chapter 11 Instruction Sets: Addressing Modes and Formats.

Register Indirect Addressing

• Hampir sama dengan indirect addressing• EA = (R)• Operand is in memory cell pointed to by

contents of register R• Large address space• fewer memory access than indirect

addressing

Page 14: William Stallings Computer Organization and Architecture 6 th Edition Chapter 11 Instruction Sets: Addressing Modes and Formats.

Register Indirect Addressing Diagram

Register Address ROpcode

Instruction

Memory

OperandPointer to Operand

Registers

Page 15: William Stallings Computer Organization and Architecture 6 th Edition Chapter 11 Instruction Sets: Addressing Modes and Formats.

Displacement Addressing

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

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

Page 16: William Stallings Computer Organization and Architecture 6 th Edition Chapter 11 Instruction Sets: Addressing Modes and Formats.

Displacement Addressing Diagram

Register ROpcode

Instruction

Memory

OperandPointer to Operand

Registers

Address A

+

Page 17: William Stallings Computer Organization and Architecture 6 th Edition Chapter 11 Instruction Sets: Addressing Modes and Formats.

Relative Addressing

• A version of displacement addressing• Dimana register R = Program counter, PC• EA = A + (PC)• i.e. get operand from A cells from current

location pointed to by PC• c.f locality of reference & cache usage

Page 18: William Stallings Computer Organization and Architecture 6 th Edition Chapter 11 Instruction Sets: Addressing Modes and Formats.

Base-Register Addressing

• Khusus di 80x86• A version of displacement addressing• A holds displacement• R holds pointer to base address• R may be explicit or implicit

Page 19: William Stallings Computer Organization and Architecture 6 th Edition Chapter 11 Instruction Sets: Addressing Modes and Formats.

Indexed Addressing

• A version of displacement addressing• A = base• R = displacement• EA = A + R• Good for accessing arrays

—EA = A + R—R++

Page 20: William Stallings Computer Organization and Architecture 6 th Edition Chapter 11 Instruction Sets: Addressing Modes and Formats.

Stack Addressing

• Operand is (implicitly) on top of stack• e.g.

—ADD Pop top two items from stackand add

Page 21: William Stallings Computer Organization and Architecture 6 th Edition Chapter 11 Instruction Sets: Addressing Modes and Formats.

Indexing

• Autoindexing— EA = A + (R)

(R) = (R) + 1

• Post Indexing: Indexing dilakukan setelah Indirection— EA = (A) + (R)

• PreIndexing : Indexing dilakukan sebelum Indirection—EA = (A + (R))

Page 22: William Stallings Computer Organization and Architecture 6 th Edition Chapter 11 Instruction Sets: Addressing Modes and Formats.

Pre-index addressing

LDR R0, [R1, #4] @ R0=mem[R1+4]

@ R1 unchanged

R0

R1 +

LDR R0, [R1, ]

Page 23: William Stallings Computer Organization and Architecture 6 th Edition Chapter 11 Instruction Sets: Addressing Modes and Formats.

Auto-indexing addressing

LDR R0, [R1, #4]! @ R0=mem[R1+4]

@ R1=R1+4

LDR R0, [R1, ]!

R0

R1 +

No extra time; Fast;

Page 24: William Stallings Computer Organization and Architecture 6 th Edition Chapter 11 Instruction Sets: Addressing Modes and Formats.

Post-index addressing

LDR R0, R1, #4 @ R0=mem[R1]

@ R1=R1+4

R0R1

+

LDR R0,[R1],

Page 25: William Stallings Computer Organization and Architecture 6 th Edition Chapter 11 Instruction Sets: Addressing Modes and Formats.

Example

Page 26: William Stallings Computer Organization and Architecture 6 th Edition Chapter 11 Instruction Sets: Addressing Modes and Formats.

Example

Page 27: William Stallings Computer Organization and Architecture 6 th Edition Chapter 11 Instruction Sets: Addressing Modes and Formats.

Example

Page 28: William Stallings Computer Organization and Architecture 6 th Edition Chapter 11 Instruction Sets: Addressing Modes and Formats.

Pentium Addressing Modes

• Virtual or effective address is offset into segment—Starting address plus offset gives linear address—This goes through page translation if paging enabled

• Pentium Addressing Mode— Immediate Operand = A—Register operand LA=R—Displacement LA=(SR)+A—Base LA=(SR)+(B)—Base with displacement LA=(SR)+(B)+A—Scaled index with displacement LA=(SR)+(I)xS

+ A—Base with index and displacement LA=(SR)+(B)+

(I)+A—Base scaled index with displacement LA=(SR)+(I)xS+

(B)+A—Relative LA=(PC)+A

Page 29: William Stallings Computer Organization and Architecture 6 th Edition Chapter 11 Instruction Sets: Addressing Modes and Formats.

• LA =Linear Address• (X) = Content of X• SR = segment register• PC=Program Counter• A =Content of an address field in the

instruction• R=Register• B= Base Register• I = Index Register• S = Scaling Factor

Page 30: William Stallings Computer Organization and Architecture 6 th Edition Chapter 11 Instruction Sets: Addressing Modes and Formats.

Pentium Addressing Mode Calculation

Page 31: William Stallings Computer Organization and Architecture 6 th Edition Chapter 11 Instruction Sets: Addressing Modes and Formats.

• Scaling factor 2 : Array /Data 16-bit integer

• Scaling factor 4 : Array / Data 32-bit integer atau floating point number (single precision)

• Scaling factor 8 : Array / Data double precision floating point

Page 32: William Stallings Computer Organization and Architecture 6 th Edition Chapter 11 Instruction Sets: Addressing Modes and Formats.

PowerPC Addressing Modes• PowerPC => RISC• RISC pengalamatannya lebih sederhana dari CISC• Mode Algorithm

Load/Store AlgorithmIndirect EA = (BR) + DIndirect Indexed EA = (BR) + (IR)

Branch AddressingAbsolute EA = IRelative EA = (PC) + IIndirect EA = (L / CR)

Fixed Point Computation

Register EA = GPRImmediate Operand = I

Floating PointRegister EA = FPR

Page 33: William Stallings Computer Organization and Architecture 6 th Edition Chapter 11 Instruction Sets: Addressing Modes and Formats.

PowerPC Addressing Modes

• EA = Effective Address• (X) = Content of X• BR = Base Register• IR = Index Register• L/CR = Link or Count Register• GPR = General Purpose register• FPR = Floating Point Register• D = Displacement• I = Immediate Value• PC = Program Counter

Page 34: William Stallings Computer Organization and Architecture 6 th Edition Chapter 11 Instruction Sets: Addressing Modes and Formats.

PowerPC Memory Operand Addressing Modes

Page 35: William Stallings Computer Organization and Architecture 6 th Edition Chapter 11 Instruction Sets: Addressing Modes and Formats.

Instruction Formats

• Format Instruksi mendefinisikan :— Layout of bits in an instruction— Includes opcode (Harus ada OpCode)— Includes (implicit or explicit) operand(s)— Usually more than one instruction format in

an instruction set

Page 36: William Stallings Computer Organization and Architecture 6 th Edition Chapter 11 Instruction Sets: Addressing Modes and Formats.

Instruction Length

• Panjang Instruksi mempengaruhi :— Memory size (Kapasitas memori)— Memory organization— Bus structure— CPU complexity— CPU speed

• Trade off between powerful instruction and saving space

• Programmer menginginkan lebih banyak:— Opcode— Operand— Addressing mode

Page 37: William Stallings Computer Organization and Architecture 6 th Edition Chapter 11 Instruction Sets: Addressing Modes and Formats.

Allocation of Bits

• Faktor-faktor yang menentukan penggunaan addressing bit:— Number of addressing modes— Number of operands— Register versus memory— Number of register sets— Address range— Address granularity (alamat mengacu byte,

word, dll)

Page 38: William Stallings Computer Organization and Architecture 6 th Edition Chapter 11 Instruction Sets: Addressing Modes and Formats.

PDP-8 Instruction Format

Page 39: William Stallings Computer Organization and Architecture 6 th Edition Chapter 11 Instruction Sets: Addressing Modes and Formats.

PDP-10 Instruction Format

Page 40: William Stallings Computer Organization and Architecture 6 th Edition Chapter 11 Instruction Sets: Addressing Modes and Formats.

PDP-11 Instruction Format

Page 41: William Stallings Computer Organization and Architecture 6 th Edition Chapter 11 Instruction Sets: Addressing Modes and Formats.

VAX Instruction Examples

Page 42: William Stallings Computer Organization and Architecture 6 th Edition Chapter 11 Instruction Sets: Addressing Modes and Formats.

Pentium Instruction Format

Page 43: William Stallings Computer Organization and Architecture 6 th Edition Chapter 11 Instruction Sets: Addressing Modes and Formats.

PowerPC Instruction Formats (1)

Page 44: William Stallings Computer Organization and Architecture 6 th Edition Chapter 11 Instruction Sets: Addressing Modes and Formats.

PowerPC Instruction Formats (2)