Presentation is loading. Please wait.

Presentation is loading. Please wait.

4 November 2014 Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems.

Similar presentations


Presentation on theme: "4 November 2014 Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems."— Presentation transcript:

1 4 November 2014 Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems Autumn 2014 Week 6b: Types of Instruction

2 4 November 2014 Brookshear, Section 2.22 Machine Architecture Address | Cells FF Arithmetic/ logic unit Registers F 1 Program counter Instruction register Bus Main memory Central processing unit Control unit

3 4 November 2014 Brookshear, Section 2.23 Machine Language Concepts Registers (R, S, T…) Memory addresses Number of bytes in a memory cell Instruction Sequence of instructions Branching (choice of next instruction)

4 Properties of the Illustrative Machine No. memory cells: 256 No. bits in a memory cell: 8 (1 byte) No. registers: 16 No. bits in a register: 8 (1 byte) No. bits in the programme counter: 8 (1 byte) No. bits in the instruction register: 16 (2 bytes) 4 November 2014 Birkbeck College, U. London4

5 4 November 2014 Brookshear, Appendix C5 Illustrative Machine Language Op-codeOperanddescription 1RXYLOAD R from memory location XY 2RXYLOAD R with data XY 3RXYSTORE R at memory location XY 40RSMove bit pattern in R to S 5RSTAdd (2s comp) contents of S,T. Put result in R 6RSTAdd (fp) contents of S,T.Put result in R

6 4 November 2014 Brookshear, Appendix C6 Illustrative Machine Language Op-codeOperandDescription 7RSTOR contents of S, T. Put result in R 8RSTAND contents of S, T. Put result in R 9RSTXOR contents of S, T. Put result in R AR0XRotate right contents of R for X times. BRXYIf contents R=contents register 0, then jump to instruction at address XY, otherwise continue as normal. C000Halt

7 4 November 2014 Brookshear, Section 2.27 Types of Instruction Data transfer LOAD, STORE, MOVE Arithmetic/Logic ADD, OR, AND, XOR, ROTATE Control JUMP, HALT

8 4 November 2014 Brookshear, Section 2.28 Format of an Instruction Instruction=op-code field+operand field Op-code: identifies the elementary operation, e.g. STORE, SHIFT, XOR, JUMP. Operand: additional information, e.g. data or a register address.

9 4 November 2014 Brookshear, Section 2.39 Instruction 156C 156C Op-code 1: load Register with bit pattern in memory at the given address register memory address

10 4 November 2014 Brookshear, Section Op Code 7 (OR) st register 2 nd register 3 rd register OR =

11 4 November 2014 Brookshear, Section Op Code A (Rotate right) register rotate right 1 rotate right 2

12 4 November 2014 Brookshear, Section Instruction B258 B258 Op-code B: change value of program counter if contents of indicated register = contents of register 0 Indicated register New contents of program counter Brookshear, Fig. 2.9.

13 Brookshear, Section Machine Cycle Fetch next instruction from memory to the CPU Decode the instruction Execute the instruction 4 November 2014 Fetch Decode Execute

14 4 November 2014 Brookshear, Section First Part of the Fetch Step of the Machine Cycle bus CPU Main memory program counter A0 instruction register 156C addresscells A0 A1 A2 A3 15 6C 16 6D

15 4 November 2014 Brookshear, Section Completion of the Fetch Step bus CPU Main memory program counter A2 instruction register 156C addresscells A0 A1 A2 A3 15 6C 16 6D

16 4 November 2014 Brookshear, Section Updating the Program Counter Fixed length instructions (2 bytes). Instructions stored consecutively in main memory. Each memory cell holds 1 byte. Then pc  pc + 2 at the end of each Fetch. … … pc=7 memory

17 4 November 2014 Brookshear, Section Program to Add Two Values 1. Get the first value from memory and place it in a register S. 2. Get the second value from memory and place it in another register T. 3. Add the contents of S, T and place the result in a register R. 4. Store the result in R in memory 5. Stop

18 4 November 2014 Brookshear, Section Encoded Program C. Load register 5 with the contents of memory cell 6C D. Load register 6 with the contents of memory cell 6D Add (2s comp) contents of registers 5, 6. Put result in register E. Store the contents of Register 0 at memory cell 6E. 5. C000. Halt.

19 4 November 2014 Birkbeck College, U. London19 Without Instruction B  A program containing n instructions would run for n-1 machine cycles.  The program would be unable to respond to changes in the data.

20 4 November 2014 Birkbeck College, U. London20 Fibonacci Numbers  0,1,1,2,3,5,8,13,21,34,55, …  N(1)=0, N(2)=1  N(i+1)=N(i)+N(i-1) for i=2,3,4, …

21 4 November 2014 Birkbeck College, U. London21 Program to Find the 10 th Fibonacci Number // load register 0 with // load register 1 with // load register 2 with // load register 4 with FF // load register 5 with -1 (Two’s Comp) Address Instruction Comment R0 R2 R3 R4 R1 R ** FF

22 4 November 2014 Birkbeck College, U. London22 Program to Find the 10 th Fibonacci Number 2A 5312 // Add contents of R1, R2. Put result in R3 3C 4021 // Move bit pattern in R2 to R1 2E 4032 // Move bit pattern in R3 to R // Add contents of R4, R5. Put result in R4 32 B436 // If contents R4=contents R0, go to B02A // If contents R0=contents R0, go to 2A 36 C000 // Halt. Result is in R2. Address Instruction Comment

23 4 November 2014 Brookshear, Section Assembly Language Mnemonic system for representing machine language Machine language 156C 166D E C000 Assembly language LD R5, Price LD R6, ShippingCharge ADDI R0, R5, R6 St R0, TotalCost HLT


Download ppt "4 November 2014 Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems."

Similar presentations


Ads by Google