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

Size: px
Start display at page:

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

Transcription

1 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 mapping Floating-Point (pending) Data Translation Code Translation compiler Assembly Lang (obj) Topic for next few classes Shakil M. Khan (adapted from Profs. Roumani & Asif) Machine Lang (exe) save.exe to disk CSE-2021 May Levels of Programming The RISC Philosophy In this course we will cover MIPS ISA used by NEC, Nintendo, Silicon Graphics, and Sony MIPS is more primitive than higher level languages with a very restrictive set of instructions High-level language program (in C) Assembly language program (for MIPS) Binary machine language program (for MIPS) swap(int v[], int k) {int temp; temp = v[k]; v[k] = v[k+1]; v[k+1] = temp; C compiler 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 Assembler MIPS adopts the RISC philosophy very simple instructions so they can execute in one cycle, perhaps with some parallelism Compared to CISC RISC programs tend to be bigger but this is offset by the higher execution speed and the simplicity of the hardware. The latter leads to faster CPU clocks and bigger on-board caches RISC: Reduced Instruction Set Computing CISC: Complex Instruction Set Computing CSE-2021 May CSE-2021 May Design Principles Stored Program Computers The design of the MIPS ISA (Instruction Set Architecture) observes these principles: smaller is faster simplicity favors regularity make the common case fast good design demands good compromises 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 CSE-2021 May CSE-2021 May

2 Fetch and Execute Cycle Registers Processor Memory memory for data, programs, compilers, editors, etc. Instructions are fetched and put into a special register Bits in the register control the subsequent actions Data if required is fetched from the memory and placed in other registers Fetch the next instruction and continue (program counter) Registers are memory cells In MIPS, data must be in registers before arithmetic operations can be performed Size of each register is 32 bits, referred to as a word (1 word = 4 bytes = 32 bits) MIPS has a total of 32 registers CSE-2021 May CSE-2021 May Variables > Registers Register Allocation associate a register with each variable Preferred Registers eighteen: t0 t9 and s0 s7 Can also use six more: a0 a3 and v0 v1 But cannot use $0, $ra (reserved for the H/W) $k0, $k1 (reserved the O/S) $gp, $sp, $fp (reserved for addressing) $at (reserved for the assembler) CSE-2021 May Registers (Table) Name Number Usage $zero 0 Constant value of 0 $at 1 reserved for the assembler $v0-$v1 2 3 Values for results and expression evaluation $a0-$a3 4 7 Input arguments to a procedure $t0-$t Not preserved across procedures (temp) $s0-$s Preserved across procedure calls $t8-$t More temporary registers $k0-$k Reserved for OS Kernel $gp 28 Global pointer $sp 29 Stack pointer, points to last location of stack $fp 30 Frame pointer $ra 31 Return address from a procedure call CSE-2021 May Assumptions for Phase I (a simple app.) A single class hence, no instantiation of objects and no linking No Attributes hence no heap and no data segment A single method, main hence no stack needed for method invocation Few integer variables hence no spilling everything fits in registers The Arithmetic Family add/sub slt mult/div CSE-2021 May CSE-2021 May

3 Addition & Subtraction Syntax Meaning Comments Example add rd, rs, rt rd = rs + rt Overflow detected add $s0, $s1, $s2 addi rt, rs, imm rt = rs + SignExtImm Overflow detected addi $s0, $s1, 5 sub rd, rs, rt rd = rs rt Overflow detected sub $s0, $s1, $s2 Why three operands? Why addi but not subi? Editors and SPIM Unix, Windows Demo Our very first assembly program: let s convert the following C code to MIPS: x = 1; y = x + x; CSE-2021 May CSE-2021 May Mapping Variables MIPS Code: step 1: Specify registers containing variables step 2: Express instruction in MIPS $s0 $s1 $s2 $s3 $s4 $s5 $s6 $s7 Set Less Than slt rd, rs, rt rd = (rs < rt)? 1 : 0 slt $s0, $s1, $s2 slti rt, rs, imm rt = (rs < SignExtImm)? 1 : 0 slti $s0, $s1, -5 sltu rd, rs, rt rd = (rs < rt)? 1 : 0 slt $s0, $s1, $s2 sltiu rt, rs, imm rt = (rs < SignExtImm)? 1 : 0 sltiu $s0, $s1, 5 $s0 - $s7 x $t0 $t1 $t2 $t3 $t4 $t5 $t6 $t7 $t8 $t9 Why do we need it? Why sltu? $t0 - $t7 y CSE-2021 May CSE-2021 May Multiplication & Division mult rs, rt {hi,lo = rs*rt mult $s0, $s1 div rs, rt Why two operands? When to ignore hi? lo = rs / rt hi = rs % rt div $s0, $s1 mfhi rd rd = hi mfhi $s3 mflo rd rd = lo mflo $s3 MIPS to Binary Machine Language (1) Example: add $t0,$s1,$s2 Binary Machine Language Equivalent: Can we derive the binary machine language code from the MIPS instruction? MIPS field for arithmetic instructions: op rs rt rd shamt funct 6 bits 5 bits 5 bits 5 bits 5 bits 6 bits opcode 1 st operand 2 nd operand destination shift function CSE-2021 May CSE-2021 May

4 MIPS Fields for Arithmetic Operations (R-type) op rs rt rd shamt funct 6 bits 5 bits 5 bits 5 bits 5 bits 6 bits opcode 1 st operand 2 nd operand destination shift function Example: add $t0, $s1, $s2 opcode = 0 10 = (000000) 2 rs = $s1 = = (10001) 2 rt = $s2 = = (10010) 2 rd = $t0 = 8 10 = (01000) 2 shamt is not used = (00000) 2 funct for add = = (100000) 2 leads to the binary machine language code: CSE-2021 May MIPS Fields for Immediate Arithmetic Operations (I-type) op rs rt constant 6 bits 5 bits 5 bits 16 bits opcode 1 st operand 2 nd operand Memory address (offset) Example: addi $s1, $s2, 23 opcode = 8 10 = (001000) 2 rs = $s2 = = (10010) 2 rt = $s1 = = (10001) 2 constant = = ( ) 2 leads to the binary machine language code: CSE-2021 May The Logical Family (1) and, or, and xor is there an immediate version? nor what about not? sll and srl is there a variable version? sra why do we need it? CSE-2021 May The Logical Family (2) and rd, rs, rt rd = rs & rt and $s3, $s1, $s2 andi rt, rs, imm rt = rs & ZeroExtImm andi $s3, $s1, 5 or rd, rs, rt rd = rs rt or $s3, $s1, $s2 ori rt, rs, imm rt = rs ZeroExtImm ori $s3, $s1, 5 nor rd, rs, rt rd = ~ (rs rt) nor $s0, $s0, $0 sll rd, rt, shamt rd = rt << shamt sll $s1, $s1, 5 srl rd, rt, shamt rd = rt >> shamt srl $s3, $s1, 3 sra rd, rt, shamt rd = rt >>> shamt sra $s3, $s1, 3 sllv rd, rt, rs rd = rt << rs sllv $s1, $s1, $s2 srlv rd, rt, rs rd = rt >> rs srlv $s3, $s1, $s2 srav rd, rt, rs rd = rt >>> rs srav $s3, $s1, $s2 CSE-2021 May The Jump Family MIPS Fields for Jump (J-type) Used for unconditional branching to skip the else fragment of if statements and implement method invocation/return opcode address 6 bits 26 bits j and jr do we need both? jal and jalr do we need both? Syntax j C jr rs jal C jalr rs Meaning PC = JumpAddr PC = rs $ra = PC + 8 PC = JumpAddr $ra = PC + 8 PC = rs Example: j 100 opcode = 2 10 = (000010) 2 address = = ( ) 2 leads to the binary machine language code: CSE-2021 May CSE-2021 May

5 The Branch Family Used for conditional branching to implement if statements and loops beq and bne beq rs, rt, C if( rs==rt) PC = PC+4+BranchAddr beq $s1, $s2, L1 bne rs, rt, C if( rs!=rt) PC = PC+4+BranchAddr bne $s1, $s2, L2 Branch Instructions for if Example: C instructions if (i == j) f = g + h; else f = g - h; Variable Register f $s0 g $s1 h $s2 i $s3 j MIPS Code: $s4 bne $s3,$s4,l1 # go to L1 if i == j add $s0,$s1,$s2 # f = g + h j L2 # go to L2 L1: sub $s0,$s1,$s2 # f = g - h L2: Ex.: write the above code using branch if equal to CSE-2021 May CSE-2021 May General Patterns The u suffix stands for un-trapped for add/sub stands for unsigned for mult, div, and slt Handling immediates 5-bit, zero-extended for shifts 16-bit, zero-extended for logical and lui 26-bit, sign-extended for jump 16-bit, sign-extended for all the rest Large immediates the instruction lui + ori I/O > System Calls Each O/S comes with a host of s also known as interrupts SPIM uses $v0 for the service number see the SPIM Syscall Sheet Service $v0 Send Return Read integer 5 - $v0 Print integer 1 $a0 - Example: #we want to print 99 addi $v0, $0, 1 addi $a0, $0, 99 CSE-2021 May CSE-2021 May Demo (cont d) Another assembly program: read x and y compute and output: z + t*r + 1, where, z = x + y t = max(x,y) r = x y 10 import java.util.*; import java.io.*; Java Code public class First{ public static void main(string[] args){ Scanner input = new Scanner(System.in); PrintStream output = System.out; int x = input.nextint(); // $t0 holds x int y = input.nextint(); // $t1 holds y int z = x + y; int r = x - y - 10; int t = x; if (y > x) t = y; int e = z + t*r + 1; // $t2 holds z // $t3 holds r // $t4 holds t // $t5 holds e output.println(e); CSE-2021 May CSE-2021 May

6 .text main: addi $v0, $0, 5 # v0 = 5 add $t0, $v0, $0 # t0 = x addi $v0, $0, 5 # v0 = 5 add $t1, $0, $v0 # t1 = y $t1=$v0 add $t2, $t0, $t1 # t2 = z $t2=$t0+$t1 Let s Assemble! sub $t3, $t0, $t1 # t3 = x - y addi $t3, $t3, -10 # t3 = t3-10 = r add $t4, $0, $t0 # t4 = x slt $t9, $t0, $t1 # t9 = (x<y)? 1 : 0 beq $t9, $0, skip # if t9=0 go to skip add $t4, $0, $t1 # t4 = y # # t4 = t skip: mult $t4, $t3 # product in Hi Lo mflo $t5 # t5 = t*r add $t5, $t2, $t5 # t5 = z + t*r addi $t5, $t5, 1 # t5 = z + t*r + 1 addi $v0, $0, 1 add $a0, $t5, $0 jr $ra CSE-2021 May for Loops Example: C instructions for (i=0; i<5; i++) k = k+1; Say k => $s0 and let s map i => $t0 MIPS Code: Loop: add $t0,$0,$0 #$t0 = 0 addi $t1,$t1,5 #$t1 = 5 beq $t0,$t1,rest #go to Rest if (i==5) addi $s0,$s0,1 #k = k+1 addi $t0,$t0,1 #i = i+1 j Loop #go to Loop Rest: #rest of the program Example: C instructions while (i!=0){ k = k+1; i = i-1; while Loops Say k => $s0 and i => $t0 MIPS Code: Foo: beq $t0,$0,bar #go to Bar if (i==0) addi $s0,$s0,1 #k = k+1 addi $t0,$t0,-1 #i = i+1 j Foo #go to Foo Bar: CSE-2021 May CSE-2021 May Demo (Exercise) First, write a simple Java/C program add, mult, slt, j, beq, ifs, loops, read 2 ints, multiply them (using both mult and add), compare them, and print 0 if both are same, ±1 otherwise Now, let s translate it to MIPS How about to machine language? Summary Stored program computers Registers Arithmetic and logical instructions Jump and branch I/O () Mapping MIPS assembly language to binary machine language CSE-2021 May CSE-2021 May

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

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

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

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

CS222: MIPS Instruction Set

CS222: MIPS Instruction Set CS222: MIPS Instruction Set Dr. A. Sahu Dept of Comp. Sc. & Engg. Indian Institute of Technology Guwahati 1 Outline Previous Introduction to MIPS Instruction Set MIPS Arithmetic's Register Vs Memory, Registers

More information

MIPS%Assembly% E155%

MIPS%Assembly% E155% MIPS%Assembly% E155% Outline MIPS Architecture ISA Instruction types Machine codes Procedure call Stack 2 The MIPS Register Set Name Register Number Usage $0 0 the constant value 0 $at 1 assembler temporary

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

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

Levels of Programming. Registers

Levels of Programming. Registers Levels of Programming COSC 2021: Computer Organization Instructor: Dr. Amir Asif Department of Computer Science York University Handout # 3: MIPS Instruction Set I Topics: 1. Arithmetic Instructions 2.

More information

Stored Program Concept. Instructions: Characteristics of Instruction Set. Architecture Specification. Example of multiple operands

Stored Program Concept. Instructions: Characteristics of Instruction Set. Architecture Specification. Example of multiple operands Stored Program Concept Instructions: Instructions are bits Programs are stored in memory to be read or written just like data Processor Memory memory for data, programs, compilers, editors, etc. Fetch

More information

Lecture 4: MIPS Instruction Set

Lecture 4: MIPS Instruction Set Lecture 4: MIPS Instruction Set No class on Tuesday Today s topic: MIPS instructions Code examples 1 Instruction Set Understanding the language of the hardware is key to understanding the hardware/software

More information

Instructions: MIPS arithmetic. MIPS arithmetic. Chapter 3 : MIPS Downloaded from:

Instructions: MIPS arithmetic. MIPS arithmetic. Chapter 3 : MIPS Downloaded from: Instructions: Chapter 3 : MIPS Downloaded from: http://www.cs.umr.edu/~bsiever/cs234/ Language of the Machine More primitive than higher level languages e.g., no sophisticated control flow Very restrictive

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

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

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

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

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

Stored Program Concept. Instructions: Characteristics of Instruction Set. Architecture Specification. Example of multiple operands

Stored Program Concept. Instructions: Characteristics of Instruction Set. Architecture Specification. Example of multiple operands Stored Program Concept nstructions: nstructions are bits Programs are stored in memory to be read or written just like data Processor Memory memory for data, programs, compilers, editors, etc. Fetch &

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

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

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

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

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

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

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

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

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

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

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 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

MIPS R-format Instructions. Representing Instructions. Hexadecimal. R-format Example. MIPS I-format Example. MIPS I-format Instructions

MIPS R-format Instructions. Representing Instructions. Hexadecimal. R-format Example. MIPS I-format Example. MIPS I-format Instructions 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

More information

CS/COE1541: Introduction to Computer Architecture

CS/COE1541: Introduction to Computer Architecture CS/COE1541: Introduction to Computer Architecture Dept. of Computer Science University of Pittsburgh http://www.cs.pitt.edu/~melhem/courses/1541p/index.html 1 Computer Architecture? Application pull Operating

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

MACHINE LANGUAGE. To work with the machine, we need a translator.

MACHINE LANGUAGE. To work with the machine, we need a translator. LECTURE 2 Assembly MACHINE LANGUAGE As humans, communicating with a machine is a tedious task. We can t, for example, just say add this number and that number and store the result here. Computers have

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

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

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

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

Chapter 3 MIPS Assembly Language. Ó1998 Morgan Kaufmann Publishers 1

Chapter 3 MIPS Assembly Language. Ó1998 Morgan Kaufmann Publishers 1 Chapter 3 MIPS Assembly Language Ó1998 Morgan Kaufmann Publishers 1 Instructions: Language of the Machine More primitive than higher level languages e.g., no sophisticated control flow Very restrictive

More information

Machine Language Instructions Introduction. Instructions Words of a language understood by machine. Instruction set Vocabulary of the machine

Machine Language Instructions Introduction. Instructions Words of a language understood by machine. Instruction set Vocabulary of the machine Machine Language Instructions Introduction Instructions Words of a language understood by machine Instruction set Vocabulary of the machine Current goal: to relate a high level language to instruction

More information

Computer Architecture

Computer Architecture CS3350B Computer Architecture Winter 2015 Lecture 4.2: MIPS ISA -- Instruction Representation Marc Moreno Maza www.csd.uwo.ca/courses/cs3350b [Adapted from lectures on Computer Organization and Design,

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

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

CS61C - Machine Structures. Lecture 6 - Instruction Representation. September 15, 2000 David Patterson.

CS61C - Machine Structures. Lecture 6 - Instruction Representation. September 15, 2000 David Patterson. CS61C - Machine Structures Lecture 6 - Instruction Representation September 15, 2000 David Patterson http://www-inst.eecs.berkeley.edu/~cs61c/ 1 Review Instructions: add, addi, sub, lw, sw beq, bne, j

More information

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

Instruction Set Architecture of. MIPS Processor. MIPS Processor. MIPS Registers (continued) MIPS Registers

Instruction Set Architecture of. MIPS Processor. MIPS Processor. MIPS Registers (continued) MIPS Registers CSE 675.02: Introduction to Computer Architecture MIPS Processor Memory Instruction Set Architecture of MIPS Processor CPU Arithmetic Logic unit Registers $0 $31 Multiply divide Coprocessor 1 (FPU) Registers

More information

Chapter 2: Instructions:

Chapter 2: Instructions: Chapter 2: Instructions: Language of the Computer Computer Architecture CS-3511-2 1 Instructions: To command a computer s hardware you must speak it s language The computer s language is called instruction

More information

Computer Organization and Structure. Bing-Yu Chen National Taiwan University

Computer Organization and Structure. Bing-Yu Chen National Taiwan University Computer Organization and Structure Bing-Yu Chen National Taiwan University Instructions: Language of the Computer Operations and Operands of the Computer Hardware Signed and Unsigned Numbers Representing

More information

Instruction Set Architecture part 1 (Introduction) Mehran Rezaei

Instruction Set Architecture part 1 (Introduction) Mehran Rezaei Instruction Set Architecture part 1 (Introduction) Mehran Rezaei Overview Last Lecture s Review Execution Cycle Levels of Computer Languages Stored Program Computer/Instruction Execution Cycle SPIM, a

More information

CS3350B Computer Architecture MIPS Instruction Representation

CS3350B Computer Architecture MIPS Instruction Representation CS3350B Computer Architecture MIPS Instruction Representation Marc Moreno Maza http://www.csd.uwo.ca/~moreno/cs3350_moreno/index.html Department of Computer Science University of Western Ontario, Canada

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

Mips Code Examples Peter Rounce

Mips Code Examples Peter Rounce Mips Code Examples Peter Rounce P.Rounce@cs.ucl.ac.uk Some C Examples Assignment : int j = 10 ; // space must be allocated to variable j Possibility 1: j is stored in a register, i.e. register $2 then

More information

Chapter 2. Instruction Set Architecture (ISA)

Chapter 2. Instruction Set Architecture (ISA) Chapter 2 Instruction Set Architecture (ISA) MIPS arithmetic Design Principle: simplicity favors regularity. Why? Of course this complicates some things... C code: A = B + C + D; E = F - A; MIPS code:

More information

Concocting an Instruction Set

Concocting an Instruction Set Concocting an Instruction Set Nerd Chef at work. move flour,bowl add milk,bowl add egg,bowl move bowl,mixer rotate mixer... Read: Chapter 2.1-2.7 L03 Instruction Set 1 A General-Purpose Computer The von

More information

Assembly Language. Prof. Dr. Antônio Augusto Fröhlich. Sep 2006

Assembly Language. Prof. Dr. Antônio Augusto Fröhlich.   Sep 2006 Sep 2006 Prof. Antônio Augusto Fröhlich (http://www.lisha.ufsc.br) 33 Assembly Language Prof. Dr. Antônio Augusto Fröhlich guto@lisha.ufsc.br http://www.lisha.ufsc.br/~guto Sep 2006 Sep 2006 Prof. Antônio

More information

Computer Architecture

Computer Architecture Computer Architecture Chapter 2 Instructions: Language of the Computer Fall 2005 Department of Computer Science Kent State University Assembly Language Encodes machine instructions using symbols and numbers

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

1/26/2014. Previously. CSE 2021: Computer Organization. The Load/Store Family (1) Memory Organization. The Load/Store Family (2)

1/26/2014. Previously. CSE 2021: Computer Organization. The Load/Store Family (1) Memory Organization. The Load/Store Family (2) CSE 202: Computer Organization Lecture-4 Code Translation-2 Memory, Data transfer instructions, Data segment,, Procedures, Stack Shakil M. Khan (adapted from Prof. Roumani) Previously Registers $s0 - $s7,

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

Previously. CSE 2021: Computer Organization. Memory Organization. The Load/Store Family (1) 5/26/2011. Used to transfer data to/from DRAM.

Previously. CSE 2021: Computer Organization. Memory Organization. The Load/Store Family (1) 5/26/2011. Used to transfer data to/from DRAM. CSE 2021: Computer Organization Lecture-4 Code Translation-2 Memory, Data transfer instructions, Data segment,, Procedures, Stack Shakil M. Khan (adapted from Profs. Roumani & Asif) Previously Registers

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

CS3350B Computer Architecture MIPS Introduction

CS3350B Computer Architecture MIPS Introduction CS3350B Computer Architecture MIPS Introduction Marc Moreno Maza http://www.csd.uwo.ca/~moreno/cs3350_moreno/index.html Department of Computer Science University of Western Ontario, Canada Thursday January

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

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

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

Review. Lecture #9 MIPS Logical & Shift Ops, and Instruction Representation I Logical Operators (1/3) Bitwise Operations

Review. Lecture #9 MIPS Logical & Shift Ops, and Instruction Representation I Logical Operators (1/3) Bitwise Operations CS6C L9 MIPS Logical & Shift Ops, and Instruction Representation I () inst.eecs.berkeley.edu/~cs6c CS6C : Machine Structures Lecture #9 MIPS Logical & Shift Ops, and Instruction Representation I 25-9-28

More information

Lecture 5: Procedure Calls

Lecture 5: Procedure Calls Lecture 5: Procedure Calls Today s topics: Memory layout, numbers, control instructions Procedure calls 1 Memory Organization The space allocated on stack by a procedure is termed the activation record

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

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

All instructions have 3 operands Operand order is fixed (destination first)

All instructions have 3 operands Operand order is fixed (destination first) Instruction Set Architecture for MIPS Processors Overview Dr. Arjan Durresi Louisiana State University Baton Rouge, LA 70803 durresi@csc.lsu.edu These slides are available at: http://www.csc.lsu.edu/~durresi/_07/

More information

A General-Purpose Computer The von Neumann Model. Concocting an Instruction Set. Meaning of an Instruction. Anatomy of an Instruction

A General-Purpose Computer The von Neumann Model. Concocting an Instruction Set. Meaning of an Instruction. Anatomy of an Instruction page 1 Concocting an Instruction Set Nerd Chef at work. move flour,bowl add milk,bowl add egg,bowl move bowl,mixer rotate mixer... A General-Purpose Computer The von Neumann Model Many architectural approaches

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

Instruction Set Design and Architecture

Instruction Set Design and Architecture Instruction Set Design and Architecture COE608: Computer Organization and Architecture Dr. Gul N. Khan http://www.ee.ryerson.ca/~gnkhan Electrical and Computer Engineering Ryerson University Overview Computer

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

Lectures 3-4: MIPS instructions

Lectures 3-4: MIPS instructions Lectures 3-4: MIPS instructions Motivation Learn how a processor s native language looks like Discover the most important software-hardware interface MIPS Microprocessor without Interlocked Pipeline Stages

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

Computer Organization and Structure. Bing-Yu Chen National Taiwan University

Computer Organization and Structure. Bing-Yu Chen National Taiwan University Computer Organization and Structure Bing-Yu Chen National Taiwan University Instructions: Language of the Computer Operations and Operands of the Computer Hardware Signed and Unsigned Numbers Representing

More information

CS 351 Exam 2 Mon. 11/2/2015

CS 351 Exam 2 Mon. 11/2/2015 CS 351 Exam 2 Mon. 11/2/2015 Name: Rules and Hints The MIPS cheat sheet and datapath diagram are attached at the end of this exam for your reference. You may use one handwritten 8.5 11 cheat sheet (front

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

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

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

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

ECE369. Chapter 2 ECE369

ECE369. Chapter 2 ECE369 Chapter 2 1 Instruction Set Architecture A very important abstraction interface between hardware and low-level software standardizes instructions, machine language bit patterns, etc. advantage: different

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

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

Concocting an Instruction Set

Concocting an Instruction Set Concocting an Instruction Set Nerd Chef at work. move flour,bowl add milk,bowl add egg,bowl move bowl,mixer rotate mixer... Read: Chapter 2.1-2.6 L04 Instruction Set 1 A General-Purpose Computer The von

More information

ECE 331 Hardware Organization and Design. Professor Jay Taneja UMass ECE - Discussion 3 2/8/2018

ECE 331 Hardware Organization and Design. Professor Jay Taneja UMass ECE - Discussion 3 2/8/2018 ECE 331 Hardware Organization and Design Professor Jay Taneja UMass ECE - jtaneja@umass.edu Discussion 3 2/8/2018 Study Jams Leader: Chris Bartoli Tuesday 5:30-6:45pm Elab 325 Wednesday 8:30-9:45pm Elab

More information

Computer Architecture Instruction Set Architecture part 2. Mehran Rezaei

Computer Architecture Instruction Set Architecture part 2. Mehran Rezaei Computer Architecture Instruction Set Architecture part 2 Mehran Rezaei Review Execution Cycle Levels of Computer Languages Stored Program Computer/Instruction Execution Cycle SPIM, a MIPS Interpreter

More information

Q1: /30 Q2: /25 Q3: /45. Total: /100

Q1: /30 Q2: /25 Q3: /45. Total: /100 ECE 2035(A) Programming for Hardware/Software Systems Fall 2013 Exam One September 19 th 2013 This is a closed book, closed note texam. Calculators are not permitted. Please work the exam in pencil and

More information

CS61C : Machine Structures

CS61C : Machine Structures inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures $2M 3D camera Lecture 8 MIPS Instruction Representation I Instructor: Miki Lustig 2014-09-17 August 25: The final ISA showdown: Is ARM, x86, or

More information

UCB CS61C : Machine Structures

UCB CS61C : Machine Structures inst.eecs.berkeley.edu/~cs61c UCB CS61C : Machine Structures Guest Lecturer Alan Christopher Lecture 08 MIPS Instruction Representation I 2014-02-07 BOINC MORE THAN JUST SETI@HOME BOINC (developed here

More information

Week 10: Assembly Programming

Week 10: Assembly Programming Week 10: Assembly Programming Arithmetic instructions Instruction Opcode/Function Syntax Operation add 100000 $d, $s, $t $d = $s + $t addu 100001 $d, $s, $t $d = $s + $t addi 001000 $t, $s, i $t = $s +

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

ECE 2035 Programming HW/SW Systems Spring problems, 6 pages Exam Two 11 March Your Name (please print) total

ECE 2035 Programming HW/SW Systems Spring problems, 6 pages Exam Two 11 March Your Name (please print) total 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

Rui Wang, Assistant professor Dept. of Information and Communication Tongji University.

Rui Wang, Assistant professor Dept. of Information and Communication Tongji University. Instructions: ti Language of the Computer Rui Wang, Assistant professor Dept. of Information and Communication Tongji University it Email: ruiwang@tongji.edu.cn Computer Hierarchy Levels Language understood

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

COMPUTER ORGANIZATION AND DESIGN

COMPUTER ORGANIZATION AND DESIGN COMPUTER ORGANIZATION AND DESIGN 5 th The Hardware/Software Interface Edition Chapter 2 Instructions: Language of the Computer 2.1 Introduction Instruction Set The repertoire of instructions of a computer

More information

CSE 141 Computer Architecture Spring Lecture 3 Instruction Set Architecute. Course Schedule. Announcements

CSE 141 Computer Architecture Spring Lecture 3 Instruction Set Architecute. Course Schedule. Announcements CSE141: Introduction to Computer Architecture CSE 141 Computer Architecture Spring 2005 Lecture 3 Instruction Set Architecute Pramod V. Argade April 4, 2005 Instructor: TAs: Pramod V. Argade (p2argade@cs.ucsd.edu)

More information

Unsigned Binary Integers

Unsigned Binary Integers Unsigned Binary Integers Given an n-bit number x x n 1 n 2 1 0 n 12 xn 22 x12 x02 Range: 0 to +2 n 1 Example 2.4 Signed and Unsigned Numbers 0000 0000 0000 0000 0000 0000 0000 1011 2 = 0 + + 1 2 3 + 0

More information

Unsigned Binary Integers

Unsigned Binary Integers Unsigned Binary Integers Given an n-bit number x x n 1 n 2 1 0 n 12 xn 22 x12 x02 Range: 0 to +2 n 1 Example 2.4 Signed and Unsigned Numbers 0000 0000 0000 0000 0000 0000 0000 1011 2 = 0 + + 1 2 3 + 0

More information