Review of the MIPS Instruction Set Architecture. RISC Instruction Set Basics All operations on data apply to data in registers and typically change the.

Slides:



Advertisements
Similar presentations
MIPS Assembly Tutorial
Advertisements

Henk Corporaal TUEindhoven 2011
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.
Goal: Write Programs in Assembly
Lecture 5: MIPS Instruction Set
CS/COE0447 Computer Organization & Assembly Language
Branches Two branch instructions:
1 Lecture 3: Instruction Set Architecture ISA types, register usage, memory addressing, endian and alignment, quantitative evaluation.
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.
Chapter 2 — Instructions: Language of the Computer — 1 Branching Far Away If branch target is too far to encode with 16-bit offset, assembler rewrites.
ECE 15B Computer Organization Spring 2010 Dmitri Strukov Lecture 5: Data Transfer Instructions / Control Flow Instructions Partially adapted from Computer.
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
Systems Architecture Lecture 5: MIPS Instruction Set
Chapter 2 Instructions: Language of the Computer
1 Instructions: Language of the Machine More primitive than higher level languages e.g., no sophisticated control flow Very restrictive e.g., MIPS Arithmetic.
CS325 Instructions: Language of the Machine MIPS ARCHITECTURE - AN INTRODUCTION TO THE INSTRUCTION SET by N. Guydosh 2/2/04+
CS 61C L09 Introduction to MIPS: Data Transfer & Decisions I (1) Garcia, Fall 2004 © UCB Lecturer PSOE Dan Garcia inst.eecs.berkeley.edu/~cs61c.
1 CSE SUNY New Paltz Chapter 3 Machine Language Instructions.
S. Barua – CPSC 440 CHAPTER 2 INSTRUCTIONS: LANGUAGE OF THE COMPUTER Goals – To get familiar with.
1 Lecture 2: MIPS Instruction Set Today’s topic:  MIPS instructions Reminder: sign up for the mailing list cs3810 Reminder: set up your CADE accounts.
RISC Concepts, MIPS ISA and the Mini–MIPS project
Lecture 5 Sept 14 Goals: Chapter 2 continued MIPS assembly language instruction formats translating c into MIPS - examples.
1  1998 Morgan Kaufmann Publishers Chapter 3 Text in blue is by N. Guydosh Updated 1/27/04 Instructions: Language of the Machine.
Data Transfer & Decisions I (1) Fall 2005 Lecture 3: MIPS Assembly language Decisions I.
MIPS Instruction Set Advantages
CDA 3101 Fall 2012 Introduction to Computer Organization Instruction Set Architecture MIPS Instruction Format 04 Sept 2013.
6.S078 - Computer Architecture: A Constructive Approach Introduction to SMIPS Li-Shiuan Peh Computer Science & Artificial Intelligence Lab. Massachusetts.
Lecture 4: MIPS Instruction Set
Computer Organization and Architecture Instructions: Language of the Machine Hennessy Patterson 2/E chapter 3. Notes are available with photocopier 24.
Computer Architecture (CS 207 D) Instruction Set Architecture ISA.
Small constants are used quite frequently (50% of operands) e.g., A = A + 5; B = B + 1; C = C - 18; Solutions? Why not? put 'typical constants' in memory.
 1998 Morgan Kaufmann Publishers MIPS arithmetic All instructions have 3 operands Operand order is fixed (destination first) Example: C code: A = B +
Computer Architecture CSE 3322 Lecture 3 Assignment: 2.4.1, 2.4.4, 2.6.1, , Due 2/3/09 Read 2.8.
Chapter 2 CSF 2009 The MIPS Assembly Language. Stored Program Computers Instructions represented in binary, just like data Instructions and data stored.
Computer Organization Rabie A. Ramadan Lecture 3.
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.
DR. SIMING LIU SPRING 2016 COMPUTER SCIENCE AND ENGINEERING UNIVERSITY OF NEVADA, RENO Session 11 Conditional Operations.
Instruction Set Architecture Chapter 3 – P & H. Introduction Instruction set architecture interface between programmer and CPU Good ISA makes program.
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
Computer Architecture & Operations I
Computer Architecture & Operations I
MIPS Instruction Set Advantages
CS2100 Computer Organisation
Lecture 4: MIPS Instruction Set
ELEN 468 Advanced Logic Design
RISC Concepts, MIPS ISA Logic Design Tutorial 8.
Assembly Programming using MIPS R3000 CPU
Computer Architecture (CS 207 D) Instruction Set Architecture ISA
Instructions - Type and Format
Lecture 4: MIPS Instruction Set
Systems Architecture I (CS ) Lecture 5: MIPS Instruction Set*
CSCI206 - Computer Organization & Programming
Systems Architecture Lecture 5: MIPS Instruction Set
Henk Corporaal TUEindhoven 2010
ECE232: Hardware Organization and Design
Instruction encoding The ISA defines Format = Encoding
Computer Instructions
3.
COMS 361 Computer Organization
COMS 361 Computer Organization
COMS 361 Computer Organization
Assembly Programming using MIPS R3000 CPU
MIPS Assembly.
Systems Architecture I (CS ) Lecture 5: MIPS Instruction Set*
7/6/
9/13/
Presentation transcript:

