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

Similar documents
Instruction Set Architecture of MIPS Processor

The MIPS Instruction Set Architecture

Review: MIPS Organization

Reduced Instruction Set Computer (RISC)

Computer Architecture. The Language of the Machine

Reduced Instruction Set Computer (RISC)

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

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

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

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

Computer Architecture. MIPS Instruction Set Architecture

MIPS Instruction Set

CISC 662 Graduate Computer Architecture. Lecture 4 - ISA

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

MIPS Instruction Reference

M2 Instruction Set Architecture

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

5DV118 Computer Organization and Architecture Umeå University Department of Computing Science Stephen J. Hegner. Topic 3: Arithmetic

Computer Architecture. Chapter 3: Arithmetic for Computers

CS3350B Computer Architecture MIPS Instruction Representation

MIPS Instruction Format

Computer Architecture

MIPS Instructions: 64-bit Core Subset

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

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

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

ICS 233 COMPUTER ARCHITECTURE. MIPS Processor Design Multicycle Implementation

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

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

F. Appendix 6 MIPS Instruction Reference

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

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

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

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

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

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

Anne Bracy CS 3410 Computer Science Cornell University. [K. Bala, A. Bracy, E. Sirer, and H. Weatherspoon]

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

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

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

Arithmetic for Computers

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

MIPS Reference Guide

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

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

CPS311 - COMPUTER ORGANIZATION. A bit of history

Instructions: Language of the Computer

Instruction Set Architecture part 1 (Introduction) Mehran Rezaei

ECE260: Fundamentals of Computer Engineering

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

Assembly Programming

EE 109 Unit 8 MIPS Instruction Set

MIPS ISA and MIPS Assembly. CS301 Prof. Szajda

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

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

CS 4200/5200 Computer Architecture I

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

Instruction Set Principles. (Appendix B)

ECE260: Fundamentals of Computer Engineering

Midterm. Sticker winners: if you got >= 50 / 67

Number Systems and Their Representations

COMPUTER ORGANIZATION AND DESIGN

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

UCB CS61C : Machine Structures

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

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

The MIPS R2000 Instruction Set

ISA and RISCV. CASS 2018 Lavanya Ramapantulu

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

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

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

A Model RISC Processor. DLX Architecture

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

Instruction Set Architecture. "Speaking with the computer"

TSK3000A - Generic 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!

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

MIPS Assembly Language. Today s Lecture

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

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

CS61C : Machine Structures

INSTRUCTION SET COMPARISONS

CS222: MIPS Instruction Set

ece4750-parc-isa.txt

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

COMPUTER ORGANIZATION AND DESIGN

Instruction Set Architecture (ISA)

ECE468 Computer Organization & Architecture. MIPS Instruction Set Architecture

Chapter 3 Arithmetic for Computers

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

Lecture Topics. Announcements. Today: The MIPS ISA (P&H ) Next: continued. Milestone #1 (due 1/26) Milestone #2 (due 2/2)

CS61CL Machine Structures. Lec 5 Instruction Set Architecture

Flow of Control -- Conditional branch instructions

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

Project Part A: Single Cycle Processor

ECE 154A Introduction to. Fall 2012

ISA: The Hardware Software Interface

SPIM Instruction Set

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

Chapter 2. Instructions:

Transcription:

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 $0 $31 Control Presentation B Prog. Counter Lo Hi Arithmetic unit Slides by Gojko Babić Figure A.10.1 Coprocessor 0 (traps and memory) Registers BadVAddr Cause Status EPC 06/21/2005 g. babic Presentation B 2 MIPS Registers CPU: 32 32-bit general purpose registers GPRs (r0 r31); r0 has fixed value of zero. Attempt to writing into r0 is not illegal, but its value will not change; two 32-bit registers Hi & Lo, hold results of integer multiply and divide 32-bit program counter PC; Floating Point Processor FPU (Coprocessor 1 CP1): 32 32-bit floating point registers FPRs (f0 f31); five control registers; g. babic Presentation B 3 MIPS Registers (continued) Coprocessor 0 CP0 is incorporated on the MIPS CPU chip and it provides functions necessary to support operating system: exception handling, memory management scheduling and control of critical resources. Coprocessor 0 (CP0) registers (partial list): Status register (CP0reg12) processor status and control; Cause register (CP0reg13) cause of the most recent exception; EPC register (CP0reg14) program counter at the last exception; BadVAddr register (CP0reg08) the address for the most recent address related exception; g. babic Presentation B 4

