Computer Organization MIPS Architecture. Department of Computer Science Missouri University of Science & Technology

Similar documents
CISC 662 Graduate Computer Architecture. Lecture 4 - ISA

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

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

Lecture 5: Procedure Calls

COMP 303 Computer Architecture Lecture 3. Comp 303 Computer Architecture

comp 180 Lecture 10 Outline of Lecture Procedure calls Saving and restoring registers Summary of MIPS instructions

MIPS%Assembly% E155%

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

Lecture 4: MIPS Instruction Set

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

Lecture 5: Procedure Calls

Chapter 2A Instructions: Language of the Computer

ECE232: Hardware Organization and Design

Computer Architecture

CS3350B Computer Architecture MIPS Instruction Representation

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

CS/COE1541: Introduction to Computer Architecture

CS3350B Computer Architecture MIPS Introduction

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

CENG3420 Lecture 03 Review

Branch Addressing. Jump Addressing. Target Addressing Example. The University of Adelaide, School of Computer Science 28 September 2015

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

CS222: MIPS Instruction Set

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

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

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

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

Computer Organization MIPS ISA

Reduced Instruction Set Computer (RISC)

Thomas Polzer Institut für Technische Informatik

Instruction Set Architecture

CSCI 402: Computer Architectures. Instructions: Language of the Computer (3) Fengguang Song Department of Computer & Information Science IUPUI.

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

COMPUTER ORGANIZATION AND DESIGN

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

Control Instructions

CS3350B Computer Architecture Quiz 3 March 15, 2018

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

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

COMPSCI 313 S Computer Organization. 7 MIPS Instruction Set

CS3350B Computer Architecture

Course Administration

Computer Science and Engineering 331. Midterm Examination #1. Fall Name: Solutions S.S.#:

MIPS Datapath. MIPS Registers (and the conventions associated with them) MIPS Instruction Types

Course Administration

Reduced Instruction Set Computer (RISC)

Instructions: Assembly Language

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

Instruction Set Architecture part 1 (Introduction) Mehran Rezaei

Chapter 2. Instructions:

Topic Notes: MIPS Instruction Set Architecture

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

Math 230 Assembly Programming (AKA Computer Organization) Spring MIPS Intro

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

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

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

Chapter 4. The Processor. Computer Architecture and IC Design Lab

Computer Architecture. MIPS Instruction Set Architecture

Instruction Pipelining

Instruction Pipelining

CENG3420 L03: Instruction Set Architecture

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

Lectures 3-4: MIPS instructions

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

Character Is a byte quantity (00~FF or 0~255) ASCII (American Standard Code for Information Interchange) Page 91, Fig. 2.21

ECE 30 Introduction to Computer Engineering

Chapter 2: Instructions:

Computer Architecture. The Language of the Machine

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

Do-While Example. In C++ In assembly language. do { z--; while (a == b); z = b; loop: addi $s2, $s2, -1 beq $s0, $s1, loop or $s2, $s1, $zero

Levels of Programming. Registers

The MIPS Instruction Set Architecture

CSE 378 Midterm 2/12/10 Sample Solution

Computer Architecture

Forecast. Instructions (354 Review) Basics. Basics. Instruction set architecture (ISA) is its vocabulary. Instructions are the words of a computer

MODULE 4 INSTRUCTIONS: LANGUAGE OF THE MACHINE

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

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

ECE 486/586. Computer Architecture. Lecture # 7

MIPS Instruction Set Architecture (2)

Chapter 2. Instructions: Language of the Computer

CS 61c: Great Ideas in Computer Architecture

Five classic components

CS31001 COMPUTER ORGANIZATION AND ARCHITECTURE. Debdeep Mukhopadhyay, CSE, IIT Kharagpur. Instructions and Addressing

Computer Organization Control Unit. Department of Computer Science Missouri University of Science & Technology

CS 5803 Introduction to High Performance Computer Architecture: RISC vs. CISC. A.R. Hurson 323 Computer Science Building, Missouri S&T

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

Assembly Language Programming. CPSC 252 Computer Organization Ellen Walker, Hiram College

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

A Processor. Kevin Walsh CS 3410, Spring 2010 Computer Science Cornell University. See: P&H Chapter , 4.1-3

Architecture II. Computer Systems Laboratory Sungkyunkwan University

Instruction Set Architecture. "Speaking with the computer"

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

CS 351 Exam 2 Mon. 11/2/2015

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

Mips Code Examples Peter Rounce

CSEE 3827: Fundamentals of Computer Systems

Instructions: Language of the Computer

EE 361 University of Hawaii Fall

ECE260: Fundamentals of Computer Engineering

Transcription:

Computer Organization MIPS Architecture Department of Computer Science Missouri University of Science & Technology hurson@mst.edu

Computer Organization Note, this unit will be covered in three lectures. In case you finish it earlier, then you have the following options: 1) Take the early test and start CS3889.module9 2) Study the supplement module (supplement CS3889.module88) 3) Act as a helper to help other students in studying CS3889.module8 Note, options 2 and 3 have extra credits as noted in course outline. 2

