Presentation is loading. Please wait.

Presentation is loading. Please wait.

COMP 1321 Digital Infrastructure Richard Henson University of Worcester October 2012.

Similar presentations


Presentation on theme: "COMP 1321 Digital Infrastructure Richard Henson University of Worcester October 2012."— Presentation transcript:

1 COMP 1321 Digital Infrastructure Richard Henson University of Worcester October 2012

2 Week 3: The Fetch-Execute Cycle n n Explain the instruction set of a typical CPU n n Understand the sequential way a CPU works, using its instruction set n n Understand how registers and memory addresses are used to process a CPU instruction and store the results

3 CPUs and the SAM n SAM designed to allow you to watch what happens when a CPU works n CPU very, very, very fast n Processes one instruction at a time n Instructions can require several cycles

4 What is “Processing”? n Usually calculations:  need data input »from register »from external memory  need to store output »from register »from external memory n Could also be a command without data

5 CPU types n Most frequently used:  Intel 8086 family  Motorola 68000 family  ARM (many mobile phones) n We’ll focus on Intel 8086 family  dates back to original IBM PC…

6 Registers n Tiny memory stores inside the CPU  usually containing one word of memory n Examples here show an 8-bit word (as used with original 8080 chip) n Typical registers:  general purpose data: AX, BX, CX, DX  specific use e.g. »program counter: instruction address in memory »stack pointer…

7 Data and Addressing n A general purpose register could contain  data  an address that points to data n Needs to be a way to distinguish between them  AX, 37 – move “37” into register  AX, [37] – move data contain in address 37 into register

8 8086 in practice n General Purpose registers 16-bit  Each gen register split into upper & lower byte AH AL BL BH CH DH CL DL AX BX CX DX upper byte lower byte

9 Fetch-Execute Cycle 1. Fetch instruction from memory 2. Decode the instruction and read any registers 3. Do any ALU operations (execute units) 5. Write back results to registers (Organization and Control) add ax, bx 4. Do any Memory Access ALU <- ax ALU <- bx ax + bx (Data cache) ax <- ALU None needed

10 add ax, bx add ax 0 1 4 3 2 bx Fetch-Exec : State 1 Instruction Fetch 8 3 7 1 9 3 1 AX BX

11 0 1 4 3 2 Fetch-Exec : State 2 Decode, Register Operations 8 3 7 1 9 add ax, bx add axbx 3 1 3 1 AX BX

12 0 1 4 3 2 Fetch-Exec : State 3 ALU Operation 8 3 7 1 9 add ax, bx add axbx AX BX 3 1 4

13 0 1 4 3 2 Fetch-Exec : State 4 Memory Access 8 3 7 1 9 add ax, bx add axbx AX BX 3 1 4

14 0 1 4 3 2 Fetch-Exec : State 5 Register Write 8 3 7 1 9 add ax, bx add axbx BX 3 1 4 4

15 Fetch-Execute Cycle 1. Fetch instruction from memory 2. Decode the instruction and read any registers 3. Do any ALU operations (execute units) 5. Write back results to registers (Organization and Control) mov ax, [1] 4. Do any Memory Access Read the ‘1’ Put ‘1’ into MAR Data into ax Read memory at addr ‘1’

16 mov ax, [1] mov ax 0 1 4 3 2 1 Fetch-Exec : State 1 Instruction Fetch 8 3 7 1 9

17 mov ax, [1] mov ax 0 1 4 3 2 1 Fetch-Exec : State 2 Decode, Register Operations 8 3 7 1 9

18 mov ax, [1] mov ax 0 1 4 3 2 1 Fetch-Exec : State 3 ALU Operation 1 8 3 7 1 9

19 mov ax, [1] mov ax 0 1 4 3 2 1 Fetch-Exec : State 4 Memory Access 1 8 3 7 1 9 8

20 mov ax, [1] mov ax 0 1 4 3 2 1 Fetch-Exec : State 5 Register Write 1 8 3 7 1 9 8 8

21 8088: Brains of the IBM PC

22 Inside the 8088 address bus address adder gen registers External buses ALU

23 5 1 2 3 4 1.Fetch 2.Decode 3.ALU 4.Mem Ops 5.Reg Write Pentium

24 So THAT’S how it all works! now you try it on SAM2… Next week: a focus on writing programs and i/o


Download ppt "COMP 1321 Digital Infrastructure Richard Henson University of Worcester October 2012."

Similar presentations


Ads by Google