Introduction to MIPS Processor

Size: px
Start display at page:

Download "Introduction to MIPS Processor"

Transcription

1 Introduction to MIPS Processor The processor we will be considering in this tutorial is the MIPS processor. The MIPS processor, designed in 1984 by researchers at Stanford University, is a RISC (Reduced Instruction Set Computer) processor. Compared with their CISC (Complex Instruction Set Computer) counterparts (such as the Intel Pentium processors), RISC processors typically support fewer and much simpler instructions. RISC processor can be made much faster than a CISC processor because of its simpler design. These days, it is generally accepted that RISC processors are more efficient than CISC processors; and even the only popular CISC processor that is still around (Intel Pentium) internally translates the CISC instructions into RISC instructions before they are executed. MARS is MIPS assembler and simulator. It runs on Windows, OSX, and Linux; just make sure that you have the Java J2SE 1.5 (or later) SDK installed on your computer. Some MIPS instructions don t have direct hardware implementations. MIPS assembler recognizes them and translate them to sequence of MIPS True instructions MIPS Pseudo Instruction: A MIPS instruction that does not turn directly into a machine language instruction, but into other MIPS instructions Register Move move reg2,reg1 Expands to: add reg2,$zero,reg1 The MIPS family provides instructions to perform the following operations: Load registers with values, either from RAM or with literal values. Store register values (i.e. copy them) out to RAM locations. Basic integer arithmetic: add, subtract, multiply, divide with remainder. Basic floating-point arithmetic: add, subtract, multiply, divide. Logical operations: AND, OR, NOT, exclusive OR (XOR). Shift operations: shift left, shift right. Comparison operations: ==,!=, <, >, <=, >= Instructions to change the flow of control: relative branches and jumps. The basic structure of a MIPS assembly language program is: Data section, where your variables and their data sizes are named. The assembler will choose where in RAM to store your variables. The data section is identified by a line with the assembler directive.data Code section, which contains your assembly language instructions. The code section is identified by a line with the assembler directive 1

2 .text Your code section must contain a starting point for your program's execution, marked by the label main: and your main code must end with a call to the exit system call, which tells the CPU to stop the program. 2

3 3

4 4

5 Instruction Set 5

6 Supported Syscalls by MARS System calls are asking OS to perform services syscall: o checks $v0 for the type of the service o the arguments (if any) are passed in $a0 - $a3 6

7 MIPS Assembly Language Overview Data representation We cannot refer to individual bits Addressable groups in MIPS: o byte - 8 bits o word - 4 bytes = 32 bits o halfword - 2 bytes = 16 bits Two's complement representation To represent a negative number: 1. start with the positive binary representation 2. invert every bit 3. add 1 to the result Examples with 4-bit integers: -1 == 0001 ==> 1110 ==> == 0100 ==> 1011 ==> == 0111 ==> 1000 ==> Sign extension To change the size of an integer without changing its value o if positive (left-most bit 0), pad left with 0s o if negative (left-most bit 1), pad left with 1s 12. Assembly program template Data and code segments # comment.data # constant and variable definitions go here.text # assembly instructions go here 7

8 16. MIPS register names and conventions Number Name Usage Preserved? $0 $zero constant 0x N/A $1 $at assembler temporary No $2-$3 $v0-$v1 function return values No $4-$7 $a0-$a3 function arguments No $8-$15 $t0-$t7 temporaries No $16-$23 $s0-$s7 saved temporaries Yes $24-$25 $t8-$t9 more temporaries No $26-$27 $k0-$k1 reserved for OS kernel N/A $28 $gp global pointer Yes $29 $sp stack pointer Yes $30 $fp frame pointer Yes $31 $ra return address Yes Assembly program example.eqv SYSCALL_PRINT_STRING 4.eqv SYSCALL_EXIT_PROG 10.data # data segment begins # Define a greeting message: Message:.asciiz "Hello World!\n".text # Print the greeting message: li $v0, SYSCALL_PRINT_STRING la $a0, Message syscall # print string # Return to the operating system: li $v0, SYSCALL_EXIT_PROG syscall # exit program Integer Multiplication Result of multiplication is a 64-bit number, stored in two 32-bit registers named "hi" and "lo" # Instruction # Meaning in pseudocode mult $t1, $t2 # hi,lo = $t1 * $t2 mflo $t0 # $t0 = lo mfhi $t3 # $t3 = hi 8

9 There is a shortcut (macro instruction): mul $t0, $t1, $t2 # hi,lo = $t1 * $t2; $t0 = lo which expands to: mult $t1, $t2 mflo $t0 Integer Division Computes quotient and remainder. Simultaneously stores quotient in "lo" and remainder in "hi" # Instruction # Meaning in pseudocode div $t1, $t2 # lo = $t1 / $t2; hi = $t1 % $t2 mflo $t0 # $t0 = lo quotient mfhi $t3 # $t3 = hi remainder Reading from data memory Basic instruction to read integer from memory is called load word lw $t1, 4($t2) # $t1 = Memory[$t2+4] Here, $t2 contains the base address, and 4 is the offset Note that there is a shortcut: lw $t1, 0($t2) lw $t1, $t2 lw $t1, label lw $t1, label + 4 # the same # $t1 = Memory[label] # $t1 = Memory[label+4] Writing to data memory Basic instruction to write integer to memory is called store word sw $t1, 4($t2) # Memory[$t2+4] = $t1 $t2 contains the base address 4 is the offset 9