Computer Organization Enforcement of background Glossary of prerequisite topics No Familiar with the topics? Yes Review CS3889.module8background Current Module Take Test No Pass? Remedial action Yes Glossary of topics No Familiar with the topics? Take the Module Yes Take Test No Pass? Yes Options At the end give a test, record the score, and impose remedial action if not successful Study next module? Lead a group of students in this module (extra credits)? Study more advanced related topics (extra credits)? Extra Curricular activities

MIPS Microprocessor without Interlocked Pipeline Stages MIPS processors (R2000 and R3000) have 5- stage pipeline, R4000 and R4400 have 8-stage pipeline, and the number of pipeline stages for R10000 varies, based on the functional units through which the instruction must pass: Integer instructions 5 stages Load/Store 6 stages Floating point 7 stages.

MIPS Microprocessor without Interlocked Pipeline Stages First MIPS instruction set architecture was MIPS I followed by MIPS II-MIPS V. The current MIPS instruction set architecture is referred to as MIPS32 (for 32-bit architecture) and MIPS64 (for 64-bit architecture). MIPS32 has 168 32-bit instructions.

General Configuration A word addressable, 3-address machine A Load/Store instruction set Register Mode Operations 32 32 bits registers Byte Addressable Main memory Main memory is of size 2 30 * 32 Fixed instruction length of 32 bits

General Configuration MIPS Supports: Register, Base or displacement (Index) Immediate PC relative, and Pseudo direct addressing modes MIPS Supports 3 different instruction formats: R (Register) Type I (Immediate) Type J (Jump) Type

Register Configuration Name Register no. Usage $zero 0 Constant zero $v 0 -v 1 2-3 Return values $a 0 -a 3 4-7 Input parameters $t 0 -t 7 8-15 Temporary Values $s 0 -s 7 16-23 Saved Values $t 8 -t 9 24-25 Temporary Values $gp 28 Global pointer $sp 29 Stack pointer $fp 30 Frame pointer $ra 31 Return address

Register Configuration Register zero (r 0 ) is hard-wired to a value of zero, r 31 is the default register for use with certain instructions i.e., it is used as implied mode, r 1 is reserved, r 26 and r 27 are used by the operating system.

Addressing Modes Register addressing: operand is a register Base or displacement (Index): operand is at the memory location whose address is the sum of a register and a constant specified in the instruction Immediate: operand is a constant defined in the instruction PC relative: the address is the sum of the PC and a constant defined in the instruction Pseudo direct addressing: the address is the 26 bits of the value defined in the instruction concatenated with the upper 4 bits of PC.

Instruction Formats R-Type Instructions OP r s r t r d Shamt Funct 6 bits 5 bits 5 bits 5 bits 5 bits 6 bits OP: Basic operation code: op code r s : 1 st source register r t : 2 nd source register r d : destination register Shamt: Shift amount Funct: Function code: modifier to op code.

Instruction Formats R-Type Instructions (Example) add $t 0, $s 1, $s 2 0 17 18 8 0 32 000000 10001 10010 01000 00000 100000

Instruction Formats R-Type Instructions (Example) sll $t 2, $s 0, 4 (Shift $s 0 left 4 positions to $t 2 ) 0 0 16 10 4 0 000000 00000 10000 01010 00100 000000

Instruction Formats R-Type Instructions (Example) and $t 0, $t 1, $t 2 (and $t 1 with $t 2 into $t 0 ) 0 9 10 8 0 24 000000 10000 10001 01010 00000 011000

Instruction Formats I-Type Instructions r s OP r t Constant or address 5 bits 6 bits 16 bits 5 bits OP: Basic operation code: op code r s : base (index) register r t : source/destination register

Instruction Formats I-Type Instructions (Example) Assume the base address of the array A is in $s 2. lw $t 0, 32($s 2 ) (load word A[8] into $t 0 ) 35 19 8 32 100011 10001 01000 0000000000100000

Instruction Formats I-Type Instructions (Example) addi $s 3, $s 3, 4 (add constant 4 to s 3 ) 8 20 20 4 001000 10100 10100 0000000000000100

Instruction Formats Assembly code If $t 1 has the base for the array A and $s 2 corresponds to h, then write an assembly code for: A[300] = h + A[300] lw $t 0, 1200($t 1 ) add $t 0, $s 2, $t 0 sw $t 0, 1200($t 1 )

Instruction Formats Machine code 35 9 8 1200 0 18 8 8 0 32 43 9 8 1200

Instruction Formats Machine code (Binary) 100011 01001 01000 0000010010110000 000000 10010 01000 01000 00000 100000 101011 01001 01000 0000010010110000

Instruction Formats J-Type Instructions OP Address 6 bits 26 bits OP: Basic operation code: op code

Instruction Formats J-Type Instructions (Example) goto 2500 000010 00000000000010011100010000 6 bits 26 bits

