Presentation is loading. Please wait.

Presentation is loading. Please wait.

COMPUTER ARCHITECTURE & OPERATIONS I

Similar presentations


Presentation on theme: "COMPUTER ARCHITECTURE & OPERATIONS I"— Presentation transcript:

1 COMPUTER ARCHITECTURE & OPERATIONS I
Instructor: Ryan Florin

2 Representing Instructions
The University of Adelaide, School of Computer Science 11 June 2018 Representing Instructions Instructions are encoded in binary Called machine code MIPS instructions Encoded as 32-bit instruction words Small number of formats encoding operation code (opcode), register numbers, … Regularity! Register numbers $t0 – $t7 are reg’s 8 – 15 $t8 – $t9 are reg’s 24 – 25 $s0 – $s7 are reg’s 16 – 23 §2.5 Representing Instructions in the Computer Chapter 2 — Instructions: Language of the Computer

3 R-Format and I-Format

4 MIPS R-format Instructions
The University of Adelaide, School of Computer Science 11 June 2018 MIPS R-format Instructions op rs rt rd shamt funct 6 bits 5 bits Instruction fields op: operation code (opcode) rs: first source register number rt: second source register number rd: destination register number shamt: shift amount (00000 for now) funct: function code (extends opcode) Chapter 2 — Instructions: Language of the Computer

5 The University of Adelaide, School of Computer Science
11 June 2018 R-format Example op rs rt rd shamt funct 6 bits 5 bits add $t0, $s1, $s2 R-format $s1 $s2 $t0 add 17 18 8 32 000000 10001 10010 01000 00000 100000 = Chapter 2 — Instructions: Language of the Computer

6 The University of Adelaide, School of Computer Science
11 June 2018 Example What is: 012a 8020 ? add $s0, $t1, $t2 Chapter 2 — Instructions: Language of the Computer

7 MIPS I-format Instructions
The University of Adelaide, School of Computer Science 11 June 2018 MIPS I-format Instructions op rs rt constant or address 6 bits 5 bits 16 bits Immediate arithmetic and load/store instructions rt: destination register number Constant: –215 to +215 – 1 Address: offset added to base address in rs *** This slide is VERY important *** ** Use this slide to figure which is rs and which is rt ** Chapter 2 — Instructions: Language of the Computer

8 MIPS I-format Instructions
The University of Adelaide, School of Computer Science 11 June 2018 MIPS I-format Instructions Which is rs and which is rt? addi $t5, $s4, 5 lw $t0, 24 ($s0) sw $t1, 16 ($t8) addi $t0, $t1, -191 Chapter 2 — Instructions: Language of the Computer

9 In Class Exercises Convert the following MIPS instructions into Machine Instructions add $t1, $t2, $t3 addi $t5, $s3, 5 lw $t4, 200($s3)

10 In Class Exercises (Answers)
Convert the following MIPS instructions into Machine Instructions add $t1, $t2, $t3 R-format $t2 $t3 $t1 add 10 11 9 32 000000 01010 01011 01001 00000 100000

11 In Class Exercises (Answers)
Convert the following MIPS instructions into Machine Instructions addi $t5, $s3, 5 I-format $s3 $t5 5 8 19 13 5 001000 10011 01101

12 In Class Exercises (Answers)
Convert the following MIPS instructions into Machine Instructions lw $t4, 200($s3) I-format $s3 $t4 200 35 19 12 200 100011 10011 01100

13 Design Principle 4: Good design demands good compromises
Different formats complicate decoding, but allow 32-bit instructions uniformly Keep formats as similar as possible

14 Stored Program Computers
The University of Adelaide, School of Computer Science 11 June 2018 Stored Program Computers Instructions represented in binary, just like data Instructions and data stored in memory Programs can operate on programs e.g., compilers, linkers, … Binary compatibility allows compiled programs to work on different computers Standardized ISAs The BIG Picture Chapter 2 — Instructions: Language of the Computer

15 The University of Adelaide, School of Computer Science
11 June 2018 Logical Operations Instructions for bitwise manipulation §2.6 Logical Operations Operation C Java MIPS Shift left << sll Shift right >> >>> srl Bitwise AND & and, andi Bitwise OR | or, ori Bitwise NOT ~ nor Useful for extracting and inserting groups of bits in a word Chapter 2 — Instructions: Language of the Computer

16 The University of Adelaide, School of Computer Science
11 June 2018 Shift Operations op rs rt rd shamt funct 6 bits 5 bits shamt: how many positions to shift Shift left logical Shift left and fill with 0 bits sll by i bits multiplies by 2i Shift right logical Shift right and fill with 0 bits srl by i bits divides by 2i (unsigned only) Chapter 2 — Instructions: Language of the Computer

17 The University of Adelaide, School of Computer Science
11 June 2018 AND Operations Useful to mask bits in a word Select some bits, clear others to 0 and $t0, $t1, $t2 $t2 $t1 $t0 Chapter 2 — Instructions: Language of the Computer

18 The University of Adelaide, School of Computer Science
11 June 2018 OR Operations Useful to include bits in a word Set some bits to 1, leave others unchanged or $t0, $t1, $t2 $t2 $t1 $t0 Chapter 2 — Instructions: Language of the Computer

19 The University of Adelaide, School of Computer Science
11 June 2018 NOT Operations Useful to invert bits in a word Change 0 to 1, and 1 to 0 MIPS has NOR 3-operand instruction a NOR b == NOT ( a OR b ) nor $t0, $t1, $zero Register 0: always read as zero $t1 $t0 Chapter 2 — Instructions: Language of the Computer

20 What I want you to do Review Chapter 2


Download ppt "COMPUTER ARCHITECTURE & OPERATIONS I"

Similar presentations


Ads by Google