Review of the MIPS Instruction Set Architecture

RISC Instruction Set Basics All operations on data apply to data in registers and typically change the entire register The only operations that affect memory are load and store operations The instruction formats are few in number with all instructions typically one size Text uses MIPS64 – Instructions generally have a D at the start or end of the mnemonic, e.g. DADD is 64 bit ADD

MIPS ISA 32 registers – Register 0 always has the value 0 Three classes of instructions – ALU instructions Register to register or immediate to register Signed or unsigned Floating point or Integer NOT to memory – Load/Store instructions Base register added to signed offset to get an effective address – Branches and Jumps Branch based on condition bit or comparison between pair of registers

MIPS arithmetic Most instructions have 3 operands Operand order is fixed (destination first) Example: HLL code: A = B + C; MIPS code: DADD $s0, $s1, $s2 ($s0, $s1 and $s2 are associated with variables by compiler)

MIPS arithmetic HLL code: A = B + C + D; E = F - A; MIPS code: DADD $t0, $s1, $s2 DADD $s0, $t0, $s3 DSUB $s4, $s5, $s0 Operands must be registers – Compiler tries to keep as many variables in registers as possible – Some variables can not be allocated large arrays aliased variables (variables accessible through pointers) dynamically allocated variables on the heap or stack – Compiler may run out of registers; this is called spilling

Memory layout: Alignment Words are aligned (32 bit in this example) Big-endian or Little-endian depending on the OS this word is aligned; the others are not address

Instructions: load and store Example: HLL code: A[3] = h + A[3]; MIPS code: LW $t0, 24($s3) DADD $t0, $s2, $t0 SW $t0, 24($s3) 8 bytes per word  offset to 3 rd word  24 byte displacement h already in register $s2 Store word operation has no destination (reg) operand

Swap example CMIPS32 swap(int v[], int k) { int temp; temp = v[k] v[k] = v[k+1]; v[k+1] = temp; } swap: MULI $2, $5, 4 ADD $2, $4, $2 LW $15, 0($2) LW $16, 4($2) SW $16, 0($2) SW $15, 4($2) JR $31 Explanation: index k : $5 base address of v: $4 address of v[k] is $4 + 4*$5

MIPS32 Instruction Formats

Decision making instructions – alter the control flow, – i.e., change the "next" instruction to be executed MIPS unconditional branch J Label MIPS conditional branch instructions: BNE $t0, $t1, Label BEQ $t0, $t1, Label Example: if (X==Y) A = B + C; BNE $s4, $s5, Label DADD $s3, $s0, $s1 Label:.... Control Assembler calculates offset amount for us

We have: BEQ, BNE, what about Branch-if-less-than? New instruction: meaning: if $s1 < $s2 then $t0 = 1 SLT $t0, $s1, $s2 else $t0 = 0 Can follow this with BNE $t0, $zero, Label to get branch if less than Control Flow

MIPS compiler conventions

What’s this do? 32 bits LI$3, 4# load immediate Foo: MULI$2, $3, 4 ADD $2, $1, $2 LW $15, 0($2) ADDI $15, $15, 1 SW $15, 0($2) ADDI$3, $3, -1 BNE $3, $zero, Foo

Brief look at the 80x86 Textbook appendix has more details Complexity: – Instructions from 1 to 17 bytes long – one operand must act as both a source and destination – one operand can come from memory – complex addressing modes e.g., “base or scaled index with 8 or 32 bit displacement” Saving grace: – the most frequently used instructions are not too difficult to build – compilers avoid the portions of the architecture that are slow Implementation on later processors translates x86 instructions into RISC-like instructions internally, allowing it to adopt many of the RISC innovations