10 Shortcuts: sw $t1, 0($t2) sw $t1, $t2 # the same sw $t1, label # Memory[label] = $t1 sw $t1, label + 4 # Memory[label+4] = $t1 Expression and Assembly example # Pseudocode: # c = (a+3) * (b-2) + a # Register mappings: # a: $t0, b: $t1, c: $t2 # tmp1: $t3, tmp2: $t4, tmp3: $t5 addi $t3, $t0, 3 # tmp1 = a+3 subi $t4, $t1, 2 # tmp2 = b-2 mul $t5, $t3, $t4 # tmp3 = tmp1 * tmp2 add $t2, $t5, $t0 # c = tmp3 + a Example adding three numbers.data # Add three numbers in memory and print the result # string to print before the result STR_PROMPT:.asciiz "Result: " # numbers to add nums:.word -77, 13, -5 # numbers to add result:.word 0 # result.text # print the initial string li $v0, 4 # ask for print string service la $a0, STR_PROMPT syscall # load three numbers into registers la $t0, nums lw $t1, 0($t0) # lw $t1, nums lw $t2, 4($t0) # lw $t2, nums + 4 lw $t3, 8($t0) # lw $t3, nums + 8 # add and store the result in $a0 for printing add $a0, $t1, $t2 # add the first two numbers add $a0, $a0, $t3 # add the third to the sum # save a0 in memory sw $a0, result # print the result li $v0, 1 # ask for $a0 print service 10

11 syscall # exit li $v0, 10 # ask for exit service syscall Bitwise logic operations and $t1, $t2, $t3 or $t1, $t2, $t3 xor $t1, $t2, $t3 # $t1 = $t2 & $t3 (bitwise and) # $t1 = $t2 $t3 (bitwise or) # $t1 = $t2 ^ $t3 (bitwise xor) Immediate formats andi $t1, $t2, 0x0F # $t1 = $t2 & 0x0F (bitwise and) ori $t1, $t2, 0xF0 # $t1 = $t2 0xF0 (bitwise or) xori $t1, $t2, 0xFF # $t1 = $t2 ^ 0xFF (bitwise xor) Bitwise examples and or xor Logical expressions seq $t1, $t2, $t3 # $t1 = $t2 == $t3? 1 : 0 sne $t1, $t2, $t3 # $t1 = $t2!= $t3? 1 : 0 sge $t1, $t2, $t3 # $t1 = $t2 >= $t3? 1 : 0 sgt $t1, $t2, $t3 # $t1 = $t2 > $t3? 1 : 0 sle $t1, $t2, $t3 # $t1 = $t2 <= $t3? 1 : 0 slt $t1, $t2, $t3 # $t1 = $t2 < $t3? 1 : 0 MARS Immediate formats: slti $t1, $t2, 42 # $t1 = $t2 < 42? 1 : 0 11

12 ...and so on... Logical expression example 1 # Pseudocode: # c = ( a < b ) ( ( a + b ) == 10 ) # Register mappings: # a: t0 # b: t1 # c: t2 add $t3, $t0, $t1 # tmp = a+b li $t4, 10 # tmp = tmp == 10 seq $t3, $t3, $t4 slt $t2, $t0, $t1 # c = a < b or $t2, $t2, $t3 # c = c tmp Logical expression example 2 # Pseudocode: # c = (a < b) && ((a+b) % 3) == 2 # Register mappings: # a: t0, b: t1, c: t2 # tmp1: t3, tmp2: t4 add $t3, $t0, $t1 # tmp1 = a+b li $t4, 3 # tmp1 = tmp1 % 3 div $t3, $t4 mfhi $t3 seq $t3, $t3, 2 # tmp1 = tmp1 == 2 slt $t4, $t0, $t1 # tmp2 = a < b and $t2, $t3, $t4 # c = tmp2 & tmp1 Conditional jumps # Basic instructions beq $t1, $t2, label bne $t1, $t2, label bgez $t1, label bgtz $t1, label blez $t1, label bltz $t1, label # Macro instructions beqz $t1, label bnez $t1, label beq $t1, 123, label bne $t1, 123, label bge $t1, $t2, label bgt $t1, $t2, label # if ($t1 == $t2) goto label # if ($t1!= $t2) goto label # if ($t1 >= 0) goto label # if ($t1 > 0) goto label # if ($t1 <= 0) goto label # if ($t1 < 0) goto label # if ($t1 == 0) goto label # if ($t1!= 0) goto label # if ($t1 == 123) goto label # if ($t1!= 123) goto label # if ($t1 >= $t2) goto label # if ($t1 > $t2) goto label 12

13 bge $t1, 123, label bgt $t1, 123, label ble... blt... # if ($t1 >= 123) goto label # if ($t1 > 123) goto label # similar # similar Conditional jump example 1 # Pseudocode: # if (a < b + 3) # a = a + 1 # else # a = a + 2 # b = b + a # Register mappings: # a: $t0, b: $t1 addi $t2, $t1, 3 # tmp = b + 3 blt $t0, $t2, ifless # if (a < tmp) addi $t0, $t0, 2 # otherwise a = a + 2 j finish ifless: addi $t0, $t0, 1 # if true, a = a + 1 finish: add $t1, $t1, $t0 # b = b + a Conditional jump example 2 # Pseudocode: # if (a < b + 3) # a = a + 1 # b = b + a # Register mappings: # a: $t0, b: $t1 # One implementation addi $t2, $t1, 3 # tmp = b + 3 blt $t0, $t2, ifless # if (a < tmp) j finish ifless: addi $t0, $t0, 1 # if true, a = a + 1 finish: add $t1, $t1, $t0 # b = b + a # Another implementation addi $t2, $t1, 3 # tmp = b + 3 bge $t0, $t2, finish # if (a >= tmp) goto finish addi $t0, $t0, 1 # a + 1 finish: add $t1, $t1, $t0 # b = b + a 13

14 while loop example # Translate to lower-level pseudocode: # sum = 0 # i = 0 # while (i < n) { # sum = sum + i # i = i + 1 # } li $t2, 0 # sum = 0 li $t1, 0 # i = 0 loop: bge $t1, $t0, endloop # Loop begins: if i >= n goto endloop add $t2, $t2, $t1 # sum = sum + i addi $t1, $t1, 1 # i = i + 1 j loop endloop: Pipelining Goal: execute programs faster How: o separate processor into stages o overlap the execution of consecutive instructions MIPS is designed for pipelining Pipelining non pipelining 14

