Computer Architecture. MIPS Instruction Set Architecture

Similar documents
Reduced Instruction Set Computer (RISC)

Computer Architecture. The Language of the Machine

Reduced Instruction Set Computer (RISC)

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

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

The MIPS Instruction Set Architecture

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

MIPS Instruction Set

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

M2 Instruction Set Architecture

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

CISC 662 Graduate Computer Architecture. Lecture 4 - ISA

Course Administration

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

MIPS Reference Guide

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

CS3350B Computer Architecture MIPS Instruction Representation

Computer Architecture

Chapter 2A Instructions: Language of the Computer

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

MIPS Instruction Format

Instructions: Language of the Computer

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

TSK3000A - Generic Instructions

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 Two 11 March Your Name (please print) total

MIPS%Assembly% E155%

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

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

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

Instruction Set Principles. (Appendix B)

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

F. Appendix 6 MIPS Instruction Reference

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

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

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

MIPS Instruction Reference

ECE 2035 Programming HW/SW Systems Fall problems, 6 pages Exam Two 23 October Your Name (please print clearly) Signed.

SPIM Instruction Set

MIPS Assembly Language. Today s Lecture

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

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

Review of instruction set architectures

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

ECE468 Computer Organization & Architecture. MIPS Instruction Set Architecture

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

Processor. Han Wang CS3410, Spring 2012 Computer Science Cornell University. See P&H Chapter , 4.1 4

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

CENG3420 Lecture 03 Review

Mark Redekopp, All rights reserved. EE 352 Unit 3 MIPS ISA

ECE 2035 Programming HW/SW Systems Fall problems, 6 pages Exam Two 21 October 2016

Computer Organization & Design

CPS311 - COMPUTER ORGANIZATION. A bit of history

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

EE 109 Unit 13 MIPS Instruction Set. Instruction Set Architecture (ISA) Components of an ISA INSTRUCTION SET OVERVIEW

Review: MIPS Organization

Examples of branch instructions

ECE 2035 Programming HW/SW Systems Fall problems, 6 pages Exam One 22 September Your Name (please print clearly) Signed.

Instructions: Language of the Computer

ECE 15B Computer Organization Spring 2010

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

ECE 2035 Programming HW/SW Systems Fall problems, 6 pages Exam One 19 September 2012

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

CS/COE1541: Introduction to Computer Architecture

CS 4200/5200 Computer Architecture I

Flow of Control -- Conditional branch instructions

Assembly Programming

CMPE324 Computer Architecture Lecture 2

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

Anne Bracy CS 3410 Computer Science Cornell University. See P&H Chapter: , , Appendix B

Concocting an Instruction Set

EE 109 Unit 8 MIPS Instruction Set

INSTRUCTION SET COMPARISONS

Arithmetic for Computers

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

Chapter 2: Instructions:

ECE331: Hardware Organization and Design

ISA and RISCV. CASS 2018 Lavanya Ramapantulu

COMPSCI 313 S Computer Organization. 7 MIPS Instruction Set

Instruction Set Architecture part 1 (Introduction) Mehran Rezaei

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

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

Computer Organization MIPS ISA

EE108B Lecture 3. MIPS Assembly Language II

MIPS Assembly Language

Digital System Design II

EEC 581 Computer Architecture Lecture 1 Review MIPS

CS61CL Machine Structures. Lec 5 Instruction Set Architecture

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

Procedure Calling. Procedure Calling. Register Usage. 25 September CSE2021 Computer Organization

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

Outline. EEL-4713 Computer Architecture Multipliers and shifters. Deriving requirements of ALU. MIPS arithmetic instructions

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

software hardware Which is easier to change/design???

CS3350B Computer Architecture

2.7 Supporting Procedures in hardware. Why procedures or functions? Procedure calls

ECE 2035 A Programming Hw/Sw Systems Fall problems, 8 pages Final Exam 8 December 2014

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

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

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

Transcription:

Computer Architecture MIPS Instruction Set Architecture

Instruction Set Architecture An Abstract Data Type Objects Registers & Memory Operations Instructions Goal of Instruction Set Architecture Design To allow high-performance & low-cost implementations while satisfying constraints imposed by applications including operating system and complier Computer Architecture & Network Lab

