Course Administration

Similar documents
MIPS Memory Access Instructions

Instructions: Language of the Computer

Computer Organization MIPS ISA

Computer Architecture

CS3350B Computer Architecture MIPS Instruction Representation

CENG3420 Lecture 03 Review

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

CISC 662 Graduate Computer Architecture. Lecture 4 - ISA

CS3350B Computer Architecture

CS3350B Computer Architecture MIPS Introduction

CENG3420 L03: Instruction Set Architecture

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

Chapter 2A Instructions: Language of the Computer

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

Announcements HW1 is due on this Friday (Sept 12th) Appendix A is very helpful to HW1. Check out system calls

Computer Architecture. MIPS Instruction Set Architecture

Reduced Instruction Set Computer (RISC)

Math 230 Assembly Programming (AKA Computer Organization) Spring 2008

Chapter 2: Instructions:

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

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

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

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

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

Reduced Instruction Set Computer (RISC)

CS222: MIPS Instruction Set

Chapter 2. Instruction Set Architecture (ISA)

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

MIPS (SPIM) Assembler Syntax

CS/COE1541: Introduction to Computer Architecture

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

Course Administration

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

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

1 5. Addressing Modes COMP2611 Fall 2015 Instruction: Language of the Computer

MIPS%Assembly% E155%

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

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

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

COMPSCI 313 S Computer Organization. 7 MIPS Instruction Set

Lecture 4: MIPS Instruction Set

Computer Architecture. The Language of the Machine

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

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

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

Instructions: Language of the Computer

3. Instruction Set Architecture The MIPS architecture

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

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

Rechnerstrukturen. Chapter 2. Instructions: Language of the Computer

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

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

Control Instructions

Thomas Polzer Institut für Technische Informatik

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

ECE 154A Introduction to. Fall 2012

Computer Architecture

Instruction Set Architecture part 1 (Introduction) Mehran Rezaei

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

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

COMPUTER ORGANIZATION AND DESIGN

Lecture 5: Procedure Calls

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

Topic Notes: MIPS Instruction Set Architecture

EEC 581 Computer Architecture Lecture 1 Review MIPS

Chapter 3. Instructions:

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

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

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

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

Chapter 2. Instructions: Language of the Computer

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

ECE468 Computer Organization & Architecture. MIPS Instruction Set Architecture

CS 4200/5200 Computer Architecture I

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

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

Course Administration

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

Lectures 3-4: MIPS instructions

Levels of Programming. Registers

CSSE 232 Computer Architecture I. I/O and Addressing

Chapter 2. lw $s1,100($s2) $s1 = Memory[$s2+100] sw $s1,100($s2) Memory[$s2+100] = $s1

Computer Architecture Instruction Set Architecture part 2. Mehran Rezaei

The MIPS Instruction Set Architecture

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

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

M2 Instruction Set Architecture

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

EE 361 University of Hawaii Fall

Chapter 1. Computer Abstractions and Technology. Lesson 3: Understanding Performance

Chapter 2. Instructions:

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

MIPS Instruction Set Architecture (2)

ECE331: Hardware Organization and Design

MIPS ISA and MIPS Assembly. CS301 Prof. Szajda

Review of instruction set architectures

Instruction Set Architecture. "Speaking with the computer"

ECE 30 Introduction to Computer Engineering

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

Lecture 3: The Instruction Set Architecture (cont.)

Transcription:

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 Website: http://oucsace.cs.ohiou.edu/~avinashk/classes/ee461a/ee461a.htm Course Administration Lecture Notes 1 (Introduction) and 2 (Performance) posted 1

MIPS Memory Instructions Supports Base + Displacement mode only Format: 2 registers (dest, base) and 16-bit immediate (offset) Example: lw $s3, 1000($s4) Retrieves a word ( bits) from address ($s4 + 1000) Example: lh $s3, 1000($s4) Retrieves a halfword (16 bits) from address ($s4+1000) Example: lb $s3, 1000($s4) Retrieves a byte (8 bits) from address ($s4+1000) Sign/Zero Extension Registers in MIPS are all -bits! So what happens when you load 8 or 16 bits? Sign extend if the load is signed 0x1F 0x0000001F 0xFFFFFFFE Zero extend if the load is unsigned 0x1F 0x0000001F 0x000000FE 2

