The University of Adelaide, School of Computer Science

Slides:



Advertisements
Similar presentations
1 Lecture 3: MIPS Instruction Set Today’s topic:  More MIPS instructions  Procedure call/return Reminder: Assignment 1 is on the class web-page (due.
Advertisements

Goal: Write Programs in Assembly
Introduction to SPIM Simulator
1 ECE462/562 ISA and Datapath Review Ali Akoglu. 2 Instruction Set Architecture A very important abstraction –interface between hardware and low-level.
1 ECE369 ECE369 Chapter 2. 2 ECE369 Instruction Set Architecture A very important abstraction –interface between hardware and low-level software –standardizes.
10/9: Lecture Topics Starting a Program Exercise 3.2 from H+P Review of Assembly Language RISC vs. CISC.
CS1104 – Computer Organization PART 2: Computer Architecture Lecture 5 MIPS ISA & Assembly Language Programming.
ELEN 468 Advanced Logic Design
CS3350B Computer Architecture Winter 2015 Lecture 4
Chapter 2 Instructions: Language of the Computer
Chapter 2.
Chapter 2 Instructions: Language of the Computer Part III.
Informationsteknologi Saturday, September 29, 2007 Computer Architecture I - Class 41 Today’s class More assembly language programming.
Instructions Set Bo Cheng Instruction Set Design An Instruction Set provides a functional description of a processor. It is the visible.
MIPS Architecture CPSC 321 Computer Architecture Andreas Klappenecker.
MIPS Assembly Language I Computer Architecture CPSC 321 Andreas Klappenecker.
S. Barua – CPSC 440 CHAPTER 2 INSTRUCTIONS: LANGUAGE OF THE COMPUTER Goals – To get familiar with.
Lecture 5 Sept 14 Goals: Chapter 2 continued MIPS assembly language instruction formats translating c into MIPS - examples.
April 23, 2001Systems Architecture I1 Systems Architecture I (CS ) Lecture 9: Assemblers, Linkers, and Loaders * Jeremy R. Johnson Mon. April 23,
Computer Architecture (CS 207 D) Instruction Set Architecture ISA.
CPS3340 COMPUTER ARCHITECTURE Fall Semester, /08/2013 Lecture 10: MIPS Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL STATE.
Chapter 2 CSF 2009 The MIPS Assembly Language. Stored Program Computers Instructions represented in binary, just like data Instructions and data stored.
Computer Organization CS224 Fall 2012 Lessons 7 and 8.
Chapter 2 — Instructions: Language of the Computer — 1 Memory Operands Main memory used for composite data – Arrays, structures, dynamic data To apply.
DR. SIMING LIU SPRING 2016 COMPUTER SCIENCE AND ENGINEERING UNIVERSITY OF NEVADA, RENO Session 7, 8 Instruction Set Architecture.
CDA 3101 Spring 2016 Introduction to Computer Organization
Lecture 2: Instruction Set Architecture part 1 (Introduction) Mehran Rezaei.
COM181 Computer Hardware Lecture 6: The MIPs CPU.
MIPS Arithmetic and Logic Instructions
Computer Architecture & Operations I
Computer Architecture & Operations I
MIPS Assembly.
Computer Architecture Instruction Set Architecture
COMPUTER ARCHITECTURE & OPERATIONS I
Instruction Set Architecture
Computer Architecture Instruction Set Architecture
Morgan Kaufmann Publishers
Instructions: Language of the Computer
Lecture 4: MIPS Instruction Set
ELEN 468 Advanced Logic Design
RISC Concepts, MIPS ISA Logic Design Tutorial 8.
The University of Adelaide, School of Computer Science
Computer Architecture (CS 207 D) Instruction Set Architecture ISA
Computer Architecture & Operations I
Super Quick Architecture Review
Instructions - Type and Format
Lecture 4: MIPS Instruction Set
Systems Architecture I (CS ) Lecture 5: MIPS Instruction Set*
CSCI206 - Computer Organization & Programming
The University of Adelaide, School of Computer Science
Systems Architecture Lecture 5: MIPS Instruction Set
Computer Architecture & Operations I
ECE232: Hardware Organization and Design
The University of Adelaide, School of Computer Science
MIPS History MIPS is a computer family
Chapter 2 Instructions: Language of the Computer
Instruction encoding The ISA defines Format = Encoding
MIPS History MIPS is a computer family
Computer Instructions
Computer Architecture
Instruction encoding The ISA defines Format = Encoding
COMP541 Datapaths I Montek Singh Mar 18, 2010.
UCSD ECE 111 Prof. Farinaz Koushanfar Fall 2018
Instruction encoding The ISA defines Format = Encoding
COMS 361 Computer Organization
Instruction encoding The ISA defines Format = Encoding
MIPS History MIPS is a computer family
CS352H Computer Systems Architecture
Systems Architecture I (CS ) Lecture 5: MIPS Instruction Set*
MIPS Arithmetic and Logic Instructions
Presentation transcript:

The University of Adelaide, School of Computer Science 1 December 2018 Lecture 2.2 Instructions: Representation Chapter 2 — Instructions: Language of the Computer

Objectives Describe the abstract of MIPS-32 architecture Explain the purpose of 32 registers Illustrate the three formats of MIPS-32 instructions Translate simple C statements to assembly instructions Convert between assembly instructions and binary representations Execute MIPS-32 instructions Chapter 2 — Instructions: Language of the Computer — 2

Coverage Textbook Chapter 2.5 Chapter 2 — Instructions: Language of the Computer — 3

MIPS-32 ISA Instruction Categories Computational Load/Store Jump and Branch Floating Point Memory Management Special op rs rt rd sa funct immediate jump target 3 Instruction Formats: all 32 bits wide R format I format J format Chapter 2 — Instructions: Language of the Computer — 4

The University of Adelaide, School of Computer Science 1 December 2018 32 Registers Name Register Number Usage Preserved by callee? $zero constant 0 (hardware) n.a. $at 1 reserved for assembler $v0 - $v1 2-3 returned values no $a0 - $a3 4-7 arguments $t0 - $t7 8-15 temporaries $s0 - $s7 16-23 saved values yes $t8 - $t9 24-25 $gp 28 global pointer $sp 29 stack pointer $fp 30 frame pointer $ra 31 return address Use register name in assembly instructions, and use their numbers in binary representations. We will use t0 to t7 and s0 to s7 very often. Chapter 2 — Instructions: Language of the Computer — 5 Chapter 2 — Instructions: Language of the Computer

MIPS Register File Holds thirty-two 32-bit registers Registers are Two read ports One write port Registers are Faster than main memory Register files with more locations are slower Easier for a compiler to use (A*B)+(C*D)-(E*F) can do multiplications in any order Register File 32 bits 5 32 src1 addr src1 data 5 src2 addr 32 locations 5 dst addr 32 src2 data 32 write data write control Chapter 2 — Instructions: Language of the Computer — 6

The University of Adelaide, School of Computer Science 1 December 2018 Registers vs. Memory Registers are faster to access than memory Operating on memory data requires loads and stores Compiler must use registers for variables as much as possible Only spill the less frequently used variables to memory Register optimization is important! Chapter 2 — Instructions: Language of the Computer — 7 Chapter 2 — Instructions: Language of the Computer

MIPS (RISC) Design Principles Simplicity favors regularity Fixed size instructions Small number of instruction formats Opcode is always the 6 most significant bits Smaller is faster Limited instruction set Limited number of registers Limited number of addressing mode Make the common case fast Arithmetic operands from the register file (load-store machine) Allow instructions to contain immediate operands Good design demands good compromises Three instruction formats Chapter 2 — Instructions: Language of the Computer — 8

MIPS R-format Instructions The University of Adelaide, School of Computer Science 1 December 2018 MIPS R-format Instructions op rs rt rd shamt funct 6 bits 5 bits Instruction fields op: operation code (opcode) All R-type instructions use opcode 0000002 rs: register file address of the first source operand rt: register file address of the second source operand rd: register file address of the result’s destination shamt: shift amount (for shift instructions) funct: function code augmenting the opcode Chapter 2 — Instructions: Language of the Computer — 9 Chapter 2 — Instructions: Language of the Computer

The University of Adelaide, School of Computer Science 1 December 2018 R-format Example op rs rt rd shamt funct 6 bits 5 bits add $t0, $s1, $s2 special $s1 $s2 $t0 add 17 18 8 32 000000 10001 10010 01000 00000 100000 0000,0010,0011,0010,0100,0000,0010,00002 = 0232402016 Chapter 2 — Instructions: Language of the Computer — 10 Chapter 2 — Instructions: Language of the Computer

R-type Arithmetic Instructions Chapter 2 — Instructions: Language of the Computer — 11

R-type Arithmetic Instructions Chapter 2 — Instructions: Language of the Computer — 12

Register Operand Example The University of Adelaide, School of Computer Science 1 December 2018 Register Operand Example C code: f = (g + h) - (i + j); f, g, h, i, j in $s0, $s1, $s2, $s3, $s4 Compiled MIPS code: add $t0, $s1, $s2 # $t0 = g + h add $t1, $s3, $s4 # $t1 = i + j sub $s0, $t0, $t1 # f = $t0 - $t1 Chapter 2 — Instructions: Language of the Computer — 13 Chapter 2 — Instructions: Language of the Computer

MIPS I-format Instructions The University of Adelaide, School of Computer Science 1 December 2018 MIPS I-format Instructions op rs rt immediate or address 6 bits 5 bits 16 bits Immediate arithmetic and load/store instructions Immediate arithmetic addi $rt, $rs, Imm #R[rt]=R[rs]+SignExtImm rt: destination register number rs: source register number immediate: –215 to +215 – 1, sign extension to 32 bits 0000,0000,0000,0011 0000,0000,0000,0000 0000,0000,0000,0011 1111,1111,1111,1111 1111,1111,1111,1111 1111,1111,1111,1111 Chapter 2 — Instructions: Language of the Computer — 14 Chapter 2 — Instructions: Language of the Computer

The University of Adelaide, School of Computer Science 1 December 2018 Immediate Operands Constant data specified in an instruction addi $s3, $s3, 4 No subtract immediate instruction Just use a negative constant addi $s2, $s1, -1 31 26 25 21 20 16 15 opcode rs rt immediate 6 5 5 16 0010002 1710 1810 FFFF16 Chapter 2 — Instructions: Language of the Computer — 15 Chapter 2 — Instructions: Language of the Computer

The University of Adelaide, School of Computer Science 1 December 2018 The Constant Zero MIPS register 0 ($zero) is the constant 0 Cannot be overwritten Useful for common operations E.g., copy between registers add $t2, $s1, $zero Chapter 2 — Instructions: Language of the Computer — 16 Chapter 2 — Instructions: Language of the Computer

Unsigned Arithmetic Instructions addu: Add Unsigned addu $rd, $rs, $rt # R[rd]=R[rs]+R[rt] addiu: Add Immediate Unsigned addiu $rt, $rs, Imm # R[rt]=R[rs]+SignExtImm This instruction may generate unexpected result subu: Subtract Unsigned subu $rd, $rs, $rt # R[rd]=R[rs]-R[rt] Chapter 2 — Instructions: Language of the Computer — 17