Instruction Set Architecture as an ADT (Review) Assumptions 8 bit ISA # of registers = 4 + PC (Program Counter) Memory size = 64B 63 Memory 63 Memory r 3 8 1 r r 1 r PC Registers 1 4 3 1 3 1 7 4 (j 15) (beq r, r 1, ) (sw r 3, (r )) (lw r, 1(r )) (add r 1, r, r 3 ) add r 1, r, r 3 r 3 8 1 r r 1 r PC Registers 1 4 3 1 3 1 7 4 (j 15) (beq r, r 1, ) (sw r 3, (r )) (lw r, 1(r )) (add r 1, r, r 3 ) Before Register and Memory After Register and Memory Computer Architecture & Network Lab 3

Instruction Set Architecture as an ADT (Review) Assumptions 8 bit ISA # of registers = 4 + PC (Program Counter) Memory size = 64B 63 Memory 63 Memory r 3 8 1 r r 1 r PC Registers 1 4 3 1 3 1 7 4 (j 15) (beq r, r 1, ) (sw r 3, (r )) (lw r, 1(r )) (add r 1, r, r 3 ) lw r, 1(r ) r 3 8 7 r r 1 r PC Registers 4 3 1 3 1 7 4 (j 15) (beq r, r 1, ) (sw r 3, (r )) (lw r, 1(r )) (add r 1, r, r 3 ) Before Register and Memory After Register and Memory Computer Architecture & Network Lab 4

Instruction Set Architecture as an ADT (Review) Assumptions 8 bit ISA # of registers = 4 + PC (Program Counter) Memory size = 64B 63 Memory 63 Memory r 3 8 7 r r 1 r PC Registers 4 3 1 3 1 7 4 (j 15) (beq r, r 1, ) (sw r 3, (r )) (lw r, 1(r )) (add r 1, r, r 3 ) sw r 3, (r ) r 3 8 7 r r 1 r PC Registers 3 4 3 1 3 1 7 8 4 (j 15) (beq r, r 1, ) (sw r 3, (r )) (lw r, 1(r )) (add r 1, r, r 3 ) Before Register and Memory After Register and Memory Computer Architecture & Network Lab 5

Instruction Set Architecture as an ADT (Review) Assumptions 8 bit ISA # of registers = 4 + PC (Program Counter) Memory size = 64B 63 Memory 63 Memory r 3 8 7 r r 1 r PC Registers 3 4 3 1 3 1 7 8 4 (j 15) (beq r, r 1, ) (sw r 3, (r )) (lw r, 1(r )) (add r 1, r, r 3 ) beq r, r 1, r 3 8 7 r r 1 r PC Registers 4 4 3 1 3 1 7 8 4 (j 15) (beq r, r 1, ) (sw r 3, (r )) (lw r, 1(r )) (add r 1, r, r 3 ) Before Register and Memory After Register and Memory Computer Architecture & Network Lab 6

Instruction Set Architecture as an ADT (Review) Assumptions 8 bit ISA # of registers = 4 + PC (Program Counter) Memory size = 64B 63 Memory 63 Memory r 3 8 7 r r 1 r PC Registers 4 4 3 1 3 1 7 8 4 (j 15) (beq r, r 1, ) (sw r 3, (r )) (lw r, 1(r )) (add r 1, r, r 3 ) j 15 r 3 8 7 r r 1 r PC Registers 15 4 3 1 3 1 7 8 4 (j 15) (beq r, r 1, ) (sw r 3, (r )) (lw r, 1(r )) (add r 1, r, r 3 ) Before Register and Memory After Register and Memory Computer Architecture & Network Lab 7

Examples of ISAs and Implementations Instruction Set Architectures IBM System/36, IA-3 (x86), IA-64, MIPS, SPARC, Alpha, PA- RISC, ARM, Implementations IA-3 (x86) Intel: 886, 888, 8186, 886, 8386, 8486, Pentium, Pentium Pro, Pentium II, Celeron, Pentium III, Pentium 4, AMD: K5, K6, K6-II, K6-III, Athlon, Duron, Cyrix: 8486, 5x86, 6x86, IA-64: Itanium, Itanium, Alpha: 164, 1164, 164, 1364, Computer Architecture & Network Lab 8

