Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "William Stallings Computer Organization and Architecture 6 th Edition Chapter 11 Instruction Sets: Addressing Modes and Formats."— Presentation transcript:

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

2 Addressing Modes Teknik Teknik Pengalamatan (Addressing) : Immediate Direct Indirect Register Register Indirect Displacement (Indexed) Stack

3 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

4 Immediate Addressing Diagram OperandOpcode Instruction

5 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

6 Direct Addressing Diagram Address AOpcode Instruction Memory Operand

7 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

8 Indirect Addressing (2) Large address space May be nested, multilevel, cascaded —e.g. EA = (((A))) Multiple memory accesses to find operand slower

9 Indirect Addressing Diagram Address AOpcode Instruction Memory Operand Pointer to operand

10 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

11 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

12 Register Addressing Diagram Register Address ROpcode Instruction Registers Operand

13 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

14 Register Indirect Addressing Diagram Register Address ROpcode Instruction Memory Operand Pointer 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 Operand Pointer to Operand Registers Address A +

17 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

18 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

19 Indexed Addressing A version of displacement addressing A = base R = displacement EA = A + R Good for accessing arrays —EA = A + R —R++

20 Stack Addressing Operand is (implicitly) on top of stack e.g. —ADDPop top two items from stack and add

21 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))

22 Pre-index addressing LDR R0, [R1, R1 unchanged R0 R1 + LDR R0, [R1, ]

23 Auto-indexing addressing LDR R0, [R1, R1=R1+4 LDR R0, [R1, ]! R0 R1 + No extra time; Fast;

24 Post-index addressing LDR R0, R1, R1=R1+4 R0 R1 + LDR R0,[R1],

25 Example

26

27

28 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 operandLA=R —DisplacementLA=(SR)+A —BaseLA=(SR)+(B) —Base with displacementLA=(SR)+(B)+A —Scaled index with displacementLA=(SR)+(I)xS + A —Base with index and displacementLA=(SR)+(B)+(I)+A —Base scaled index with displacementLA=(SR)+(I)xS+(B)+A —Relative LA=(PC)+A

29 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

30 Pentium Addressing Mode Calculation

31 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

32 PowerPC Addressing Modes PowerPC => RISC RISC pengalamatannya lebih sederhana dari CISC ModeAlgorithm Load/Store Algorithm IndirectEA = (BR) + D Indirect Indexed EA = (BR) + (IR) Branch Addressing AbsoluteEA = I RelativeEA = (PC) + I IndirectEA = (L / CR) Fixed Point Computation RegisterEA = GPR ImmediateOperand = I Floating Point RegisterEA = FPR

33 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

34 PowerPC Memory Operand Addressing Modes

35 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

36 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

37 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)

38 PDP-8 Instruction Format

39 PDP-10 Instruction Format

40 PDP-11 Instruction Format

41 VAX Instruction Examples

42 Pentium Instruction Format

43 PowerPC Instruction Formats (1)

44 PowerPC Instruction Formats (2)


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

Similar presentations


Ads by Google