MIPS Data Types MIPS operates on: 32-bit (unsigned or 2 s complement) integers, 32-bit (single precision floating point) real numbers, 64-bit (double precision floating point) real numbers; bytes and half words loaded into GPRs are either zero or sign bit expanded to fill the 32 bits; only 32-bit units can be loaded into FPRs; 32-bit real numbers are stored in even numbered FPRs. 64-bit real numbers are stored in two consecutive FPRs, starting with even-numbered register. MIPS arithmetic All instructions have 3 operands Operand order is fixed (destination first) Example: C code: a = b + c MIPS code : add a, b, c The natural number of operands for an operation like addition is three requiring every instruction to have exactly three operands, no more and no less, conforms to the philosophy of keeping the hardware simple g. babic Presentation B 5 MIPS arithmetic Registers vs. Memory Design Principle: simplicity favors regularity. Of course this complicates some things... C code: a = b + c + d; MIPS code: add a, b, c add a, a, d Arithmetic instructions operands must be registers, only 32 registers provided Compiler associates variables with registers What about programs with lots of variables Operands must be registers, only 32 registers provided Each register contains 32 bits Control Memory Input Design Principle: smaller is faster. Why? Datapath Output Processor I/O

Memory Organization Viewed as a large, single-dimension array, with an address. A memory address is an index 0 8 bits of data 1 8 bits of data into the array 2 8 bits of data "Byte addressing" means that 3 8 bits of data 4 8 bits of data the index points to a byte of 5 8 bits of data memory. 6 8 bits of data... MIPS Addressing Modes register addressing; immediate addressing; only one memory data addressing: register content plus offset (register indexed); since r0 always contains value 0: r0 + offset absolute addressing; offset = 0 register indirect; MIPS supports byte addressability: it means that a byte is the smallest unit with its address; MIPS supports 32-bit addresses: it means that an address is given as 32-bit unsigned integer; g. babic Presentation B 10 Memory Organization Bytes are nice, but most data items use larger "words" For MIPS, a word is 32 bits or 4 bytes. 0 4 8 12... Registers hold 2 32 bytes with byte addresses from 0 to 2 32-1 2 30 words with byte addresses 0, 4, 8,... 2 32-4 Words are aligned i.e., what are the least 2 significant bits of a word address? MIPS Alignment MIPS restricts memory accesses to be aligned as follows: 32-bit word has to start at byte address that is multiple of 4; 32-bit word at address 4n includes four bytes with addresses 4n, 4n+1, 4n+2, and 4n+3. 16-bit half word has to start at byte address that is multiple of 2; 16-bit word at address 2n includes two bytes with addresses 2n and 2n+1. g. babic Presentation B 12

MIPS Instructions 32-bit fixed format instruction and 3 formats; register register and register-immediate computational instructions; single address mode for load/store instructions: register content + offset (called base addressing); simple branch conditions; branch instructions use PC relative addressing; branch address = [PC] + 4 + 4 offset jump instructions with: 28-bit addresses (jumps inside 256 megabyte regions), or absolute 32-bit addresses. Our First Example Can we figure out the code? Guess!!! swap(int v[], int k); { int temp; temp = v[k] v[k] = v[k+1]; v[k+1] = temp; } 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 g. babic Presentation B 13 MIPS Instruction (continued) Instructions that move data: load to register from memory, store from register to memory, move between registers in same and different coprocessors ALU integer instructions, Floating point instructions, Control-related instructions, Special control-related instructions. Stored Program Concept 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 & Execute Cycle Instructions are fetched and put into a special register Bits in the register "control" the subsequent actions Fetch the next instruction and continue g. babic Presentation B 15