History Hot topics in Computer Architecture High-level language computer architectures in the 197s RISC architectures in the early 198s Shared-memory multiprocessors in the late 198s Out-of-order speculative execution processors in the 199s Multi-core architectures in the s From Single-Chip Multiprocessors: the Rebirth of Parallel Architecture by Prof. Guri Sohi Computer Architecture & Network Lab 9

A Critical point in VLSI Technology Source: www.icknowledge.com Computer Architecture & Network Lab 1

History of RISC Architecture Integration of processors on a single chip A critical point ( epoch ) Argued for different architectures (RISC) Small repertoire of instructions in a uniform format Pipelined execution Cache memory Load/store architecture More transistors allowed for different optimizations Large/multi-level caches Co-processors Superscalar etc From Single-Chip Multiprocessors: the Rebirth of Parallel Architecture by Prof. Guri Sohi Computer Architecture & Network Lab 11

MIPS Instruction Set Architecture One of the Pioneering RISC Instruction Set Architectures Small repertoire of instructions in a uniform format Pipelined execution Cache memory Load/store architecture Starts with a 3-bit architecture, later extended to 64-bit Even currently used in many embedded applications Game consoles Nintendo 64, PlayStation, PlayStation, etc Network devices IP phone, WLAN Access points, etc Residential Devices High Definition TV, Digital Photo Frame, etc Computer Architecture & Network Lab 1

MIPS ISA State (Register & Memory) Register Memory $31 xffff ffff $1 $ PC LO HI 3 words = 3 bytes x Computer Architecture & Network Lab 13

MIPS Register Usage (Software Convention for Interoperability) $zero constant 1 $at reserved for assembler $v return values 3 $v1 4 $a arguments 5 $a1 6 $a 7 $a3 8 $t temporary 15 $t7 16 $s permanent 3 $s7 4 $t8 temporary 5 $t9 6 $k OS kernel (reserved) 7 $k1 (For variables in a high-level language program) 8 $gp global pointer 9 $sp stack pointer 3 $fp frame pointer 31 $ra return address Computer Architecture & Network Lab 14

MIPS Instructions Arithmetic/Logic instructions Data Transfer (Load/Store) instructions Conditional branch instructions Unconditional jump instructions Computer Architecture & Network Lab 15

MIPS Instruction Format Name Fields Comments Field size 6bits 5bits 5bits 5bits 5bits 6bits All MIPS insturctions 3 bits R-format op rs rt rd shamt funct Arithmetic instruction format I-format op rs rt address/immediate Transfer, branch, imm. format J-format op target address Jump instruction format Computer Architecture & Network Lab 16

MIPS Integer Arithmetic Instructions Category Instruction Ex ample Meaning Comments Arithmetic add add $s1, $s, $s3 $s1 = $s + $s3 3 operands; exception possible add immediate addi $s1, $s, 1 $s1 = $s + 1 + constant; exception possible add unsigned addu $s1, $s, $s3 $s1 = $s + $s3 3 operands; no exceptions add immediate unsigned addiu $s1, $s, 1 $s1 = $s + 1 + constant; no exceptions subtract sub $s1, $s, $s3 $s1 = $s - $s3 3 operands; exception possible subtract unsigned subu $s1, $s, $s3 $s1 = $s - $s3 3 operands; no exceptions set less than slt $s1, $s, $s3 $s1 = ($s < $s3) compare signed < set less than immediate slti $s1, $s, 1 $s1 = ($s < 1) compare signed < constant set less than unsigned sltu $s1, $s, $s3 $s1 = ($s < $s3) compare unsigned < set less than immediate unsigned sltiu $s1, $s, 1 $s1 = ($s < 1) compare unsigned < constant Computer Architecture & Network Lab 17

MIPS Integer Arithmetic Instructions Category Instruction Ex ample Meaning Comments Arithmetic multiply mult $s, $s3 HI, LO $s x $s3 64 bit signed product multiply unsigned multu $s, $s3 HI, LO $s x $s3 64 bit unsigned product divide div $s, $s3 LO $s $s3, LO quotient HI $s mod $s3 HI remainder divide unsigned divu $s, $s3 LO $s $s3, Unsigned quotient HI $ s mod $ s3 Unsigned remainder mov e from HI mfhi $ s1 $s1 HI Used to get copy of HI mov e from LO mflo $ s1 $s1 LO Used to get copy of LO Computer Architecture & Network Lab 18