Instruction Formats Instructions for making decision (If-then-else) If (i = = j) f = g + h; else f = g h; yes i = = j no f = g + h f = g - h

Instruction Formats If (i = = j) f = g + h; else f = g h; Assuming i is in S 3, j is in S 4, g is in S 1, and h is in S 2. bne $s 3, $s 4, Else goto Else if i j add $s 0, $s 1, $s 2 f = g + h j Exit Else: Sub $s 0, $s 1, $s 2 f = g h Exit:

Instruction Formats Instructions for Loops While (Save[i] = = k) i += 1 Assume Save is an array whose base is in $s 6. Also assume i and k correspond to registers $s 3 and $s 5, respectively;

Instruction Formats Loop: sll $t 1, $s 3, 2 Multiply i by 4, add $t 1, $t 1, $s 6 Calculate the effective address lw $t 0, 0($t 1 ) $t 0 = Save[i] bne $t 0, $s 5, Exit If Save[i] k goto Exit addi $s 3, $s 3, 1 i = i + 1 j Loop Repeat the loop Exit:

Instruction Formats In the previous example, if the loop is starting at location 80,000, then what is the MIPS machine code: Loop: 80000 80004 80008 80012 80016 80020 Exit: 80024 0 0 9 19 0 9 9 22 35 9 8 5 8 21 8 19 19 2 20000 4 0 0 2 1 0 32

Example Load Upper Immediate (lui) sets the upper 16 bits of a constant in a register lui $t 0, 255 001111 00000 01000 0000 0000 1111 1111 After execution $t 0 is: 0000 0000 1111 1111 0000 0000 0000 0000

Example Set register $s 0 to 0000 0000 0011 1101 0000 1001 0000 0000 lui $s 0, 61 ori $s 0, $s 0, 2304

Procedure A procedure is a sequence of instructions that performs a specific task based on its input parameters. In the execution of a procedure, the program performs the following steps: Place input parameters in a place where it is accessible by the procedure, Transfer control to the procedure, Acquire the storage resources for the procedure, Execute the procedure, Place the result in a place accessible to the calling program, Return control to the point of origin.

Procedure In MIPS: $a 0 -$a 3 are used to pass parameters, $v 0 -$v 1 are used to return values, $r a is used to return to the point of origin. The Jump-and-link instruction (jal) saves the return address and jump to the define address: jal Procedureaddress The Jump-register (jr) instruction returns the control to the point of origin: jr $r a

Procedure Assume the following subroutine was called: Int leaf_example (int g, int h, int i, int j) Int f; F = (g + h) (I + j) Return f; The parameters g, h, i, and j are input parameters and f is the return value. If this program is compiled for MIPS then we have:

Procedure The parameters g, h, i, and j correspond to $a 0 - $a 3, and f corresponds to $s 0. The compiled program starts with the label leaf_example. Internally the procedure will use some of the registers (working registers) during the execution time, as a result, the contents of these registers must be saved and restore after the execution of the subroutine. This will be done in the system stack...

Procedure addi $sp, $sp, -12 # The first four instructions allow us to save sw $t 1, 8($sp) the contents of the working registers in the sw $t 0, 4($sp) stack# sw $s 0, 0($sp) add $t 0, $a 0, $a 1 add $t 1, $a 2, $a 3 sub $s 0, $t 0, $t 1 add $v 0, $s 0, $zero lw $s 0, 0($sp) #This instruction and the next three instructions lw $t 0, 4($sp) are intended to restore the original contents of lw $t 1, 8($sp) the working registers before control transfers addi $sp, $sp, 12 to the callee procedure# jr $ra callee# #This instruction transfers the control back to

Computer Organization Instruction Cycle An instruction cycle is implemented in five basic steps: Instruction Fetch IF IR Mem [PC] NPC PC + 4 Instruction decode and register fetch ID A Regs [IR 6,..,10 ] B Regs [IR 11,..,15 ] Imm ((IR 16 ) 16 ## IR 16,..,31 )

Computer Organization Instruction Cycle Execution and effective address calculation EX Memory reference ALUoutput A + Imm Reg.-Reg. ALU instruction ALUoutput A op-code B Reg.-Immediate ALU instruction ALUoutput A op-code Imm Branch ALUoutput NPC + Imm, Cond (A op-code 0)

Computer Organization Instruction Cycle Memory access/branch completion MEM Memory reference LMD Mem [ALUoutput] or Mem [ALUoutput] B Branch If (cond.) PC ALUoutput else PC NPC

Computer Organization Instruction Cycle Write Back WB Reg.-Reg. ALU instruction Regs [IR 16,..,20 ] ALUoutput Reg.-Immediate ALU instruction Regs [IR 11,..,15 ] ALUoutput Load instruction Regs [IR 11,..,15 ] LMD

Computer Organization Pipelined instruction cycle Inst. i IF ID EX MEM WB Inst. i+1 IF ID EX MEM WB Inst. i+2 IF ID EX MEM WB Inst. i+3 IF ID EX MEM WB A pipelined instruction cycle gives a peak performance of one instruction every step.