MIPS Instruction Set Advantages

Slides:



Advertisements
Similar presentations
Henk Corporaal TUEindhoven 2011
Advertisements

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
Review of the MIPS Instruction Set Architecture. RISC Instruction Set Basics All operations on data apply to data in registers and typically change the.
Lecture 5: MIPS Instruction Set
CS/COE0447 Computer Organization & Assembly Language
1 ECE462/562 ISA and Datapath Review Ali Akoglu. 2 Instruction Set Architecture A very important abstraction –interface between hardware and low-level.
CPS3340 COMPUTER ARCHITECTURE Fall Semester, /15/2013 Lecture 11: MIPS-Conditional Instructions Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER.
1 ECE369 ECE369 Chapter 2. 2 ECE369 Instruction Set Architecture A very important abstraction –interface between hardware and low-level software –standardizes.
1 Procedure Calls, Linking & Launching Applications Lecture 15 Digital Design and Computer Architecture Harris & Harris Morgan Kaufmann / Elsevier, 2007.
ECE 15B Computer Organization Spring 2010 Dmitri Strukov Lecture 5: Data Transfer Instructions / Control Flow Instructions Partially adapted from Computer.
CS1104 – Computer Organization PART 2: Computer Architecture Lecture 5 MIPS ISA & Assembly Language Programming.
ELEN 468 Advanced Logic Design
Chapter 2 Instructions: Language of the Computer
1 COMS 361 Computer Organization Title: Instructions Date: 9/28/2004 Lecture Number: 10.
ENEE350 Spring07 1 Ankur Srivastava University of Maryland, College Park Adapted from Computer Organization and Design, Patterson & Hennessy, © 2005.”
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.
ECE 232 L5 Assembl.1 Adapted from Patterson 97 ©UCBCopyright 1998 Morgan Kaufmann Publishers ECE 232 Hardware Organization and Design Lecture 5 MIPS Assembly.
Data Transfer & Decisions I (1) Fall 2005 Lecture 3: MIPS Assembly language Decisions I.
CS 300 – Lecture 6 Intro to Computer Architecture / Assembly Language Instructions.
11/02/2009CA&O Lecture 03 by Engr. Umbreen Sabir Computer Architecture & Organization Instructions: Language of Computer Engr. Umbreen Sabir Computer Engineering.
April 23, 2001Systems Architecture I1 Systems Architecture I (CS ) Lecture 9: Assemblers, Linkers, and Loaders * Jeremy R. Johnson Mon. April 23,
Lecture 4: MIPS Instruction Set
Computer Architecture CSE 3322 Lecture 2 NO CLASS MON Sept 1 Course WEB SITE crystal.uta.edu/~jpatters.
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.
MIPS coding. Review Shifting – Shift Left Logical (sll) – Shift Right Logical (srl) – Moves all of the bits to the left/right and fills in gap with 0’s.
CHAPTER 6 Instruction Set Architecture 12/7/
 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 CS224 Fall 2012 Lessons 7 and 8.
Computer Organization Rabie A. Ramadan Lecture 3.
Chapter 2 — Instructions: Language of the Computer — 1 Conditional Operations Branch to a labeled instruction if a condition is true – Otherwise, continue.
Addressing Modes. Register Addressing Immediate Addressing Base Addressing Indexed Addressing PC-Relative Addressing.
Computer Organization Instructions Language of The Computer (MIPS) 2.
DR. SIMING LIU SPRING 2016 COMPUTER SCIENCE AND ENGINEERING UNIVERSITY OF NEVADA, RENO Session 11 Conditional Operations.
Computer Organization Instructions Language of The Computer (MIPS) 2.
Instruction Set Architecture Chapter 3 – P & H. Introduction Instruction set architecture interface between programmer and CPU Good ISA makes program.
Computer Architecture Instruction Set Architecture
MIPS Instruction Set Advantages
Computer Architecture Instruction Set Architecture
MIPS Coding Continued.
Lecture 4: MIPS Instruction Set
ELEN 468 Advanced Logic Design
Computer Architecture & Operations I
RISC Concepts, MIPS ISA Logic Design Tutorial 8.
Conditional Branches What distinguishes a computer from a simple calculator is its ability to make decisions Decisions are made using the if statement,
Computer Architecture (CS 207 D) Instruction Set Architecture ISA
The University of Adelaide, School of Computer Science
MIPS coding.
Instructions - Type and Format
Lecture 4: MIPS Instruction Set
MIPS Instruction Encoding
ECE232: Hardware Organization and Design
MIPS Instruction Encoding
Instruction encoding The ISA defines Format = Encoding
Lecture 5: Procedure Calls
The University of Adelaide, School of Computer Science
COMS 361 Computer Organization
COMS 361 Computer Organization
MIPS Assembly.
MIPS Coding Continued.
MIPS coding.
The Processor: Datapath & Control.
Instruction Set Architecture
Conditional Branching (beq)
Presentation transcript:

MIPS Instruction Set Advantages Typical of Modern RISC Instruction sets Free Simulator Available for Unix, PCs and Macs Used in real machines - MIPS R2000 Processors Used in many CS Compiler Classes as Target Machine

MIPS Architecture 32-bit RISC Processor 32 32-bit Registers, $0..$31 Pipelined Execution of Instructions All instructions are 32-bits Most Instructions executed in one clock cycle 230 32-bit memory words Byte addressable memory A 32-bit word contains four bytes To address the next word of memory add 4

MIPS Instruction Formats R format - Uses three register operands Used by all arithmetic and logical instructions I format - Uses two register operands and an address/immediate value Used by load and store instructions Used by arithmetic and logical instructions with a constant J format - Contains a jump address Used by Jump instructions