MIPS Memory Instruction - Recap Load Instruction lb lbu lh lhu lw \\ load byte signed \\ load byte unsigned (zero extend) \\ load halfword \\ load halfword unsigned (zero extend) \\ load word Store Instruction sb $s3, 1000($s4) sh $s3, 1000($s4) sw $s3, 1000($s4) \\ store 8 LSBs of $s3 to M[$s4 + 1000] \\ store 16 LSBs of $s3 to M[$s4 + 1000] \\ store all bits of $s3 to M[$s4+1000] Byte Addresses Since 8-bit addresses are so useful, most architectures address individual bytes in memory The memory address of a word must be multiple of 4 (alignment restriction) Big Endian : leftmost byte is word address IBM 360/370, Motorola 68K, MIPS, Sparc, HP PA Little Endian: rightmost byte is word address Intel 80x86, DEC Vax, DEC Alpha little endian byte 0 3 2 1 0 msb lsb 0 1 2 3 big endian byte 0 3

Example Code Sequence What is the final state of memory once you execute the following instruction sequence ($s0 = 0)? lw $s4, 100($s0) lb $s3, 102($s0) sw $s3, 100($s0) sb $s4, 102($s0) $s3 Register File Memory (Each location is 1 Byte) $s4 0x02 0x03 0x05 100 101 102 103 Example Code Sequence - 1 What is the final state of memory once you execute the following instruction sequence? lw $s4, 100($s0) lb $s3, 102($s0) sw $s3, 100($s0) sb $s4, 102($s0) $s3 Register File Memory (Each location is 1 Byte) $s4 0x0203 FE05 0x02 100 0x03 101 102 0x05 103 4