MIPS Logical Instructions Category Instruction Ex ample Meaning Comments Logical and and $s1, $s, $s3 $s1 = $s & $s3 Thee reg. operands; bit-by-bit AND and immediate andi $s1, $s, 1 $s1 = $s & 1 Bit-by-Bit AND reg with constant or or $s1, $s, $s3 $s1 = $s $s3 Thee reg. operands; bit-by-bit OR or immediate ori $s1, $s, 1 $s1 = $s 1 Bit-by-Bit OR reg with constant xor xor $s1, $s, $s3 $s1 = $s xor $s3 Logical XOR x or immediate xori $s1, $s, 1 $s1 = $s xor 1 Logical XOR w/ constant nor nor $s1, $s, $s3 $s1 = ($s $s3) Logical NOR shift left logical sll $s1, $s, 1 $s1 = $s 1 Shift left by constant shift right logical srl $s1, $s, 1 $s1 = $s 1 Shift right by constant shift right arithmetic sra $s1, $s, 1 $s1 = $s 1 Shift right (sign extended) shift left logical variable sllv $s1, $s, $s3 $s1 = $s $s3 Shift left by variable shift right logical variable srlv $s1, $s, $s3 $s1 = $s $s3 Shift right by variable shift right arithmetic variable srav $s1, $s, $s3 $s1 = $s $s3 Shift right arithmetic by variable load upper immediate lui $s1, 4 $s1 = 4 16 Places immediate into upper 16 bits Computer Architecture & Network Lab 19

MIPS Data Transfer (Load/Store) Instructions Category Instruction Ex ample Meaning Comments Date store word sw $s1, 1($s) Memory[$s + 1] = $s1 Word from register to memory transfer store halfword sh $s1, 1($s) Memory[$s + 1] = $s1 Store only lower 16 bits store byte sb $s1, 1($s) Memory[$s + 1] = $s1 Store only lowest byte store float swc1$f1,1($s) Memory[$s + 1] = $f1 Store FP word load word lw $s1, 1($s) $s1 = Memory[$s + 1] Load word load halfword lh $s1, 1($s) $s1 = Memory[$s + 1] Load halfword; sign extended load half unsigned lhu $s1, 1($s) $s1 = Memory[$s + 1] Load halfword; zero extended load byte lb $s1, 1($s) $s1 = Memory[$s + 1] Load byte; sign extended load byte unsigned lbu $s1, 1($s) $s1 = Memory[$s + 1] Load byte; zero extended load float lwc1 $f1,1($s) $f1 = Memory[$s + 1] Load FP register load upper immediate lui $s1, 1 $s1 = 1 * 16 Loads constant in upper 16 bits Computer Architecture & Network Lab

More about Loads and Stores All memory accesses are exclusively through loads and stores (load-store architecture) Alignment restriction Word addresses must be multiples of 4 Halfword addresses must be multiples of Partial word (halfword or byte) loads from memory Sign-extended for signed operations Zero-extended for unsigned operations Computer Architecture & Network Lab 1

More about Loads and Stores Big Endian vs. Little Endian MSB a b c d LSB ( at address ) 3 1 d c b a 3 1 a b c d Big Endian Little Endian (Macintosh, Sun SPARC) (DEC Station 31, Intel 8x86) Computer Architecture & Network Lab

MIPS Conditional Branch Instructions Category Instruction Ex ample Meaning Comments conditional branch branch on equal beq $ s1, $ s, L if($ s1==$ s) go to L Equal test and branch branch on not equal bne $s1, $s, L if($s1!=$s) go to L Not equal test and branch Computer Architecture & Network Lab 3

MIPS Unconditional Jump Instructions Category Instruction Ex ample Meaning Comments Unconditional jump jump j 5 go to 1 Jump to target address jump register jr $ ra go to $ ra For switch, procedure return jump and link jal 5 $ ra = PC + 4 For procedure call go to 1 Computer Architecture & Network Lab 4

MIPS Addressing Modes Operand in instruction itself Immediate addressing op rs rt Immediate Operand in register Register addressing op rs rt rd funct Registers Register Operand in Memory Base addressing op rs rt Address Memory Register + Byte Halfword Word Computer Architecture & Network Lab 5

MIPS Addressing Modes Instruction in memory PC-relative addressing (branch) op rs rt Address Memory PC + Word Pseudo-direct addressing (jump) op Address Memory 4bits PC : Word Computer Architecture & Network Lab 6