MIPS Instruction Formats 32-bit Instruction Formats R, I and J OP RS RT RD SHAMT FUNCT OP RS RT Address/Immediate OP Jump Address

MIPS Instruction Set Only Load instruction can read an operand from memory Only Store instruction can write an operand to memory Typcial RISC calculations require Load(s) to get operands from memory into registers Calculations performed only on values in registers Store(s) to write result from register back to memory

MIPS Addressing Modes Register - Uses value in register as operand Example $2 - Uses register 2 as operand Direct Address - Uses value stored in memory at given address Example 100 - Uses value stored at location 100 in memory as operand Register Indirect Address - Uses value in register as address of operand in memory Example ($3) - Uses value in register 3 as address of memory operand

MIPS Addressing Modes Indexed Address - Adds address field and register value and uses this as address of operand in memory Example 100($2) - Adds 100 to the value in register 2 and reads the operand from the resulting memory address Used for array X[I] operations, the array index is normally in the register and the address field is the first location in the array

MIPS Addressing Modes Immediate Addressing - Uses constant value contained in instruction Example addi $1,$2,4 - adds constant 4 to register 2 and stores result in register 1 Used for constants in programs PC relative - Address from instruction is added to the current value in the Program Counter Example J 4 - Jumps to address PC+4 Saves address bits in jump instructions

MIPS Assembly Language Examples ADD $1,$2,$3 Register 1 = Register 2 + Register 3 SUB $1,$2,$3 Register 1 = Register 2 - Register 3 AND $1,$2,$3 Register 1 = Register 2 AND Register 3 ADDI $1,$2,10 Register 1 = Register 2 + 10 SLL $1, $2, 10 Register 1 = Register 2 shifted left 10 bits

MIPS Assembly Language Examples LW $1,100 Register 1 = Contents of memory location 100 Used to load registers SW $1,100 Contents of memory location 100 = Register 1 Used to save registers LUI $1,100 Register 1 upper 16-bits = 100 Lower 16-bits are set to all 0’s Used to load a constant in the upper 16-bits Other constants in instructions are only 16-bits, so this instruction is used when a constant larger than 16-bits is required for the operation

MIPS Assembly Language Examples J 100 Jumps to PC+100 JAL 100 Save PC in $31 and Jumps to PC+100 Used for subroutine calls JR $31 Jumps to address in register 31 Used for subroutine returns

MIPS Assembly Language Examples BEQ $1, $2, 100 If register 1 equal to register 2 jump to PC+100 Used for Assembly Language If statements BNE $1, $2, 100 If register 1 not equal to register 2 jump to PC+100

MIPS Assembly Language Examples SLT $1,$2,$3 If register 2 is less than register 3 then register 1=1 else register 1=0 In an assembly language flag a “1” means true and a “0” means false Used in conjunction with Bxx instruction to implement any arithmetic comparision Required for more complex assembly language If statements

MIPS Labels Instead of absolute memory addresses symbolic labels are used to indicate memory addresses in assembly language Assembly Language Programs are easier to modify and are easier to understand when labels are used Examples Variable X is stored a location 123 in memory - Use label X instead of 123 in programs. Location LOOP_TOP is address 250 in a program - Use label LOOP_TOP instead of jump address 250 in programs

MIPS Program Examples A = B + C; LW $2, B ;Register 2 = value of B LW $3, C ;Register 3 = value of C ADD $4, $2, $3 ;Register 4 = B+C SW $4, A ; A = B + C

MIPS Assembly Language Label Examples N: .WORD 0 Like declaring an Integer, N, in a HLL Sets up N as a Label that points to a 32-bit data value Initial value is set to 0 LOOP: ADD $a0,$a0,$a1 Sets up LOOP as a Label that points to the Add instruction Can jump to LOOP (i.e. J LOOP)

MIPS Assembler Directives Assembler directives are commands for the assembler that do not generate machine instructions Assembler directives are also called pseudo ops Used to set up data and instruction areas

MIPS Assembler Directive Examples .DATA The following lines are constant or data values .WORD Reserve a 32-bit word in memory for a variable .ASCII Place a string in memory using the ASCII character code .TEXT The following lines are instructions

SPIM Simulator Windows Text Window Contains Assembled Machine Instructions Use to Obtain Program and Breakpoint Addresses Register Window Displays value of machine registers when program is run Check after stopping at a breakpoint to aid debug Data Window Displays values of data in memory Console Window Used for Program Input and Output Session Window Displays Assembly Errors

sub $16,$8,$9 # $16=(g+h)-(i+j) MIPS Examples # f=(g+h)-(i+j); # compiler puts f,g,h,i in # $16,$17,$18,$19,$20 add $8,$17,$18 # $8 =g+h add $9,$19,$20 #9=i+j sub $16,$8,$9 # $16=(g+h)-(i+j)

MIPS Examples # g=h+A[i] # compiler puts g,h,i in $17,$18,$19 LW $8,Astart($19) # $8 = A[i] ADD $17,$18,$8 # $17 = h+A[i]

MIPS Examples # A[i] = h + A[i]; # compiler puts g,h in $17,$18 # compiler puts i times 4 in $19 LW $8,Astart($19) # $8 = A[i] ADD $8,$18,$8 # $8 = h+A[i] SW $8,Astart($19) # A[i]=h+A[i]

MIPS Examples #if (i==j) f=g+h; Bne $19,$20,Endif Add $16,$17,$18 Endif:

MIPS Examples #if (i==j) f=g+h; else f=g-h; Bne $19,$20,Else Add $16,$17,$18 J Exit Else: sub $16,$17,$18 Exit:

MIPS Examples #for loop ADDI $5,$0,10 Loop: … … ADDI $5,$5,-1 BNE $5,$0,Loop