MIPS Instruction Layout MIPS instructions are an example of fixed field decoding /ft /offset /ft /fs /fd and fd fs funct ft jump_target g. babic Presentation B 17 CPU Load & Store Instructions lw rt, offset(rs) ; load 32-bits: Regs[rt] Mem [offset+regs[rs]] sw rt, offset(rs) ; store 32-bits: Mem [offset+regs[rs]] Regs[rt] lb rt, offset(rs) ; load 8-bits (byte): Regs[rt] 24-bit sign-extend Mem [offset+regs[rs]] Note: means concatenation. lbu rt, offset(rs) ; load 8-bits (byte) unsigned: Regs[rt] 24-bit zero-extend Mem [offset+regs[rs]] sh rt, offset(rs) ; store 16-bits: Mem [offset+regs[rs]] Regs[rt] (16 least significant bits taken from the register) Plus: sb, lh, & lhu g. babic Presentation B 18 FP Load, Store & Move Instructions lwc1 ft, offset(rs) ; load into FP register: Regs[ft] Mem [offset+regs[rs]] swc1 ft, offset(rs) ; store from FP register: Mem [offset+regs[rs]] Regs[ft] mov.d fd, fs ; move FP double precision between FPRs: Regs[fd] Regs[fd+1] Regs[fs] Regs[fs+1] mov.s fd, fs ; move FP single precision between FPRs: Regs[fd] Regs[fs] Move Instructions mfc1 rt, fs ; move from FPU to CPU: Regs[rt] Regs[fs] mtc1 rt, fs ; move from CPU to FPU: Regs[fs] Regs[rt] mfc0 rt, rd ; move from CP0 to CPU: Regs[rt] CP0Regs[rd] mtc0 rt, rd ; move from CPU to CP0: CP0Regs[rd] Regs[rt] mfhi rd ; move from Hi: Regs[rd] Hi; mflo rd ; move from Lo: Regs[rd] Lo; g. babic Presentation B 19 g. babic Presentation B 20

ALU Integer Instructions add rd, rs, rt ; add integer@: Regs[rd] Regs[rs] + Regs[rt] Note: Instructions flagged by @ may cause an arithmetic exception. addi rt, rs, immediate ; add immediate integer@: Regs[rt] Regs[rs] + 16-bit sign-extend immediate and rd, rs, rt ; bit-wise AND 32 bits: Regs[rd] Regs[rs] AND Regs[rt] andi rt, rs, immediate ; bit-wise AND immediate 32 bits: Regs[rt] Regs[rs] AND 16-bit zero-extend immediate slt rd, rs, rt ; set less than integer: if (Regs[rs] < Regs[rt]) then Regs[rd] 1 else Regs[rd] 0 g. babic Presentation B 21 ALU Integer Instructions (continued) mul rs, rt ; multiply integer: Hi Lo Regs[rs] Regs[rt] Note: mul does not generate an arithmetic exception, since a storage for the result is always sufficiently large. div rs, rt ; divide integer: Lo Regs[rs] / Regs[rt] Hi Regs[rs] mod Regs[rt] Note: div does not generate an arithmetic exception and software should test for zero divisor. sll rd, rt, shamt ; shift left logical: Regs[rd] Regs[rt] << shamt lui rt, immediate ; load upper immediate: Regs[rt] immediate 16 zero-bits g. babic Presentation B 22 ALU Integer Instructions (continued) addu rd, rs, rt ; add unsigned integer: Regs[rd] Regs[rs] + Regs[rt] Note: This instructions does not cause an arithmetic exception. Plus: addiu, sub @, subu, mulu, divu, or, ori, xor, xori, nor, slti, sltu, sltiu, srl, sra Instructions addu, addiu, subu, mulu, divu, sltu, and sltiu operate on unsigned numbers and these instructions do not trap on overflow. They are appropriate for unsigned arithmetic, such as address arithmetic, or in integer arithmetic environment that ignores overflow, such as C language arithmetic. g. babic Presentation B 23 Arithmetic FP Instructions add.d fd, fs, ft ; FP double precision add: Regs[fd] Regs[fd+1] Regs[fs] Regs[fs+1] + Regs[ft] Regs[ft+1] mul.s fd, fs, ft ; FP single precision multiply: Regs[fd] Regs[fs] Regs[ft] Plus: add.s, sub.d, sub.s, mul.d, div.d, div.s, several convert floating point to/from integer instructions, several compare instructions. Note: Any of instructions above may cause FP exception. All instructions presented so far, in addition, increment the program counter PC by 4, i.e. PC [PC] + 4 g. babic Presentation B 24