15 MIPS Instruction pipelining Pipeline stages: 1. IF - Instruction Fetch 2. ID - Instruction Decode 3. EX - EXecute 4. ME - MEmory access 5. WB - Write Back MIPS Instruction pipeline example Pipeline Hazards Hazard is a dependency that breaks pipelining o Data hazard program needs a value that has not been computed yet 15

16 o Control hazard program does not know which instruction is next Data hazard example: add $t1, $t2, $t3 # IF ID EX ME WB-$t1 is set here addi $t4, $t1, 1 # IF ID-$t1 is read here EX ME WB Solution 1: processor inserts delays add $t1, $t2, $t3 # IF ID EX ME WB-$t1 is set here addi $t4, $t1, 1 # IF XX XX XX ID-$t1 is read here EX ME WB Solution 2: processor reorders instructions to avoid data hazards Examples Take 2 numbers from user and print the sum of them 1 1 Swap numbers Print 2 different strings 16

17 Addition, subtract, multiplication, division Read from memory using loop 17

SPIM Instruction Set

SPIM Instruction Set SPIM Instruction Set This document gives an overview of the more common instructions used in the SPIM simulator. Overview The SPIM simulator implements the full MIPS instruction set, as well as a large

More information

MIPS Instruction Format

MIPS Instruction Format MIPS Instruction Format MIPS uses a 32-bit fixed-length instruction format. only three different instruction word formats: There are Register format Op-code Rs Rt Rd Function code 000000 sssss ttttt ddddd

More information

MIPS Assembly Language

MIPS Assembly Language MIPS Assembly Language Chapter 15 S. Dandamudi Outline MIPS architecture Registers Addressing modes MIPS instruction set Instruction format Data transfer instructions Arithmetic instructions Logical/shift/rotate/compare

More information

Overview. Introduction to the MIPS ISA. MIPS ISA Overview. Overview (2)

Overview. Introduction to the MIPS ISA. MIPS ISA Overview. Overview (2) Introduction to the MIPS ISA Overview Remember that the machine only understands very basic instructions (machine instructions) It is the compiler s job to translate your high-level (e.g. C program) into

More information

TSK3000A - Generic Instructions

TSK3000A - Generic Instructions TSK3000A - Generic Instructions Frozen Content Modified by Admin on Sep 13, 2017 Using the core set of assembly language instructions for the TSK3000A as building blocks, a number of generic instructions

More information

ECE232: Hardware Organization and Design. Computer Organization - Previously covered

ECE232: Hardware Organization and Design. Computer Organization - Previously covered ECE232: Hardware Organization and Design Part 6: MIPS Instructions II http://www.ecs.umass.edu/ece/ece232/ Adapted from Computer Organization and Design, Patterson & Hennessy, UCB Computer Organization

More information

CISC 662 Graduate Computer Architecture. Lecture 4 - ISA

CISC 662 Graduate Computer Architecture. Lecture 4 - ISA CISC 662 Graduate Computer Architecture Lecture 4 - ISA Michela Taufer http://www.cis.udel.edu/~taufer/courses Powerpoint Lecture Notes from John Hennessy and David Patterson s: Computer Architecture,

More information

MIPS Reference Guide

MIPS Reference Guide MIPS Reference Guide Free at PushingButtons.net 2 Table of Contents I. Data Registers 3 II. Instruction Register Formats 4 III. MIPS Instruction Set 5 IV. MIPS Instruction Set (Extended) 6 V. SPIM Programming

More information

Mark Redekopp, All rights reserved. EE 357 Unit 11 MIPS ISA

Mark Redekopp, All rights reserved. EE 357 Unit 11 MIPS ISA EE 357 Unit 11 MIPS ISA Components of an ISA 1. Data and Address Size 8-, 16-, 32-, 64-bit 2. Which instructions does the processor support SUBtract instruc. vs. NEGate + ADD instrucs. 3. Registers accessible

More information

Implementing Algorithms in MIPS Assembly

Implementing Algorithms in MIPS Assembly 1 / 18 Implementing Algorithms in MIPS Assembly (Part 1) January 28 30, 2013 2 / 18 Outline Effective documentation Arithmetic and logical expressions Compositionality Sequentializing complex expressions

More information

F. Appendix 6 MIPS Instruction Reference

F. Appendix 6 MIPS Instruction Reference F. Appendix 6 MIPS Instruction Reference Note: ALL immediate values should be sign extended. Exception: For logical operations immediate values should be zero extended. After extensions, you treat them

More information

MIPS Instruction Reference

MIPS Instruction Reference Page 1 of 9 MIPS Instruction Reference This is a description of the MIPS instruction set, their meanings, syntax, semantics, and bit encodings. The syntax given for each instruction refers to the assembly

More information

CISC 662 Graduate Computer Architecture. Lecture 4 - ISA MIPS ISA. In a CPU. (vonneumann) Processor Organization

CISC 662 Graduate Computer Architecture. Lecture 4 - ISA MIPS ISA. In a CPU. (vonneumann) Processor Organization CISC 662 Graduate Computer Architecture Lecture 4 - ISA MIPS ISA Michela Taufer http://www.cis.udel.edu/~taufer/courses Powerpoint Lecture Notes from John Hennessy and David Patterson s: Computer Architecture,

More information

Computer Systems and Architecture

Computer Systems and Architecture Computer Systems and Architecture Stephen Pauwels MIPS: Introduction Academic Year 2018-2019 Outline MIPS Registers and Memory Language Constructs Exercises Assembly Language Very closely related to machine

More information

Flow of Control -- Conditional branch instructions

