CPE 442 Lec4.1 Intro Computer Architectures CpE 442 Computer Architecture and Engineering MIPS Instruction Set Architecture.

Slides:



Advertisements
Similar presentations
Instructor: Prof. Hany H Ammar, LCSEE, WVU
Advertisements

1 Lecture 3: MIPS Instruction Set Today’s topic:  More MIPS instructions  Procedure call/return Reminder: Assignment 1 is on the class web-page (due.
Deeper Assembly: Addressing, Conditions, Branching, and Loops
©UCB CS 161 Lecture 4 Prof. L.N. Bhuyan
ECE 232 L6.Assemb.1 Adapted from Patterson 97 ©UCBCopyright 1998 Morgan Kaufmann Publishers ECE 232 Hardware Organization and Design Lecture 6 MIPS Assembly.
CMPE 325 Computer Architecture II Cem Ergün Eastern Mediterranean University Assembly Language (cont)
1 Lecture 4: Procedure Calls Today’s topics:  Procedure calls  Large constants  The compilation process Reminder: Assignment 1 is due on Thursday.
CS1104 – Computer Organization PART 2: Computer Architecture Lecture 5 MIPS ISA & Assembly Language Programming.
ELEN 468 Advanced Logic Design
Fall EE 333 Lillevik 333f06-l4 University of Portland School of Engineering Computer Organization Lecture 4 Assembly language programming ALU and.
CPS3340 COMPUTER ARCHITECTURE Fall Semester, /17/2013 Lecture 12: Procedures Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL.
The University of Adelaide, School of Computer Science
The University of Adelaide, School of Computer Science
Procedure call frame: Hold values passed to a procedure as arguments
Computer Architecture ECE 361 Lecture 6: ALU Design
Informationsteknologi Saturday, September 29, 2007 Computer Architecture I - Class 41 Today’s class More assembly language programming.
1  1998 Morgan Kaufmann Publishers and UCB CEG3420 Computer Design Lecture 4 MIPS Instruction Set Philip Leong.
MIPS Overview (with comparisons to x86)
EECC550 - Shaaban #1 Lec # 2 Winter Reduced Instruction Set Computer (RISC) Focuses on reducing the number and complexity of instructions.
Reduced Instruction Set Computer (RISC)
CS152 / Kubiatowicz Lec2.1 8/31/01©UCB Fall 2001 August 31, 2001 John Kubiatowicz (http.cs.berkeley.edu/~kubitron) lecture slides:
361 Lec4.1 ECE 361 Computer Architecture Lecture 4: MIPS Instruction Set Architecture.
S. Barua – CPSC 440 CHAPTER 2 INSTRUCTIONS: LANGUAGE OF THE COMPUTER Goals – To get familiar with.
RISC Concepts, MIPS ISA and the Mini–MIPS project
EECC550 - Shaaban #1 Lec # 2 Winter Reduced Instruction Set Computer (RISC) Focuses on reducing the number and complexity of instructions.
EECC550 - Shaaban #1 Lec # 2 Winter (Chapter 2) Reduced Instruction Set Computer (RISC) Focuses on reducing the number and complexity of.
ECE 232 L9.Mult.1 Adapted from Patterson 97 ©UCBCopyright 1998 Morgan Kaufmann Publishers ECE 232 Hardware Organization and Design Lecture 9 Computer Arithmetic.
Lecture 7: MIPS Instruction Set Today’s topic –Procedure call/return –Large constants Reminders –Homework #2 posted, due 9/17/
Overview of Today’s Lecture
Some material taken from Assembly Language for x86 Processors by Kip Irvine © Pearson Education, 2010 Slides revised 2/2/2014 by Patrick Kelley.
83 Assembly Language Readings: Chapter 2 ( , 2.8, 2.9, 2.13, 2.15), Appendix A.10 Assembly language Simple, regular instructions – building blocks.
13/02/2009CA&O Lecture 04 by Engr. Umbreen Sabir Computer Architecture & Organization Instructions: Language of Computer Engr. Umbreen Sabir Computer Engineering.
IT253: Computer Organization Lecture 5: Assembly Language and an Introduction to MIPS Tonga Institute of Higher Education.
Lecture 4: MIPS Subroutines and x86 Architecture Professor Mike Schulte Computer Architecture ECE 201.
1. 2 Instructions: Words of the language understood by CPU Instruction set: CPU’s vocabulary Instruction Set Architecture (ISA): CPU’s vocabulary together.
EECC250 - Shaaban #1 lec #21 Winter Complex Instruction Set Computer (CISC) Emphasizes doing more with each instruction. Motivated by the high.
1 IKI20210 Pengantar Organisasi Komputer Kuliah Minggu ke-4b: Bahasa Rakitan MIPS I diadaptasikan dari materi kuliah CS61C/2000 & CS152/1997  2000/1997.
6.S078 - Computer Architecture: A Constructive Approach Introduction to SMIPS Li-Shiuan Peh Computer Science & Artificial Intelligence Lab. Massachusetts.
Chapter 10 The Assembly Process. What Assemblers Do Translates assembly language into machine code. Assigns addresses to all symbolic labels (variables.
CS152 Fall 2002 Lec 2.1 Computer Organization Lecture 2 Review of MIPS ISA and Performance Modified From the Lectures of Randy H. Katz EECS UC Berkeley.
Fall EE 333 Lillevik 333f06-l5 University of Portland School of Engineering Computer Organization Lecture 5 MIPS Instructions Loops Machine Instructions.
Lecture 4: MIPS Instruction Set
Microprocessors The ia32 User Instruction Set Jan 31st, 2002.
Intro & ISA.1 1/14 Instruction Set Architecture (ISA) (Ch: , th ed) Instructions: Language of the Computer Dr. Khaled El-Ayat.
Csci 136 Computer Architecture II – Summary of MIPS ISA Xiuzhen Cheng
Computer Organization and Design Jair Gonzalez Enero 2004 MIPS ISA.
Csci 136 Computer Architecture II – More on MIPS ISA Xiuzhen Cheng
MIPS Instructions Instructions: Language of the Machine
Chapter 2 — Instructions: Language of the Computer — 1 Conditional Operations Branch to a labeled instruction if a condition is true – Otherwise, continue.
EEL5708/Bölöni Lec 3.1 Fall 2006 Sept 1, 2006 Lotzi Bölöni EEL 5708 High Performance Computer Architecture Lecture 3 Review: Instruction Sets.
DR. SIMING LIU SPRING 2016 COMPUTER SCIENCE AND ENGINEERING UNIVERSITY OF NEVADA, RENO Session 7, 8 Instruction Set Architecture.
Lecture 2: Instruction Set Architecture part 1 (Introduction) Mehran Rezaei.
EEL5708/Bölöni Lec 3.1 Fall 2004 Sept 1, 2004 Lotzi Bölöni Fall 2004 EEL 5708 High Performance Computer Architecture Lecture 3 Review: Instruction Sets.
Lecture 2 CS154B Review of MIPS ISA and Performance.
Instructor: Prof. Hany H Ammar, LCSEE, WVU
Prof. Hsien-Hsin Sean Lee
ELEN 468 Advanced Logic Design
RISC Concepts, MIPS ISA Logic Design Tutorial 8.
32-bit MIPS ISA.
ENGR 3410 – Computer Architecture Mark L. Chang Fall 2006
Instructions - Type and Format
Appendix A Classifying Instruction Set Architecture
MPIS Instructions Functionalities of instructions Instruction format
The University of Adelaide, School of Computer Science
ECE232: Hardware Organization and Design
Today’s Lecture Quick Review of Last Lecture
The University of Adelaide, School of Computer Science
Computer Instructions
CS352H Computer Systems Architecture
Reduced Instruction Set Computer (RISC)
Presentation transcript:

CPE 442 Lec4.1 Intro Computer Architectures CpE 442 Computer Architecture and Engineering MIPS Instruction Set Architecture

CPE 442 Lec4.2 Intro Computer Architectures Overview of Today’s Lecture: MIPS et al °Review from Last Lecture (3 minutes) °MIPS ISA (20 minutes) °More MIPS (25 minutes) °MIPS (VAX, 80x86?) (25 minutes)

CPE 442 Lec4.3 Intro Computer Architectures Review: Instruction Set Design instruction set software hardware

CPE 442 Lec4.4 Intro Computer Architectures Execution Cycle Instruction Fetch Instruction Decode Operand Fetch Execute Result Store Next Instruction Obtain instruction from program storage Determine required actions and instruction size Locate and obtain operand data Compute result value or status Deposit results in storage for later use Determine successor instruction

CPE 442 Lec4.5 Intro Computer Architectures Review: Summary °Use general purpose registers with a load-store architecture; °Provide at least 16 general purpose registers plus separate floating- point registers, °Support these addressing modes: displacement (with an address offset size of 12 to 16 bits), immediate (size 8 to 16 bits), and register deferred; ° Be sure all addressing modes apply to all data transfer instructions, °Use fixed instruction encoding if interested in performance and use variable instruction encoding if interested in code size; °Support these data sizes and types: 8-bit, 16-bit, 32-bit integers and 32- bit and 64-bit IEEE 754 floating point numbers; °Support these simple instructions, since they will dominate the number of instructions executed: load, store, add, subtract, move register- register, and, shift, compare equal, compare not equal, branch (with a PC-relative address at least 8-bits long), jump, call, and return; ° Aim for a minimalist instruction set.

CPE 442 Lec4.6 Intro Computer Architectures MIPS R2000 / R3000 Registers °Programmable storage2^32 x bytes31 x 32-bit GPRs (R0 = 0)32 x 32-bit FP regs (paired DP)HI, LO, PC

CPE 442 Lec4.7 Intro Computer Architectures MIPS Addressing Modes/Instruction Formats oprsrtrd Displ register Register (direct) oprsrt register Displacement + Memory immedoprsrt Immediate Disploprsrt PC PC-relative + Memory

CPE 442 Lec4.8 Intro Computer Architectures MIPS arithmetic instructions InstructionExampleMeaningComments add add $1,$2,$3$1 = $2 + $33 operands; exception possible subtractsub $1,$2,$3$1 = $2 – $33 operands; exception possible add immediateaddi $1,$2,100$1 = $ constant; exception possible add unsignedaddu $1,$2,$3$1 = $2 + $33 operands; no exceptions subtract unsignedsubu $1,$2,$3$1 = $2 – $33 operands; no exceptions add imm. unsign.addiu $1,$2,100$1 = $ constant; no exceptions multiply mult $2,$3Hi, Lo = $2 x $364-bit signed product multiply unsignedmultu$2,$3Hi, Lo = $2 x $364-bit unsigned product divide div $2,$3Lo = $2 ÷ $3,Lo = quotient, Hi = remainder Hi = $2 mod $3 divide unsigned divu $2,$3Lo = $2 ÷ $3,Unsigned quotient & remainder Hi = $2 mod $3 Move from Himfhi $1$1 = HiUsed to get copy of Hi Move from Lomflo $1$1 = LoUsed to get copy of Lo

CPE 442 Lec4.9 Intro Computer Architectures MIPS logical instructions InstructionExampleMeaningComment and and $1,$2,$3$1 = $2 & $33 reg. operands; Logical AND oror $1,$2,$3$1 = $2 | $33 reg. operands; Logical OR xorxor $1,$2,$3$1 = $2  $33 reg. operands; Logical XOR nornor $1,$2,$3$1 = ~($2 |$3)3 reg. operands; Logical NOR and immediateandi $1,$2,10$1 = $2 & 10Logical AND reg, constant or immediateori $1,$2,10$1 = $2 | 10Logical OR reg, constant xor immediate xori $1, $2,10 $1 = ~$2 &~10Logical XOR reg, constant shift left logicalsll $1,$2,10$1 = $2 << 10Shift left by constant shift right logicalsrl $1,$2,10$1 = $2 >> 10Shift right by constant shift right arithm.sra $1,$2,10$1 = $2 >> 10Shift right (sign extend) shift left logicalsllv $1,$2,$3$1 = $2 << $3 Shift left by variable shift right logicalsrlv $1,$2, $3 $1 = $2 >> $3 Shift right by variable shift right arithm.srav $1,$2, $3 $1 = $2 >> $3 Shift right arith. by variable

CPE 442 Lec4.10 Intro Computer Architectures MIPS data transfer instructions InstructionComment SW 500(R4), R3Store word SH 502(R2), R3Store half SB 41(R3), R2Store byte LW R1, 30(R2)Load word LH R1, 40(R3)Load halfword LHU R1, 40(R3)Load halfword unsigned LB R1, 40(R3)Load byte LBU R1, 40(R3)Load byte unsigned LUI R1, 40Load Upper Immediate (16 bits shifted left by 16)

CPE 442 Lec4.11 Intro Computer Architectures Compare and Branch °Compare and BranchBEQ rs, rt, offset if R[rs] == R[rt] then PC- relative branchBNE rs, rt, offset <> °BLEZ rs, offsetif R[rs] <= 0 then PC-relative branch °BGTZ rs, offset > °BLT < °BGEZ >=

CPE 442 Lec4.12 Intro Computer Architectures MIPS jump, branch, compare instructions InstructionExampleMeaning branch on equalbeq $1,$2,100if ($1 == $2) go to PC Equal test; PC relative branch branch on not eq.bne $1,$2,100if ($1!= $2) go to PC Not equal test; PC relative set on less thanslt $1,$2,$3if ($2 < $3) $1=1; else $1=0 Compare less than; 2’s comp. set less than imm.slti $1,$2,100if ($2 < 100) $1=1; else $1=0 Compare < constant; 2’s comp. set less than uns.sltu $1,$2,$3if ($2 < $3) $1=1; else $1=0 Compare less than; natural no. set l. t. imm. uns.sltiu $1,$2,100if ($2 < 100) $1=1; else $1=0 Compare < constant; natural jumpj 10000go to Jump to target address jump registerjr $31go to $31 For switch, procedure return jump and linkjal 10000$31 = PC + 4; go to For procedure call

CPE 442 Lec4.13 Intro Computer Architectures Assignment 2 Text, Chapter 2 Exercises section, work out and submit the solutions of the following problems 2.29, 2.34,, 2.49, 2.51 Due: Sept. 22, 2009

CPE 442 Lec4.14 Intro Computer Architectures Why Are Stacks So Great? Stacking of Subroutine Calls & Returns and Environments: A: CALL B CALL C C: RET B: A AB ABC AB A Some machines provide a memory stack as part of the architecture (e.g., the VAX) Sometimes stacks are implemented via software convention (e.g., MIPS)

CPE 442 Lec4.15 Intro Computer Architectures Call-Return Linkage: Stack Frames FP ARGS Callee Save Registers Local Variables SP Reference args and local variables at fixed (positive) offset from FP Grows and shrinks during expression evaluation (old FP, RA) °Many variations on stacks possible (up/down, last pushed / next ) °Block structured languages contain link to lexically enclosing frame. High Mem Low Mem

CPE 442 Lec4.16 Intro Computer Architectures MIPS: Software conventions 0zeroconstant 0 1atreserved for assembler 2v0expression evaluation and 3v1function results 4a0arguments 5a1 6a2 7a3 8t0temporary: caller saves... 15t7 16s0callee saves... 23s7 24t8 25t9 26k0reserved for OS kernel 27k1 28gpPointer to global area 29spStack pointer 30fpframe pointer 31raReturn Address (HW)

CPE 442 Lec4.17 Intro Computer Architectures MIPS / GCC Calling Conventions FP SP fact: addiu $sp, $sp, -32 sw$ra, 0($sp) sw$fp, 4($sp) addu$fp, $sp, 8... sw$a0, 0($fp)... lw$31, 0($sp) lw$fp, 4($sp) addiu$sp, $sp, 32 jr$31 ra oFP ra old FP ra FP SP ra FP SP low address First four args passed in registers. ; save ra ; save old fp ; Save arg0 ; restore ra ; restore old fp ; allocate a frame ; de-allocate ; return

CPE 442 Lec4.18 Intro Computer Architectures Example in C: swap swap(int v[], int k) { int temp; temp = v[k]; v[k] = v[k+1]; v[k+1] = temp; } °Assume swap is called as a procedure °Assume temp is register $15; arguments in $a1, $a2; $16 is scratch reg: °Write MIPS code

CPE 442 Lec4.19 Intro Computer Architectures swap: MIPS swap: addiu$sp,$sp, –4; create space on stack sw$16, 0($sp) ; callee saved register put onto stack sll$t2, $a2,2; mulitply k by 4 addu$t2, $a1,$t2; address of v[k] lw$15, 0($t2); load v[k[ lw$16, 4($t2); load v[k+1] sw$16, 0($t2); store v[k+1] into v[k] sw$15, 4($t2); store old value of v[k] into v[k+1] lw$16, 0($sp) ; callee saved register restored from stack addiu$sp,$sp, 4 ; restore top of stack jr$31 ; return to place that called swap

CPE 442 Lec4.20 Intro Computer Architectures Miscellaneous MIPS instructions °breakA breakpoint trap occurs, transfers control to exception handler °syscallA system trap occurs, transfers control to exception handler °coprocessor instrs.Support for floating point: discussed later °TLB instructionsSupport for virtual memory: discussed later °restore from exceptionRestores previous interrupt mask & kernel/user mode bits into status register °load word left/rightSupports misaligned word loads °store word left/rightSupports misaligned word stores

CPE 442 Lec4.21 Intro Computer Architectures Details of the MIPS instruction set °Register zero always has the value zero (even if you try to write it) ° jump and link instructions put the return address PC+4 into the link register($31) °All instructions change all 32 bits of the destination reigster (including lui, lb, lh) and all read all 32 bits of sources (add, sub, and, or, …) °Immediate arithmetic and logical instructions are extended as follows: logical immediates are zero extended to 32 bits arithmetic immediates are sign extended to 32 bits °The data loaded by the instructions lb and lh are extended as follows: lbu, lhu are zero extended lb, lh are sign extended °Overflow can occur in these arithmetic and logical instructions: add, sub, addi it cannot occur in addu, subu, addiu, and, or, xor, nor, shifts, mult, multu, div, divu

CPE 442 Lec4.22 Intro Computer Architectures Other ISAs °Intel 8086/88 => => => => Pentium => P few transistors to implement 16-bit microprocessor tried to be somewhat compatible with 8-bit microprocessor 8080 successors added features which where missing from 8086 over next 15 years product several different intel enigneers over 10 to 15 years Announced 1978 °VAX simple compilers & small code size => efficient instruction encoding powerful addressing modes powerful instructions few registers product of a single talented architect Announced 1977

CPE 442 Lec4.23 Intro Computer Architectures Machine Examples: Address & Registers Intel 8086 VAX 11 MC MIPS 2 x 8 bit bytes AX, BX, CX, DX SP, BP, SI, DI CS, SS, DS IP, Flags 2 x 8 bit bytes 16 x 32 bit GPRs 2 x 8 bit bytes 8 x 32 bit GPRs 7 x 32 bit addr reg 1 x 32 bit SP 1 x 32 bit PC 2 x 8 bit bytes 32 x 32 bit GPRs 32 x 32 bit FPRs HI, LO, PC acc, index, count, quot stack, string code,stack,data segment r15-- program counter r14-- stack pointer r13-- frame pointer r12-- argument ptr

CPE 442 Lec4.24 Intro Computer Architectures VAX Operations °General Format: (operation) (datatype) (2, 3) 2 or 3 explicit operands °For example add(b, w, l, f, d) (2, 3) Yields addb2addw2addl2addf2addd2 addb3addw3addl3addf3addd3

CPE 442 Lec4.25 Intro Computer Architectures VAX format, addressing modes General Instruction Format operand specifier 5rregister rautoinc8 rAdispbyte rChalf word rEword r4indexrmdisplacement

CPE 442 Lec4.26 Intro Computer Architectures swap: MIPS vs. VAX swap: addiu$sp,$sp, –4.word ^m ; saves r0 to r3 sw$16, 0($sp) sll$t2, $a2,2movlr2, 4(ap) ; move arg v[] to reg addu$t2, $a1,$t2movlr1, 8(ap) ; move arg k to reg lw$15, 0($t2)movlr3, (r2)[r1] ; get v[k] lw$16, 4($t2)addl3r0, #1,8(ap) ; reg gets k+1 sw$16, 0($t2)movl(r2)[r1],(r2)[r0] ; v[k] = v[k+1] sw$15, 4($t2)movl(r2)[r0],r3 ; v[k+1] gets old v[k] lw$16, 0($sp) addiu$sp,$sp, 4 jr$31ret; return to caller, restore r0 - r3

CPE 442 Lec4.27 Intro Computer Architectures Summary °Use general purpose registers with a load-store architecture: YES °Provide at least 16 general purpose registers plus separate floating- point registers: 31 GPR & 32 FPR °Support these addressing modes: displacement (with an address offset size of 12 to 16 bits), immediate (size 8 to 16 bits), and register deferred; : YES: 16 bits for immediate, displacement (disp=0 => register deferred) ° All addressing modes apply to all data transfer instructions : YES °Use fixed instruction encoding if interested in performance and use variable instruction encoding if interested in code size : Fixed °Support these data sizes and types: 8-bit, 16-bit, 32-bit integers and 32- bit and 64-bit IEEE 754 floating point numbers: YES °Support these simple instructions, since they will dominate the number of instructions executed: load, store, add, subtract, move register- register, and, shift, compare equal, compare not equal, branch (with a PC-relative address at least 8-bits long), jump, call, and return: YES, 16b ° Aim for a minimalist instruction set: YES

CPE 442 Lec4.28 Intro Computer Architectures Summary: Salient features of MIPS R bit fixed format inst (3 formats) bit GPR (R0 contains zero) and 32 FP registers (and HI LO) partitioned by software convention 3-address, reg-reg arithmetic instr. Single address mode for load/store: base+displacement –no indirection –16-bit immediate plus LUI Simple branch conditions compare against zero or two registers for = no condition codes Delayed branch execute instruction after the branch (or jump) even if the banch is taken (Compiler can fill a delayed branch with useful work about 50% of the time)