MIPS Addressing Modes Instruction in memory Register (jump register) op rs Memory Register Word Computer Architecture & Network Lab 7

Addressing Modes (Many not supported in MIPS) Addressing mode Example Instruction Meaning When used Register Add R4, R5, R3 R4 R5 + R3 When a value is in a register. Immediate or literal Add R4, R5, #3 R4 R5 + 3 For constants. Displacement or based Register deferred or indirect Add R4, R5, 1(R1) R4 R5 + M[1+R1] Accessing local variables. Add R4, R5, (R1) R4 R5 + M[R1] Accessing using a pointer or a computed address. Indexed Add R3, R5, (R1+R) R3 R5 + M[R1+R] Sometimes useful in array addressing R1=base of array, R=index amount. Direct or absolute Add R1, R5, (11) R1 R5 + M[11] Sometimes useful for accessing static data: address constant may need to be large. Memory indirect or memory deferred Add R1, R5, @(R3) R1 R5 + M[M[R3]] If R3 is the address of a pointer p, then mode yields *p. Auto-increment Add R1, R5, (R)+ R1 R5 + M[R] Useful for stepping through arrays within a loop. R R + d R pointers to start of array; each reference increments R by size of an element, d. Auto-decrement Add R1, R5, -(R) R R - d R1 R5 + M[R] Same use as autoincrement. Autoincrement/decrement can also be used to implement a stack as push and pop. Scaled or index Add R1, R5, 1(R)[R3] R1 R5 + Used to index arrays. May be applied to any base M[1+R+R3*d] addressing mode in some machines. Computer Architecture & Network Lab 8

C vs. Assembly C f = (g + h) (i + j); f is mapped to s g is mapped to s1 h is mapped to s i is mapped to s3 j is mapped to s4 Assembly add $t, $s1, $s add $t1, $s3, $s4 sub $s, $t, $t1 Computer Architecture & Network Lab 9

C vs. Assembly C g = h + A[i]; g is mapped to s1 h is mapped to s s3 contains the base address of array A[]. i is mapped to s4. Assembly add $t1, $s4, $s4 add $t1, $t1, $t1 add $t1, $t1, $s3 lw $t, ($t1) add $s1, $s, $t Computer Architecture & Network Lab 3

C vs. Assembly if (i == j) else C f = g + h; f = g h; Assembly bne $s3, $s4, Else add $s, $s1, $s j Exit Else: sub $s, $s1, $s Exit: f is mapped to s g is mapped to s1 h is mapped to s i is mapped to s3 j is mapped to s4 Computer Architecture & Network Lab 31

C vs. Assembly C while (save[i] == k) i = i + j; i is mapped to s3 j is mapped to s4 k is mapped to s5 s6 contains the base address of array save[]. Assembly Loop: add $t1, $s3, $s3 add $t1, $t1, $t1 add $t1, $t1, $s6 lw $t, ($t1) bne $t, $s5, Exit add $s3, $s3, $s4 j Loop Exit: Computer Architecture & Network Lab 3

C vs. Assembly C switch (k) { case : f = i + j; break; case 1: f = g + h; break; case : f = g - h; break; case 3: f = i - j; break; } f is mapped to s g is mapped to s1 h is mapped to s i is mapped to s3 j is mapped to s4 k is mapped to s5 t contains 4 Assembly slt $t3, $s5, $zero bne $t3, $zero, Exit slt $t3, $s5, $t beq $t3, $zero, Exit add $t1, $s5, $s5 add $t1, $t1, $t1 add $t1, $t1, $t4 lw $t, ($t1) jr $t L: add $s, $s3, $s4 j Exit L1: add $s, $s1, $s j Exit L: sub $s, $s1, $s j Exit L3: sub $s, $s3, $s4 Exit Computer Architecture & Network Lab 33

Pseudo Instructions Pseudo instruction : Instructions that are available in assembly language but not implemented in hardware Pseudo instruction examples Pseudo instruction Equivalent real instruction sequence move $s1, $s add $s1, $zero, $s blt $s1, $s, label slt $at, $s1, $s bne $at, $zero, label abs $s1, $s add $s1, $zero, $s slt $at, $s, $zero beq $at, $zero, L sub $s1, $zero, $s1 L: Computer Architecture & Network Lab 34