Example Code Sequence - 2 What is the final state of memory once you execute the following instruction sequence? lw $s4, 100($s0) lb $s3, 102($s0) sw $s3, 100($s0) sb $s4, 102($s0) $s3 Register File 0xFFFF FFFE Memory (Each location is 1 Byte) $s4 0x0203 FF05 0x02 100 0x03 101 102 0x05 103 Example Code Sequence - 3 What is the final state of memory once you execute the following instruction sequence? lw $s4, 100($s0) lb $s3, 102($s0) sw $s3, 100($s0) sb $s4, 102($s0) $s3 Register File 0xFFFF FFFE Memory (Each location is 1 Byte)` $s4 0x0203 FF05 0xFF 100 0xFF 101 0xFF 102 103 5

Example Code Sequence - 4 What is the final state of memory once you execute the following instruction sequence? lw $s4, 100($s0) lb $s3, 102($s0) sw $s3, 100($s0) sb $s4, 102($s0) $s3 Register File 0xFFFF FFFE Memory $s4 0x0203 FF05 0xFF 100 0xFF 101 0x05 102 103 Convert C to Assembly Example 1 a = b + names[i] Assume that a is in $s1, b is in $s2, i is in $s3 and the array names starts at address 1000 and holds -bit integers lw $t0, 1000($s3) add $s1, $s2, $t0 # load word # addition Example 2 A[12] = b + A[8] Assume that b is in $s2, base address of A in $s3 lw $t0, ($s3) add $t0, $s2, $t0 sw $t0, 48($s3) # load word # store word 6

What about Immediate Operands? Small constants often used, keep the constant inside the instruction itself addi $sp, $sp, 4 #$sp = $sp + 4 Machine I-Format op rs rt 16-bit Offset What about large operands? Aside: How About Larger Constants? We'd also like to be able to load a bit constant into a register, for this we must use two instructions a new "load upper immediate" instruction lui $t0, 255 16 0 8 0000 0000 1111 1111 Then must get the lower order bits right, use ori $t0, $t0, 43690 0000 0000 1111 1111 0000000000000000 0000 0000 1111 1111 1010101010101010 0000 0000 1111 1111 1010101010101010 7

MIPS Control Flow Instructions MIPS conditional branch instructions: bne $s0, $s1, Lbl beq $s0, $s1, Lbl Ex: if (i==j) h = i + j; bne $s0, $s1, Lbl1 add $s3, $s0, $s1 Lbl1:... #go to Lbl if $s0 $s1 #go to Lbl if $s0=$s1 Instruction Format (I format): op rs rt 16-bit Offset How is the branch destination address specified? Specifying Branch Destinations Use a register (like in lw and sw) added to the 16-bit offset which register? Instruction Address Register (the Program Counter) its use is automatically implied by instruction PC gets updated (PC+4) during the fetch cycle so that it holds the address of the next instruction limits the branch distance to -2 15 to +2 15-1 instructions from the (instruction after the) branch instruction, but most branches are local anyway from the low order 16 bits of the branch instruction sign-extend PC 16 offset 00 4 Add Add? branch dst address 8

More Branch Instructions We have beq, bne, but what about other kinds of branches (e.g., branch-if-less-than)? For this, we need yet another instruction, slt Set on less than instruction: slt $t0, $s0, $s1 # if $s0 < $s1 then # $t0 = 1 else # $t0 = 0 Instruction format (R format): op rs rt rd shamt funct More Branch Instructions Can use slt, beq, bne, and the fixed value of 0 in register $zero to create other conditions less than blt $s1, $s2, Label slt $at, $s1, $s2 #$at set to 1 if bne $at, $zero, Label # $s1 < $s2 less than or equal to greater than great than or equal to ble $s1, $s2, Label bgt $s1, $s2, Label bge $s1, $s2, Label Such branches are included in the instruction set as pseudo instructions - recognized (and expanded) by the assembler Its why the assembler needs a reserved register ($at) 9

Other Control Flow Instructions MIPS also has an unconditional branch instruction or jump instruction: j label #go to label Instruction Format (J Format): op 26-bit address from the low order 26 bits of the jump instruction 26 00 4 PC Aside: Branching Far Away What if the branch destination is further away than can be captured in 16 bits?, The assembler comes to the rescue it inserts an unconditional jump to the branch target and inverts the condition beq $s0, $s1, L1 becomes L2: bne j $s0, $s1, L2 L1 10

MIPS ISA So Far Category Instr Op Code Example Meaning Arithmetic (R & I format) Data Transfer (I format) Cond. Branch (I & R format) Uncond. Jump (J & R format) add 0 and add $s1, $s2, $s3 $s1 = $s2 + $s3 subtract 0 and 34 sub $s1, $s2, $s3 $s1 = $s2 - $s3 add immediate 8 addi $s1, $s2, 6 $s1 = $s2 + 6 or immediate 13 ori $s1, $s2, 6 $s1 = $s2 v 6 load word 35 lw $s1, 24($s2) $s1 = Memory($s2+24) store word 43 sw $s1, 24($s2) Memory($s2+24) = $s1 load byte lb $s1, 25($s2) $s1 = Memory($s2+25) store byte 40 sb $s1, 25($s2) Memory($s2+25) = $s1 load upper imm 15 lui $s1, 6 $s1 = 6 * 2 16 br on equal 4 beq $s1, $s2, L if ($s1==$s2) go to L br on not equal 5 bne $s1, $s2, L if ($s1!=$s2) go to L set on less than 0 and 42 slt $s1, $s2, $s3 if ($s2<$s3) $s1=1 else $s1=0 set on less than immediate 10 slti $s1, $s2, 6 if ($s2<6) $s1=1 else $s1=0 jump 2 j 2500 go to 10000 jump register 0 and 8 jr $t1 go to $t1 jump and link 3 jal 2500 go to 10000; $ra=pc+4 Register Organization Name Register Number Usage Preserved on Call $zero 0 Constant Value of 0 n.a. $v0-$v1 2-3 Values for results and expressions $a0-$a3 4-7 Arguments No $t0-$t7 8-15 Temporaries No $s0-$s7 16-23 Saved Yes $t8-$t9 24-25 More Temporaries No $gp 28 Global Pointer Yes $sp 29 Stack Pointer Yes $fp 30 Frame Pointer Yes $ra 31 Return Address Yes No What about Register 1? 11