Flow of Control -- Conditional branch instructions Flow of Control -- Conditional branch instructions You can compare directly Equality or inequality of two registers One register with 0 (>,

More information

Examples of branch instructions

Examples of branch instructions Examples of branch instructions Beq rs,rt,target #go to target if rs = rt Beqz rs, target #go to target if rs = 0 Bne rs,rt,target #go to target if rs!= rt Bltz rs, target #go to target if rs < 0 etc.

More information

Computer Architecture. The Language of the Machine

Computer Architecture. The Language of the Machine Computer Architecture The Language of the Machine Instruction Sets Basic ISA Classes, Addressing, Format Administrative Matters Operations, Branching, Calling conventions Break Organization All computers

More information

MIPS ISA. 1. Data and Address Size 8-, 16-, 32-, 64-bit 2. Which instructions does the processor support

MIPS ISA. 1. Data and Address Size 8-, 16-, 32-, 64-bit 2. Which instructions does the processor support Components of an ISA EE 357 Unit 11 MIPS ISA 1. Data and Address Size 8-, 16-, 32-, 64-bit 2. Which instructions does the processor support SUBtract instruc. vs. NEGate + ADD instrucs. 3. Registers accessible

More information

Compiling Techniques

Compiling Techniques Lecture 10: An Introduction to MIPS assembly 18 October 2016 Table of contents 1 Overview 2 3 Assembly program template.data Data segment: constant and variable definitions go here (including statically

More information

Topic Notes: MIPS Instruction Set Architecture

Topic Notes: MIPS Instruction Set Architecture Computer Science 220 Assembly Language & Comp. Architecture Siena College Fall 2011 Topic Notes: MIPS Instruction Set Architecture vonneumann Architecture Modern computers use the vonneumann architecture.

More information

Computer Architecture. MIPS Instruction Set Architecture

Computer Architecture. MIPS Instruction Set Architecture Computer Architecture MIPS Instruction Set Architecture Instruction Set Architecture An Abstract Data Type Objects Registers & Memory Operations Instructions Goal of Instruction Set Architecture Design

More information

Kernel Registers 0 1. Global Data Pointer. Stack Pointer. Frame Pointer. Return Address.

Kernel Registers 0 1. Global Data Pointer. Stack Pointer. Frame Pointer. Return Address. The MIPS Register Set The MIPS R2000 CPU has 32 registers. 31 of these are general-purpose registers that can be used in any of the instructions. The last one, denoted register zero, is defined to contain

More information

The MIPS Instruction Set Architecture

The MIPS Instruction Set Architecture The MIPS Set Architecture CPS 14 Lecture 5 Today s Lecture Admin HW #1 is due HW #2 assigned Outline Review A specific ISA, we ll use it throughout semester, very similar to the NiosII ISA (we will use

More information

101 Assembly. ENGR 3410 Computer Architecture Mark L. Chang Fall 2009

101 Assembly. ENGR 3410 Computer Architecture Mark L. Chang Fall 2009 101 Assembly ENGR 3410 Computer Architecture Mark L. Chang Fall 2009 What is assembly? 79 Why are we learning assembly now? 80 Assembly Language Readings: Chapter 2 (2.1-2.6, 2.8, 2.9, 2.13, 2.15), Appendix

More information

CSc 256 Midterm 2 Fall 2011

CSc 256 Midterm 2 Fall 2011 CSc 256 Midterm 2 Fall 2011 NAME: 1a) You are given a MIPS branch instruction: x: beq $12, $0, y The address of the label "y" is 0x400468. The memory location at "x" contains: address contents 0x40049c

More information

Course Administration

Course Administration Fall 2017 EE 3613: Computer Organization Chapter 2: Instruction Set Architecture 2/4 Avinash Kodi Department of Electrical Engineering & Computer Science Ohio University, Athens, Ohio 45701 E-mail: kodi@ohio.edu

More information

Recap from Last Time. CSE 2021: Computer Organization. Levels of Programming. The RISC Philosophy 5/19/2011

Recap from Last Time. CSE 2021: Computer Organization. Levels of Programming. The RISC Philosophy 5/19/2011 CSE 2021: Computer Organization Recap from Last Time load from disk High-Level Program Lecture-3 Code Translation-1 Registers, Arithmetic, logical, jump, and branch instructions MIPS to machine language

More information

5/17/2012. Recap from Last Time. CSE 2021: Computer Organization. The RISC Philosophy. Levels of Programming. Stored Program Computers

5/17/2012. Recap from Last Time. CSE 2021: Computer Organization. The RISC Philosophy. Levels of Programming. Stored Program Computers CSE 2021: Computer Organization Recap from Last Time load from disk High-Level Program Lecture-2 Code Translation-1 Registers, Arithmetic, logical, jump, and branch instructions MIPS to machine language

More information

Instructions: Language of the Computer

Instructions: Language of the Computer CS359: Computer Architecture Instructions: Language of the Computer Yanyan Shen Department of Computer Science and Engineering 1 The Language a Computer Understands Word a computer understands: instruction

More information

CSc 256 Midterm (green) Fall 2018

CSc 256 Midterm (green) Fall 2018 CSc 256 Midterm (green) Fall 2018 NAME: Problem 1 (5 points): Suppose we are tracing a C/C++ program using a debugger such as gdb. The code showing all function calls looks like this: main() { bat(5);

More information

Programming the processor

Programming the processor CSC258 Week 9 Logistics This week: Lab 7 is the last Logisim DE2 lab. Next week: Lab 8 will be assembly. For assembly labs you can work individually or in pairs. No matter how you do it, the important

More information

Instructions: MIPS ISA. Chapter 2 Instructions: Language of the Computer 1

Instructions: MIPS ISA. Chapter 2 Instructions: Language of the Computer 1 Instructions: MIPS ISA Chapter 2 Instructions: Language of the Computer 1 PH Chapter 2 Pt A Instructions: MIPS ISA Based on Text: Patterson Henessey Publisher: Morgan Kaufmann Edited by Y.K. Malaiya for

More information

MIPS Instruction Set

MIPS Instruction Set MIPS Instruction Set Prof. James L. Frankel Harvard University Version of 7:12 PM 3-Apr-2018 Copyright 2018, 2017, 2016, 201 James L. Frankel. All rights reserved. CPU Overview CPU is an acronym for Central

More information

CSc 256 Midterm 2 Spring 2012

CSc 256 Midterm 2 Spring 2012 CSc 256 Midterm 2 Spring 2012 NAME: 1a) You are given this MIPS assembly language instruction (i.e., pseudo- instruction): ble $12, 0x20004880, there Translate this MIPS instruction to an efficient sequence

More information

CDA3100 Midterm Exam, Summer 2013

CDA3100 Midterm Exam, Summer 2013 CDA3100 Midterm Exam, Summer 2013 Name : Instructions: 1. This is a close-book and close-notes exam. 2. You have 75 minutes to answer the questions. 3. Please write down your name on the top of this page

More information

MIPS Architecture and Assembly Language Overview

MIPS Architecture and Assembly Language Overview MIPS Architecture and Assembly Language Overview Adapted from: http://edge.mcs.dre.g.el.edu/gicl/people/sevy/architecture/mipsref(spim).html [Register Description] [I/O Description] Data Types and Literals

More information

Reduced Instruction Set Computer (RISC)

Reduced Instruction Set Computer (RISC) Reduced Instruction Set Computer (RISC) Reduced Instruction Set Computer (RISC) Focuses on reducing the number and complexity of instructions of the machine. Reduced number of cycles needed per instruction.

More information

ECE468 Computer Organization & Architecture. MIPS Instruction Set Architecture

ECE468 Computer Organization & Architecture. MIPS Instruction Set Architecture ECE468 Computer Organization & Architecture MIPS Instruction Set Architecture ECE468 Lec4.1 MIPS R2000 / R3000 Registers 32-bit machine --> Programmable storage 2^32 x bytes 31 x 32-bit GPRs (R0 = 0) 32

More information

Chapter 2A Instructions: Language of the Computer

Chapter 2A Instructions: Language of the Computer Chapter 2A Instructions: Language of the Computer Copyright 2009 Elsevier, Inc. All rights reserved. Instruction Set The repertoire of instructions of a computer Different computers have different instruction

More information

COMPSCI 313 S Computer Organization. 7 MIPS Instruction Set

COMPSCI 313 S Computer Organization. 7 MIPS Instruction Set COMPSCI 313 S2 2018 Computer Organization 7 MIPS Instruction Set Agenda & Reading MIPS instruction set MIPS I-format instructions MIPS R-format instructions 2 7.1 MIPS Instruction Set MIPS Instruction

More information

EEM 486: Computer Architecture. Lecture 2. MIPS Instruction Set Architecture

EEM 486: Computer Architecture. Lecture 2. MIPS Instruction Set Architecture EEM 486: Computer Architecture Lecture 2 MIPS Instruction Set Architecture EEM 486 Overview Instruction Representation Big idea: stored program consequences of stored program Instructions as numbers Instruction

More information

Introduction to the MIPS. Lecture for CPSC 5155 Edward Bosworth, Ph.D. Computer Science Department Columbus State University

Introduction to the MIPS. Lecture for CPSC 5155 Edward Bosworth, Ph.D. Computer Science Department Columbus State University Introduction to the MIPS Lecture for CPSC 5155 Edward Bosworth, Ph.D. Computer Science Department Columbus State University Introduction to the MIPS The Microprocessor without Interlocked Pipeline Stages

More information

Reduced Instruction Set Computer (RISC)

Reduced Instruction Set Computer (RISC) Reduced Instruction Set Computer (RISC) Focuses on reducing the number and complexity of instructions of the ISA. RISC Goals RISC: Simplify ISA Simplify CPU Design Better CPU Performance Motivated by simplifying

More information

CENG3420 Lecture 03 Review

CENG3420 Lecture 03 Review CENG3420 Lecture 03 Review Bei Yu byu@cse.cuhk.edu.hk 2017 Spring 1 / 38 CISC vs. RISC Complex Instruction Set Computer (CISC) Lots of instructions of variable size, very memory optimal, typically less

More information

MIPS Assembly Language. Today s Lecture

MIPS Assembly Language. Today s Lecture MIPS Assembly Language Computer Science 104 Lecture 6 Homework #2 Midterm I Feb 22 (in class closed book) Outline Assembly Programming Reading Chapter 2, Appendix B Today s Lecture 2 Review: A Program

More information

CS153: Compilers Lecture 2: Assembly

CS153: Compilers Lecture 2: Assembly CS153: Compilers Lecture 2: Assembly Stephen Chong https://www.seas.harvard.edu/courses/cs153 Announcements (1/2) Name tags Device free seating Right side of classroom (as facing front): no devices Allow

More information

Today s Lecture. MIPS Assembly Language. Review: What Must be Specified? Review: A Program. Review: MIPS Instruction Formats

Today s Lecture. MIPS Assembly Language. Review: What Must be Specified? Review: A Program. Review: MIPS Instruction Formats Today s Lecture Homework #2 Midterm I Feb 22 (in class closed book) MIPS Assembly Language Computer Science 14 Lecture 6 Outline Assembly Programming Reading Chapter 2, Appendix B 2 Review: A Program Review:

More information

MIPS Assembly Language Programming

MIPS Assembly Language Programming MIPS Assembly Language Programming Bob Britton Chapter 1 The MIPS Architecture My objective in teaching assembly language is to introduce students to the fundamental concepts of contemporary computer architecture.

More information

Chapter 2. Instructions:

Chapter 2. Instructions: Chapter 2 1 Instructions: Language of the Machine More primitive than higher level languages e.g., no sophisticated control flow Very restrictive e.g., MIPS Arithmetic Instructions We ll be working with

More information

Computer Systems Architecture

Computer Systems Architecture Computer Systems Architecture http://cs.nott.ac.uk/ txa/g51csa/ Thorsten Altenkirch and Liyang Hu School of Computer Science and IT University of Nottingham Lecture 05: Comparisons, Loops and Bitwise Operations

More information

CSc 256 Midterm 1 Fall 2011

CSc 256 Midterm 1 Fall 2011 CSc 256 Midterm 1 Fall 2011 NAME: Problem 1a: Given the C++ function prototype and variable declarations: int func(int arg0, int *arg1, int *arg2); int *ptr, n, arr[10]; which of the following statements

More information

CPS311 - COMPUTER ORGANIZATION. A bit of history

CPS311 - COMPUTER ORGANIZATION. A bit of history CPS311 - COMPUTER ORGANIZATION A Brief Introduction to the MIPS Architecture A bit of history The MIPS architecture grows out of an early 1980's research project at Stanford University. In 1984, MIPS computer

More information

Today s topics. MIPS operations and operands. MIPS arithmetic. CS/COE1541: Introduction to Computer Architecture. A Review of MIPS ISA.

Today s topics. MIPS operations and operands. MIPS arithmetic. CS/COE1541: Introduction to Computer Architecture. A Review of MIPS ISA. Today s topics CS/COE1541: Introduction to Computer Architecture MIPS operations and operands MIPS registers Memory view Instruction encoding A Review of MIPS ISA Sangyeun Cho Arithmetic operations Logic

More information

Lecture 2. Instructions: Language of the Computer (Chapter 2 of the textbook)

Lecture 2. Instructions: Language of the Computer (Chapter 2 of the textbook) Lecture 2 Instructions: Language of the Computer (Chapter 2 of the textbook) Instructions: tell computers what to do Chapter 2 Instructions: Language of the Computer 2 Introduction Chapter 2.1 Chapter

More information

Computer Organization MIPS ISA

Computer Organization MIPS ISA CPE 335 Computer Organization MIPS ISA Dr. Iyad Jafar Adapted from Dr. Gheith Abandah Slides http://www.abandah.com/gheith/courses/cpe335_s08/index.html CPE 232 MIPS ISA 1 (vonneumann) Processor Organization

More information

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: MIPS Instruction Set Architecture

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: MIPS Instruction Set Architecture Computer Science 324 Computer Architecture Mount Holyoke College Fall 2009 Topic Notes: MIPS Instruction Set Architecture vonneumann Architecture Modern computers use the vonneumann architecture. Idea:

More information

Arithmetic for Computers

Arithmetic for Computers MIPS Arithmetic Instructions Cptr280 Dr Curtis Nelson Arithmetic for Computers Operations on integers Addition and subtraction; Multiplication and division; Dealing with overflow; Signed vs. unsigned numbers.

More information

Lecture 6 Decision + Shift + I/O

Lecture 6 Decision + Shift + I/O Lecture 6 Decision + Shift + I/O Instructions so far MIPS C Program add, sub, addi, multi, div lw $t0,12($s0) sw $t0, 12($s0) beq $s0, $s1, L1 bne $s0, $s1, L1 j L1 (unconditional branch) slt reg1,reg2,reg3

More information

ENGN1640: Design of Computing Systems Topic 03: Instruction Set Architecture Design

ENGN1640: Design of Computing Systems Topic 03: Instruction Set Architecture Design ENGN1640: Design of Computing Systems Topic 03: Instruction Set Architecture Design Professor Sherief Reda http://scale.engin.brown.edu School of Engineering Brown University Spring 2014 Sources: Computer

More information

Assembly Programming

Assembly Programming Designing Computer Systems Assembly Programming 08:34:48 PM 23 August 2016 AP-1 Scott & Linda Wills Designing Computer Systems Assembly Programming In the early days of computers, assembly programming

More information

MIPS Assembly Programming

MIPS Assembly Programming COMP 212 Computer Organization & Architecture COMP 212 Fall 2008 Lecture 8 Cache & Disk System Review MIPS Assembly Programming Comp 212 Computer Org & Arch 1 Z. Li, 2008 Comp 212 Computer Org & Arch 2

More information

M2 Instruction Set Architecture

M2 Instruction Set Architecture M2 Instruction Set Architecture Module Outline Addressing modes. Instruction classes. MIPS-I ISA. High level languages, Assembly languages and object code. Translating and starting a program. Subroutine

More information

Computer Science 2500 Computer Organization Rensselaer Polytechnic Institute Spring Topic Notes: MIPS Programming

Computer Science 2500 Computer Organization Rensselaer Polytechnic Institute Spring Topic Notes: MIPS Programming Computer Science 2500 Computer Organization Rensselaer Polytechnic Institute Spring 2009 Topic Notes: MIPS Programming We spent some time looking at the MIPS Instruction Set Architecture. We will now consider

More information

Chapter 2. Computer Abstractions and Technology. Lesson 4: MIPS (cont )

Chapter 2. Computer Abstractions and Technology. Lesson 4: MIPS (cont ) Chapter 2 Computer Abstractions and Technology Lesson 4: MIPS (cont ) Logical Operations Instructions for bitwise manipulation Operation C Java MIPS Shift left >>> srl Bitwise

More information

ELEC / Computer Architecture and Design Fall 2013 Instruction Set Architecture (Chapter 2)

ELEC / Computer Architecture and Design Fall 2013 Instruction Set Architecture (Chapter 2) ELEC 5200-001/6200-001 Computer Architecture and Design Fall 2013 Instruction Set Architecture (Chapter 2) Victor P. Nelson, Professor & Asst. Chair Vishwani D. Agrawal, James J. Danaher Professor Department

More information

Chapter 3. Instructions:

Chapter 3. Instructions: Chapter 3 1 Instructions: Language of the Machine More primitive than higher level languages e.g., no sophisticated control flow Very restrictive e.g., MIPS Arithmetic Instructions We ll be working with

More information

The MIPS R2000 Instruction Set

The MIPS R2000 Instruction Set The MIPS R2000 Instruction Set Arithmetic and Logical Instructions In all instructions below, Src2 can either be a register or an immediate value (a 16 bit integer). The immediate forms of the instructions

More information

ECE Exam I February 19 th, :00 pm 4:25pm

ECE Exam I February 19 th, :00 pm 4:25pm ECE 3056 Exam I February 19 th, 2015 3:00 pm 4:25pm 1. The exam is closed, notes, closed text, and no calculators. 2. The Georgia Tech Honor Code governs this examination. 3. There are 4 questions and

More information

We will study the MIPS assembly language as an exemplar of the concept.

We will study the MIPS assembly language as an exemplar of the concept. MIPS Assembly Language 1 We will study the MIPS assembly language as an exemplar of the concept. MIPS assembly instructions each consist of a single token specifying the command to be carried out, and

More information

ICS DEPARTMENT ICS 233 COMPUTER ARCHITECTURE & ASSEMBLY LANGUAGE. Midterm Exam. First Semester (141) Time: 1:00-3:30 PM. Student Name : _KEY

ICS DEPARTMENT ICS 233 COMPUTER ARCHITECTURE & ASSEMBLY LANGUAGE. Midterm Exam. First Semester (141) Time: 1:00-3:30 PM. Student Name : _KEY Page 1 of 14 Nov. 22, 2014 ICS DEPARTMENT ICS 233 COMPUTER ARCHITECTURE & ASSEMBLY LANGUAGE Midterm Exam First Semester (141) Time: 1:00-3:30 PM Student Name : _KEY Student ID. : Question Max Points Score

More information

RISC-V Assembly and Binary Notation

RISC-V Assembly and Binary Notation RISC-V Assembly and Binary Notation L02-1 Course Mechanics Reminders Course website: http://6004.mit.edu All lectures, videos, tutorials, and exam material can be found under Information/Resources tab.

More information

MIPS Memory Access Instructions

MIPS Memory Access Instructions MIPS Memory Access Instructions MIPS has two basic data transfer instructions for accessing memory lw $t0, 4($s3) #load word from memory sw $t0, 8($s3) #store word to memory The data is loaded into (lw)

More information

Instructions: Language of the Computer

Instructions: Language of the Computer Instructions: Language of the Computer Tuesday 22 September 15 Many slides adapted from: and Design, Patterson & Hennessy 5th Edition, 2014, MK and from Prof. Mary Jane Irwin, PSU Summary Previous Class

More information

Programmable Machines

Programmable Machines Programmable Machines Silvina Hanono Wachman Computer Science & Artificial Intelligence Lab M.I.T. Quiz 1: next week Covers L1-L8 Oct 11, 7:30-9:30PM Walker memorial 50-340 L09-1 6.004 So Far Using Combinational

More information

MIPS ISA and MIPS Assembly. CS301 Prof. Szajda

MIPS ISA and MIPS Assembly. CS301 Prof. Szajda MIPS ISA and MIPS Assembly CS301 Prof. Szajda Administrative HW #2 due Wednesday (9/11) at 5pm Lab #2 due Friday (9/13) 1:30pm Read Appendix B5, B6, B.9 and Chapter 2.5-2.9 (if you have not already done

More information

MIPS Coding Snippets. Prof. James L. Frankel Harvard University. Version of 9:32 PM 14-Feb-2016 Copyright 2016 James L. Frankel. All rights reserved.

MIPS Coding Snippets. Prof. James L. Frankel Harvard University. Version of 9:32 PM 14-Feb-2016 Copyright 2016 James L. Frankel. All rights reserved. MIPS Coding Snippets Prof. James L. Frankel Harvard University Version of 9:32 PM 14-Feb-2016 Copyright 2016 James L. Frankel. All rights reserved. Loading a 32-bit constant into a register # Example loading

More information

1 5. Addressing Modes COMP2611 Fall 2015 Instruction: Language of the Computer

1 5. Addressing Modes COMP2611 Fall 2015 Instruction: Language of the Computer 1 5. Addressing Modes MIPS Addressing Modes 2 Addressing takes care of where to find data instruction We have seen, so far three addressing modes of MIPS (to find data): 1. Immediate addressing: provides

More information

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: MIPS Instruction Set Architecture

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: MIPS Instruction Set Architecture Computer Science 324 Computer Architecture Mount Holyoke College Fall 2007 Topic Notes: MIPS Instruction Set Architecture vonneumann Architecture Modern computers use the vonneumann architecture. Idea:

More information

Programmable Machines

Programmable Machines Programmable Machines Silvina Hanono Wachman Computer Science & Artificial Intelligence Lab M.I.T. Quiz 1: next week Covers L1-L8 Oct 11, 7:30-9:30PM Walker memorial 50-340 L09-1 6.004 So Far Using Combinational

More information

MIPS Assembly Language Guide

MIPS Assembly Language Guide MIPS Assembly Language Guide MIPS is an example of a Reduced Instruction Set Computer (RISC) which was designed for easy instruction pipelining. MIPS has a Load/Store architecture since all instructions

More information

Chapter 2. Instructions: Language of the Computer. Adapted by Paulo Lopes

Chapter 2. Instructions: Language of the Computer. Adapted by Paulo Lopes Chapter 2 Instructions: Language of the Computer Adapted by Paulo Lopes Instruction Set The repertoire of instructions of a computer Different computers have different instruction sets But with many aspects

More information

ECE 2035 Programming HW/SW Systems Fall problems, 7 pages Exam Two 23 October 2013

ECE 2035 Programming HW/SW Systems Fall problems, 7 pages Exam Two 23 October 2013 Instructions: This is a closed book, closed note exam. Calculators are not permitted. If you have a question, raise your hand and I will come to you. Please work the exam in pencil and do not separate

More information

Control Instructions. Computer Organization Architectures for Embedded Computing. Thursday, 26 September Summary

Control Instructions. Computer Organization Architectures for Embedded Computing. Thursday, 26 September Summary Control Instructions Computer Organization Architectures for Embedded Computing Thursday, 26 September 2013 Many slides adapted from: Computer Organization and Design, Patterson & Hennessy 4th Edition,

More information

Control Instructions

Control Instructions Control Instructions Tuesday 22 September 15 Many slides adapted from: and Design, Patterson & Hennessy 5th Edition, 2014, MK and from Prof. Mary Jane Irwin, PSU Summary Previous Class Instruction Set

More information

MIPS function continued

MIPS function continued MIPS function continued Review Functions Series of related instructions one after another in memory Called through the jal instruction Pointed to by a label like any other Returns by calling Stack Top

More information

CS3350B Computer Architecture

CS3350B Computer Architecture CS3350B Computer Architecture Winter 2015 Lecture 4.1: MIPS ISA: Introduction Marc Moreno Maza www.csd.uwo.ca/courses/cs3350b [Adapted d from lectures on Computer Organization and Design, Patterson & Hennessy,

More information

The Program Counter. QtSPIM Register Display (Fixed-Point Registers) Erik Jonsson School of Engineering and Computer Science

The Program Counter. QtSPIM Register Display (Fixed-Point Registers) Erik Jonsson School of Engineering and Computer Science The Program Counter PC = 400064 EPC = 0 Cause = 0 BadVAddr = 0 Status = 3000ff10 1 The program counter is a register that always contains the memory address of the next instruction (i.e., the instruction

More information

ECE232: Hardware Organization and Design

ECE232: Hardware Organization and Design ECE232: Hardware Organization and Design Lecture 4: Logic Operations and Introduction to Conditionals Adapted from Computer Organization and Design, Patterson & Hennessy, UCB Overview Previously examined

More information

Programming with QtSpim: A User s Manual

Programming with QtSpim: A User s Manual Programming with QtSpim: A User s Manual John McCranie November 15, 2013 1 1 Introduction to SPIM Spim is a self-contained simulator that runs MIPS32 programs. It utilizes the instruction set originally

More information

Thomas Polzer Institut für Technische Informatik

Thomas Polzer Institut für Technische Informatik Thomas Polzer tpolzer@ecs.tuwien.ac.at Institut für Technische Informatik Branch to a labeled instruction if a condition is true Otherwise, continue sequentially beq rs, rt, L1 if (rs == rt) branch to

More information

CSc 256 Final Fall 2016

CSc 256 Final Fall 2016 CSc 256 Final Fall 2016 NAME: Problem 1 (25 points) Translate the C/C++ function func() into MIPS assembly language. The prototype is: void func(int arg0, int *arg1); arg0-arg1 are in $a0- $a1 respectively.

More information

Adventures in Assembly Land

Adventures in Assembly Land Adventures in Assembly Land What is an Assembler ASM Directives ASM Syntax Intro to SPIM Simple examples L6 Simulator 1 A Simple Programming Task Add the numbers 0 to 4 10 = 0 + 1 + 2 + 3 + 4 In C : int

More information

MIPS Hello World. MIPS Assembly 1. # PROGRAM: Hello, World! # Data declaration section. out_string:.asciiz "\nhello, World!\n"

MIPS Hello World. MIPS Assembly 1. # PROGRAM: Hello, World! # Data declaration section. out_string:.asciiz \nhello, World!\n MIPS Hello World MIPS Assembly 1 # PROGRAM: Hello, World!.data # Data declaration section out_string:.asciiz "\nhello, World!\n".text # Assembly language instructions main: # Start of code section li $v0,

More information

ECE 2035 Programming HW/SW Systems Spring problems, 6 pages Exam One 4 February Your Name (please print clearly)

ECE 2035 Programming HW/SW Systems Spring problems, 6 pages Exam One 4 February Your Name (please print clearly) Your Name (please print clearly) This exam will be conducted according to the Georgia Tech Honor Code. I pledge to neither give nor receive unauthorized assistance on this exam and to abide by all provisions

More information

CMPE324 Computer Architecture Lecture 2

CMPE324 Computer Architecture Lecture 2 CMPE324 Computer Architecture Lecture 2.1 What is Computer Architecture? Software Hardware Application (Netscape) Operating System Compiler (Unix; Assembler Windows 9x) Processor Memory Datapath & Control

More information

Question 0. Do not turn this page until you have received the signal to start. (Please fill out the identification section above) Good Luck!

Question 0. Do not turn this page until you have received the signal to start. (Please fill out the identification section above) Good Luck! CSC B58 Winter 2017 Final Examination Duration 2 hours and 50 minutes Aids allowed: none Last Name: Student Number: UTORid: First Name: Question 0. [1 mark] Read and follow all instructions on this page,

More information

Chapter 2. Instructions: Language of the Computer. HW#1: 1.3 all, 1.4 all, 1.6.1, , , , , and Due date: one week.

Chapter 2. Instructions: Language of the Computer. HW#1: 1.3 all, 1.4 all, 1.6.1, , , , , and Due date: one week. Chapter 2 Instructions: Language of the Computer HW#1: 1.3 all, 1.4 all, 1.6.1, 1.14.4, 1.14.5, 1.14.6, 1.15.1, and 1.15.4 Due date: one week. Practice: 1.5 all, 1.6 all, 1.10 all, 1.11 all, 1.14 all,

More information

EEC 581 Computer Architecture Lecture 1 Review MIPS

EEC 581 Computer Architecture Lecture 1 Review MIPS EEC 581 Computer Architecture Lecture 1 Review MIPS 1 Supercomputing: Suddenly Fancy 2 1 Instructions: Language of the Machine More primitive than higher level languages e.g., no sophisticated control

More information

ENCM 369 Winter 2013: Reference Material for Midterm #2 page 1 of 5

ENCM 369 Winter 2013: Reference Material for Midterm #2 page 1 of 5 ENCM 369 Winter 2013: Reference Material for Midterm #2 page 1 of 5 MIPS/SPIM General Purpose Registers Powers of Two 0 $zero all bits are zero 16 $s0 local variable 1 $at assembler temporary 17 $s1 local

More information

ISA: The Hardware Software Interface

ISA: The Hardware Software Interface ISA: The Hardware Software Interface Instruction Set Architecture (ISA) is where software meets hardware In embedded systems, this boundary is often flexible Understanding of ISA design is therefore important

More information