# Computer Architecture. Lecture 2 : Instructions

Save this PDF as:

Size: px
Start display at page:

## Transcription

1 Computer Architecture Lecture 2 : Instructions 1

2 Components of a Computer

3 Hierarchical Layers of Program Code 3

4 Instruction Set The repertoire of instructions of a computer 2.1 Intr roduction Different computers have different instruction sets But with many aspects in common 4

5 The MIPS Instruction Set Used as the example throughout the book Stanford MIPS commercialized by MIPS Technologies ( Founded in 1984 by? Large share of embedded core market Applications in consumer electronics, network/storage equipment, cameras, printers, Typical of many modern ISAs 5

6 Instruction Set Stored-program concept The idea that instructions and data of many types can be stored in memory as numbers, leading to stored-program computer Let us look into MIPS instruction ti set one by one to understand this 6

7 Arithmetic Operations Add and subtract, three operands Two sources and one destination add a, b, c 2.2 Ope erations of the Com mputer Ha ardware # a gets b + c 7

8 Arithmetic Operations Operand is a quantity on which an operation is performed add a, b, c How many operands in this instruction? 2.2 Ope erations of the Com mputer Ha ardware All arithmetic operations have this form 8

9 Arithmetic Operations All arithmetic operations have same form What if we want to add b,c,d,,,, and e and put the result into a? 2.2 Ope erations of the Com mputer Hardware 9

10 Design Principle 1 All arithmetic operations have same form Design Principle 1: Simplicity favors regularity Regularity makes hardware implementation simpler 2.2 Ope erations of the Com mputer Ha ardware 10

11 Arithmetic Example C code: f = (g + h) - (i + j); Compiled MIPS code:? Hints: Use sub instruction,e.g., a=b-c, is sub a,b,c Use two temporary variables t0 and t1 11

12 Arithmetic Example C code: f = (g + h) - (i + j); Compiled MIPS code: add t0, g, h # temp t0 = g + h add t1, i, j # temp t1 = i + j sub f, t0, t1 # f = t0 - t1 12

13 Register Operands The operands of arithmetic instructions must be from special location in hardware called registers Registers are primitives of hardware design and are visible to programmers 2.3 Ope erands of the Computer Har dware 13

14 Assembler names Register Operands \$t0, \$t1,, \$t9 for temporary values \$s0, \$s1,, \$s7 for saved variables 2.3 Ope erands of the Comp puter Hardware 14

15 Register Operand Example Compiler s job to associate variables of a highlevel program with registers C code: f = (g + h) - (i + j); f,, j in \$s0,, \$s4 Compiled MIPS code? 15

16 Register Operand Example Compiled MIPS code: add \$t0, \$s1, \$s2 add \$t1, \$s3, \$s4 sub \$s0, \$t0, \$t1 16

17 Register Operands MIPS has a bit register file Numbered 0 to bit data called a word Word is the natural unit of access, typically 32 bits, corresponds to the size of a register in MIPS 2.3 Ope erands of the Comp puter Har dware There may be only 3 operands and they must be chosen from one of the 32 registers. Why only 32? 17

18 Smaller is faster Design Principle 2 Larger registers will increase clock cycle time --- electronic signals takes longer when they travel farther Design principles are not hard truths but general guidelines 31 registers instead of 32 need not make MIPS faster 2.3 Ope erands of the Comp puter Har dware 18

19 Memory Operands Programming languages, C, Java, Allow complex data structures like arrays and structures They often contain many more data elements than the number of registers in a computer Where are they stored? Memory But, arithmetic operations are applied on register operands Hence, data transfer instructions are required to transfer data from memory to registers Load values from memory into registers Store result from register to memory 19

20 Memory is like an array Data transfer instructions must supply the address (index/offset) of the memory (array) 20

21 Memory Operands Memory is bt byte addressed d Each address identifies an 8-bit byte Words are aligned in memory Each word is 32 bits or 4 bytes To locate words, addresses are in multiples of 4 21

22 A is an array of words What is the offset to locate A[8]? A[0] 0 A[1] 4 A[2] 8 A[8] 32 22

23 Memory Operands Why is memory not word-addressable? dd 23

24 Memory Operands Why is memory not word-addressable? dd Bytes are useful in many programs. In a word addressable system, it is necessary first to compute the address of the word containing the byte, fetch that word, and then extract the byte from the two-byte word. Although the processes for byte extraction are well understood, they are less efficient than directly accessing the byte. For this reason, many modern machines are byte addressable. 24

25 Memory Operands Load instruction lw refers to load word lw registername, offset (registerwithbaseaddress) lw \$t0, 8 (\$s3) offset base register 25

26 Memory Operand Example 1 C code: g = h + A[8]; g in \$s1 h in \$s2 base address of A in \$s3 A is an array of 100 words Compiled MIPS code? 26

27 Memory Operand Example 1 C code: g = h + A[8]; g in \$s1, h in \$s2, base address of A in \$s3 Compiled MIPS code: lw \$t0, 32(\$s3) # load word add \$s1, \$s2, \$t0 offset base register 27

28 Memory Operand Example 2 C code: A[12] = h + A[8]; h in \$s2, base address of A in \$s3 Compiled MIPS code: 28

29 Memory Operand Example 2 C code: A[12] = h + A[8]; h in \$s2, base address of A in \$s3 Compiled MIPS code: Index 8 requires offset of 32 lw \$t0, 32(\$s3) # load word add \$t0, \$s2, \$t0 sw \$t0, 48(\$s3) # store word 29

30 Registers vs. Memory Registers are faster to access than memory Operating on memory data requires loads and stores More instructions to be executed Compiler must use registers for variables as much as possible Only spill to memory for less frequently used variables Register optimization is important! 30

31 Immediate Operands Constant data specified in an instruction addi \$s3, \$s3, 4 No subtract immediate instruction Just use a negative constant addi \$s2, \$s1, -1 31

32 Design Principle3 Make the common case fast Small constants are common : immediate operand avoids a load instruction Allows us to avoid using memory meaning faster operations and lesser energy 32

33 The Constant Zero MIPS register 0 (\$zero) is the constant 0 Cannot be overwritten Useful for common operations E.g., move between registers add \$t2, \$s1, \$zero 33

34 Problems In the snippet of MIPS assembler code below, how many times is the memory accessed? How many times data is fetched from memory? lw \$v1, 0(\$a0) addi \$v0, \$v0, 1 sw \$v1, 0(\$a1) addi \$a0, \$a0, 1 Write the MIPS assembly language instructions for the following C statement. tt t Assume f is stored in \$s0, g in \$s1 and h in \$s2. Use a minimal i number of MIPS statements and a minimal number of registers. f = g + (h 5) 34

35 Stored-program concept The idea that instructions and data of many types can be stored in memory as numbers, leading to stored-program computer 35

36 Representing Instructions Instructions are encoded in binary Called machine code MIPS instructions Encoded as 32-bit instruction words Small number of formats encoding operation code (opcode), register numbers, Regularity! Register numbers \$t0 \$t7 are reg s 8 15 \$s0 \$s7 are reg s Rep presenting Instructi ions in the Comput ter 36

37 Example add \$t0, \$s1, \$s2 special \$s1 \$s2 \$t0 0 add op rs rt rd shamt funct 6 bits 5 bits 5 bits 5 bits 5 bits 6 bits 37

38 Representing Instructions The layout or the form of representation of instruction is composed of fields of binary numbers The numeric version of instructions is called machine language and a sequence of such instructions is called machine code 38

39 Instruction types R format (for register) Add, sub I-format (for immediate) Immediate Data transfer 39

40 MIPS R-format Instructions op rs rt rd shamt funct 6 bits 5 bits 5 bits 5 bits 5 bits 6 bits Instruction fields op: operation code (opcode) rs: first source register number rt: second source register number rd: destination register number shamt: shift amount (00000 for now) funct: function code (extends opcode) 40

41 MIPS I-format Instructions op rs rt constant or address 6 bits 5 bits 5 bits 16 bits Immediate arithmetic and load/store instructions rt: destination register number rs: register number with address Constant/ Address: offset added to base address in rs 41

42 Design Principle 4 Ideally, Keep all instructions of the same format and length But this makes it difficult to address large memories Compromise and allow different formats Principle 4: Good design demands good compromises Different formats complicate decoding, but allow 32-bit instructions uniformly Keep formats as similar as possible See example in page 98 42

43 Stored Program Computers Instructions represented in binary, just like data Instructions and data stored in memory Programs can operate on programs e.g., compilers, linkers, Binary compatibility allows compiled programs to work on different computers Standardized ISAs 43

44 Logical Operations Instructions for bitwise manipulation Operation C Java MIPS Shift left << << sll Shift right >> >>> srl Bitwise AND & & and, andi Bitwise OR or, ori Bitwise NOT ~ ~ nor 2.6 Log gical Opera ations Useful for extracting and inserting groups of bits in a word 44

45 Shift Operations Shift left logical Shift bits to the left and fill the empty bits with zeros sll \$t2,\$s0,3\$s

46 Shift Operations Shift left logical Shift bits to the left and fill the empty bits with zeros sll \$t2,\$s0,3\$s

47 Shift Operations Shift left logical Shift bits to the left and fill the empty bits with zeros sll \$t2,\$s0,3\$s sll by i bits multiplies by 2 i 47

48 Shift Operations op rs rt rd shamt funct 6 bits 5 bits 5 bits 5 bits 5 bits 6 bits 48

49 Shift Operations op rs rt rd shamt funct 6 bits 5 bits 5 bits 5 bits 5 bits 6 bits sll \$t2,\$s0, \$s0 \$t2 shamt: how many positions to shift Similarly, Shift right logical 49

50 AND Operations Mask bits in a word Select some bits, clear others to 0 and \$t0, \$t1, \$t2 \$t2 \$t1 \$t

51 OR Operations Include bits in a word Set some bits to 1, leave others unchanged or \$t0, \$t1, \$t2 \$t2 \$t1 \$t

52 NOT Operations Useful to invert bits in a word Change 0 to 1, and 1 to 0 MIPS has NOR 3-operand instruction a NOR b == NOT ( a OR b ) nor \$t0, \$t1, \$zero Register 0: always read as zero \$t1 \$t

53 Hexadecimal Numbers Reading binary numbers are tedious So, hexadecimal representation is popular Base 16 is power of two and hence it is easy to replace each group of 4 binary digits 53

54 Base 16 Hexadecimal Compact representation of bit strings 4 bits per hex digit c d a 1010 e b 1011 f 1111 Example: eca8 6420? Example: eca8 6420? Example:

55 Conditional Operations Branch to a labeled instruction if a condition is true Otherwise, continue sequentially beq rs, rt, L1 if (rs == rt) branch to instruction labeled L1; bne rs, rt, L1 if (rs!= rt) branch to instruction labeled L1; j L1 unconditional jump to instruction labeled L1 2.7 Inst tructions for Makin ng Decisio ns 55

56 Compiling If Statements C code: if (i==j) f = g+h; else f = g-h; f, g, in \$s0, \$s1, 56

57 C code: Compiling If Statements if (i==j) f = g+h; else f = g-h; f,,g, in \$s0,,\$ \$s1, Compiled MIPS code: bne \$s3, \$s4, Else add \$s0, \$s1, \$s2 j Exit Else: sub \$s0, \$s1, \$s2 Exit: 57 Assembler calculates addresses

58 RISC vs CISC 58

59 CISC Approach Complex Instruction Set Computer C code: g = h + A[8]; CISC add a,32<b> Achieved by building complex hardware that loads value from memory into a register and then adds it to register a and stores the results in register a 59

60 CISC vs RISC C code: g = h + A[8]; CISC add a,32<b> Compiled MIPS code: lw \$t0, 32(\$s3) # load word add \$s1, \$s2, \$t0 60

61 CISC Advantages Compiler has to do little Programming was done in assembly language To make it easy, more and more complex instructions were added Length of the code is short and hence, little memory is required e to store the code Memory was a very costly real-estate E.g., Intel x86 machines powering several million desktops 61

62 RISC Advantages Each instruction needs only one clock cycle Hardware is less complex 62

63 RISC Roadblocks RISC processors, despite their advantages, took several years to gain market Intel had a head start of 2 years before its RISC competitors Customers were unwilling to take risk with new technology and change software products They have a large market and hence, they can afford resources to overcome complexity 63

64 Fallacies Powerful instruction higher performance Fewer instructions required But complex instructions are hard to implement May slow down all instructions, including simple ones Compilers are good at making fast code from simple instructions Use assembly code for high performance But modern compilers are better at dealing with modern processors More lines of code more errors and less productivity 2.18 Fa llacies an d Pitfalls 64

65 Fallacies Backward compatibility instruction set doesn t change But they do accrete more instructions x86 instruction ti set 65

66 Pitfalls Sequential words are not at sequential addresses Increment by 4, not by 1! 66

67 CISC vs RISC Very good slides on the topic s/pdf/riscvscisc.pdf 67

68 Patterson s blog: risc-versus-cisc-wars-in-the-prepc-and-pc-eraspart-1/ Interview with Hennessy ts/risc/about/interview.html /i /b /i i 68

69 Concluding Remarks Design principles 1.Simplicity favors regularity 2.Smaller is faster 3.Make the common case fast 4.Good design demands good compromises Layers of software/hardware Compiler, assembler, hardware MIPS: typical of RISC ISAs c.f. x Co oncluding Remarks 69

### Chapter 2. Instruction Set. RISC vs. CISC Instruction set. The University of Adelaide, School of Computer Science 18 September 2017

COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface RISC-V Edition Chapter 2 Instructions: Language of the Computer These slides are based on the slides by the authors. The slides doesn t

### Architecture I. Computer Systems Laboratory Sungkyunkwan University

MIPS Instruction ti Set Architecture I Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Architecture (1) the attributes of a system as seen by the

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

ENGN1640: Design of Computing Systems Topic 03: Instruction Set Architecture Design Professor Sherief Reda http://scale.engin.brown.edu School of Engineering Brown University Spring 2014 Sources: Computer

### CS3350B Computer Architecture

CS3350B Computer Architecture Winter 2015 Lecture 4.1: MIPS ISA: Introduction Marc Moreno Maza www.csd.uwo.ca/courses/cs3350b [Adapted d from lectures on Computer Organization and Design, Patterson & Hennessy,

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

Computer Science 324 Computer Architecture Mount Holyoke College Fall 2009 Topic Notes: MIPS Instruction Set Architecture vonneumann Architecture Modern computers use the vonneumann architecture. Idea:

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

Today s topics CS/COE1541: Introduction to Computer Architecture MIPS operations and operands MIPS registers Memory view Instruction encoding A Review of MIPS ISA Sangyeun Cho Arithmetic operations Logic

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

ECE232: Hardware Organization and Design Part 6: MIPS Instructions II http://www.ecs.umass.edu/ece/ece232/ Adapted from Computer Organization and Design, Patterson & Hennessy, UCB Computer Organization

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

Computer Science 324 Computer Architecture Mount Holyoke College Fall 2007 Topic Notes: MIPS Instruction Set Architecture vonneumann Architecture Modern computers use the vonneumann architecture. Idea:

### Chapter 2. Instruction Set Architecture (ISA)

Chapter 2 Instruction Set Architecture (ISA) MIPS arithmetic Design Principle: simplicity favors regularity. Why? Of course this complicates some things... C code: A = B + C + D; E = F - A; MIPS code:

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

Instructions: ti Language of the Computer Rui Wang, Assistant professor Dept. of Information and Communication Tongji University it Email: ruiwang@tongji.edu.cn Computer Hierarchy Levels Language understood

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

Machine Language Instructions Introduction Instructions Words of a language understood by machine Instruction set Vocabulary of the machine Current goal: to relate a high level language to instruction

### MIPS%Assembly% E155%

MIPS%Assembly% E155% Outline MIPS Architecture ISA Instruction types Machine codes Procedure call Stack 2 The MIPS Register Set Name Register Number Usage \$0 0 the constant value 0 \$at 1 assembler temporary

### Chapter 2. Instructions: Language of the Computer

Chapter 2 Instructions: Language g of the Computer Outlines Introduction to MIPS machine Operations of the Computer HW Operands of the Computer HW Representing instructions in the Computer Logical Operations

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

Assembly Language Programming CPSC 252 Computer Organization Ellen Walker, Hiram College Instruction Set Design Complex and powerful enough to enable any computation Simplicity of equipment MIPS Microprocessor

### Processor (I) - datapath & control. Hwansoo Han

Processor (I) - datapath & control Hwansoo Han Introduction CPU performance factors Instruction count - Determined by ISA and compiler CPI and Cycle time - Determined by CPU hardware We will examine two

### Lecture 6 Decision + Shift + I/O

Lecture 6 Decision + Shift + I/O Instructions so far MIPS C Program add, sub, addi, multi, div lw \$t0,12(\$s0) sw \$t0, 12(\$s0) beq \$s0, \$s1, L1 bne \$s0, \$s1, L1 j L1 (unconditional branch) slt reg1,reg2,reg3

### Concocting an Instruction Set

Concocting an Instruction Set Nerd Chef at work. move flour,bowl add milk,bowl add egg,bowl move bowl,mixer rotate mixer... Read: Chapter 2.1-2.7 L03 Instruction Set 1 A General-Purpose Computer The von

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

Instruction Set Architecture for MIPS Processors Overview Dr. Arjan Durresi Louisiana State University Baton Rouge, LA 70803 durresi@csc.lsu.edu These slides are available at: http://www.csc.lsu.edu/~durresi/_07/

### Chapter 4. The Processor. Instruction count Determined by ISA and compiler. We will examine two MIPS implementations

Chapter 4 The Processor Part I Introduction CPU performance factors Instruction count Determined by ISA and compiler CPI and Cycle time Determined by CPU hardware We will examine two MIPS implementations

### CS61C : Machine Structures

inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures \$2M 3D camera Lecture 8 MIPS Instruction Representation I Instructor: Miki Lustig 2014-09-17 August 25: The final ISA showdown: Is ARM, x86, or

### Math 230 Assembly Programming (AKA Computer Organization) Spring 2008

Math 230 Assembly Programming (AKA Computer Organization) Spring 2008 MIPS Intro II Lect 10 Feb 15, 2008 Adapted from slides developed for: Mary J. Irwin PSU CSE331 Dave Patterson s UCB CS152 M230 L10.1

### EE108B Lecture 3. MIPS Assembly Language II

EE108B Lecture 3 MIPS Assembly Language II Christos Kozyrakis Stanford University http://eeclass.stanford.edu/ee108b 1 Announcements Urgent: sign up at EEclass and say if you are taking 3 or 4 units Homework

### COMPUTER ORGANIZATION AND DESIGN. The Hardware/Software Interface. Chapter 4. The Processor: A Based on P&H

COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface Chapter 4 The Processor: A Based on P&H Introduction We will examine two MIPS implementations A simplified version A more realistic pipelined

### IC220 SlideSet #2: Instructions (Chapter 2)

Chapter Goals IC220 SlideSet #2: Instructions (Chapter 2) Teach a subset of MIPS assembly language Introduce the stored program concept Explain how MIPS instructions are represented in machine language

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

page 1 Concocting an Instruction Set Nerd Chef at work. move flour,bowl add milk,bowl add egg,bowl move bowl,mixer rotate mixer... A General-Purpose Computer The von Neumann Model Many architectural approaches

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

Instructions (354 Review) Forecast Instructions are the words of a computer Instruction set architecture (ISA) is its vocabulary With a few other things, this defines the interface of computers But implementations

### Of course, the hardware doesn t really execute MIPS assembly language code.

Machine Language MIPS ML 1 Of coue, the hardware doesn t really execute MIPS assembly language code. The hardware can only store bits, and so the instructions it executes must be expressed in a suitable

### Lecture Topics. Branch Condition Options. Branch Conditions ECE 486/586. Computer Architecture. Lecture # 8. Instruction Set Principles.

ECE 486/586 Computer Architecture Lecture # 8 Spring 2015 Portland State University Instruction Set Principles MIPS Control flow instructions Dealing with constants IA-32 Fallacies and Pitfalls Reference:

### Lecture 3: The Processor (Chapter 4 of textbook) Chapter 4.1

Lecture 3: The Processor (Chapter 4 of textbook) Chapter 4.1 Introduction Chapter 4.1 Chapter 4.2 Review: MIPS (RISC) Design Principles Simplicity favors regularity fixed size instructions small number

### ISA: The Hardware Software Interface

ISA: The Hardware Software Interface Instruction Set Architecture (ISA) is where software meets hardware In embedded systems, this boundary is often flexible Understanding of ISA design is therefore important

### ECE260: Fundamentals of Computer Engineering

Datapath for a Simplified Processor James Moscola Dept. of Engineering & Computer Science York College of Pennsylvania Based on Computer Organization and Design, 5th Edition by Patterson & Hennessy Introduction

### Grading: 3 pts each part. If answer is correct but uses more instructions, 1 pt off. Wrong answer 3pts off.

Department of Electrical and Computer Engineering University of Wisconsin Madison ECE 552 Introductions to Computer Architecture Homework #2 (Suggested Solution) 1. (10 points) MIPS and C program translations

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

A Processor Kevin Walsh CS 3410, Spring 2010 Computer Science Cornell University See: P&H Chapter 2.16-20, 4.1-3 Let s build a MIPS CPU but using Harvard architecture Basic Computer System Registers ALU

### CS 4200/5200 Computer Architecture I

CS 4200/5200 Computer Architecture I MIPS Instruction Set Architecture Dr. Xiaobo Zhou Department of Computer Science CS420/520 Lec3.1 UC. Colorado Springs Adapted from UCB97 & UCB03 Review: Organizational

### COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface. 5 th. Edition. Chapter 4. The Processor

COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface 5 th Edition Chapter 4 The Processor Introduction CPU performance factors Instruction count Determined by ISA and compiler CPI and Cycle

### Concocting an Instruction Set

Concocting an Instruction Set Nerd Chef at work. move flour,bowl add milk,bowl add egg,bowl move bowl,mixer rotate mixer... Lab is posted. Do your prelab! Stay tuned for the first problem set. L04 Instruction

### Architecture II. Computer Systems Laboratory Sungkyunkwan University

MIPS Instruction ti Set Architecture II Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Making Decisions (1) Conditional operations Branch to a

### CS 61C: Great Ideas in Computer Architecture MIPS Instruction Formats

CS 61C: Great Ideas in Computer Architecture MIPS Instruction Formats Instructors: Vladimir Stojanovic and Nicholas Weaver http://inst.eecs.berkeley.edu/~cs61c/sp16 1 Machine Interpretation Levels of Representation/Interpretation

### CS61C : Machine Structures

inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture 13 Introduction to MIPS Instruction Representation I Lecturer PSOE Dan Garcia www.cs.berkeley.edu/~ddgarcia Anyone seen Terminator? Military

### MIPS Processor Overview

MIPS Processor Cptr280 Dr Curtis Nelson MIPS Processor Overview Hardware Design philosophy Architecture Software Assembly language program structure QTSpim simulator Example programs 1 MIPS Processor Power

### MIPS PROJECT INSTRUCTION SET and FORMAT

ECE 312: Semester Project MIPS PROJECT INSTRUCTION SET FORMAT This is a description of the required MIPS instruction set, their meanings, syntax, semantics, bit encodings. The syntax given for each instruction

### CS 61c: Great Ideas in Computer Architecture

Introduction to Assembly Language June 30, 2014 Review C Memory Layout Local variables disappear because the stack changes Global variables don t disappear because they are in static data Dynamic memory

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

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.

### The overall datapath for RT, lw,sw beq instrucution

Designing The Main Control Unit: Remember the three instruction classes {R-type, Memory, Branch}: a) R-type : Op rs rt rd shamt funct 1.src 2.src dest. 31-26 25-21 20-16 15-11 10-6 5-0 a) Memory : Op rs

### CS61C L10 MIPS Instruction Representation II, Floating Point I (6)

CS61C L1 MIPS Instruction Representation II, Floating Point I (1) inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture #1 Instruction Representation II, Floating Point I 25-1-3 There is one

### CS61C : Machine Structures

inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture 14 Introduction to MIPS Instruction Representation II Lecturer PSOE Dan Garcia www.cs.berkeley.edu/~ddgarcia Are you P2P sharing fans? Two

### Chapter 5. The Processor. Islamic University of Gaza 2009/2010

Chapter 5 The Processor Husam Alzaq Islamic University of Gaza 2009/2010 Introduction CPU performance factors Instruction ti count Determined by ISA and compiler CPI and Cycle time Determined by CPU hardware

### CS61C : Machine Structures

inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture #10 Instruction Representation II, Floating Point I 2005-10-03 Lecturer PSOE, new dad Dan Garcia www.cs.berkeley.edu/~ddgarcia #9 bears

### Chapter 2. Instructions: Language of the Computer

Chapter 2 Instructions: Language g of the Computer Stored Program Computers The BIG Picture Instructions represented in binary, just like data Instructions and data stored in memory Programs can operate

### Computer Systems and Networks. ECPE 170 Jeff Shafer University of the Pacific. MIPS Assembly

ECPE 170 Jeff Shafer University of the Pacific MIPS Assembly 2 Lab Schedule This Week Activities MIPS discussion Practice problems (whiteboard) Using the QtSPIM simulator Discuss available resources Lab

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

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

### Computer Hardware Engineering

Computer Hardware Engineering IS2, spring 27 Lecture 9: LU and s ssociate Professor, KTH Royal Institute of Technology Slides version. 2 Course Structure Module : C and ssembly Programming LE LE2 LE EX

### Overview of the MIPS Architecture: Part I. CS 161: Lecture 0 1/24/17

Overview of the MIPS Architecture: Part I CS 161: Lecture 0 1/24/17 Looking Behind the Curtain of Software The OS sits between hardware and user-level software, providing: Isolation (e.g., to give each

### Lecture 3: The Instruction Set Architecture (cont.)

Lecture 3: The Instruction Set Architecture (cont.) COS / ELE 375 Computer Architecture and Organization Princeton University Fall 2015 Prof. David August 1 Review: Instructions Computers process information

### Mips Code Examples Peter Rounce

Mips Code Examples Peter Rounce P.Rounce@cs.ucl.ac.uk Some C Examples Assignment : int j = 10 ; // space must be allocated to variable j Possibility 1: j is stored in a register, i.e. register \$2 then

### MIPS (SPIM) Assembler Syntax

MIPS (SPIM) Assembler Syntax Comments begin with # Everything from # to the end of the line is ignored Identifiers are a sequence of alphanumeric characters, underbars (_), and dots () that do not begin

### Single Cycle Datapath

Single Cycle atapath Lecture notes from MKP, H. H. Lee and S. Yalamanchili Section 4.-4.4 Appendices B.7, B.8, B.,.2 Practice Problems:, 4, 6, 9 ing (2) Introduction We will examine two MIPS implementations

### CPU Organization (Design)

ISA Requirements CPU Organization (Design) Datapath Design: Capabilities & performance characteristics of principal Functional Units (FUs) needed by ISA instructions (e.g., Registers, ALU, Shifters, Logic

### CSE A215 Assembly Language Programming for Engineers

CSE A215 Assembly Language Programming for Engineers Lecture 7 MIPS vs. ARM (COD Chapter 2 and Exam #1 Review) October 12, 2012 Sam Siewert Comparison of MIPS32 and ARM Instruction Formats and Addressing

### Lecture 2: RISC V Instruction Set Architecture. Housekeeping

S 17 L2 1 18 447 Lecture 2: RISC V Instruction Set Architecture James C. Hoe Department of ECE Carnegie Mellon University Housekeeping S 17 L2 2 Your goal today get bootstrapped on RISC V RV32I to start

EE 352 Unit 3 MIPS ISA Instruction Set Architecture (ISA) Defines the software interface of the processor and memory system Instruction set is the vocabulary the HW can understand and the SW is composed

### CS 61C: Great Ideas in Computer Architecture Introduction to Assembly Language and MIPS Instruction Set Architecture

CS 61C: Great Ideas in Computer Architecture Introduction to Assembly Language and MIPS Instruction Set Architecture Instructors: Bernhard Boser & Randy H. Katz http://inst.eecs.berkeley.edu/~cs61c/fa16

### CO Computer Architecture and Programming Languages CAPL. Lecture 18 & 19

CO2-3224 Computer Architecture and Programming Languages CAPL Lecture 8 & 9 Dr. Kinga Lipskoch Fall 27 Single Cycle Disadvantages & Advantages Uses the clock cycle inefficiently the clock cycle must be

### CS61C : Machine Structures

inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture 14 Introduction to MIPS Instruction Representation II 2004-02-23 Lecturer PSOE Dan Garcia www.cs.berkeley.edu/~ddgarcia In the US, who is

### Field 6-Bit Op Code rs Field rt Field 16-bit Immediate field

Introduction to MIPS Instruction Set Architecture The MIPS used by SPIM is a 32-bit reduced instruction set architecture with 32 integer and 32 floating point registers. Other characteristics are as follows:

### CS3350B Computer Architecture MIPS Procedures and Compilation

CS3350B Computer Architecture MIPS Procedures and Compilation Marc Moreno Maza http://www.csd.uwo.ca/~moreno/cs3350_moreno/index.html Department of Computer Science University of Western Ontario, Canada

### MIPS Pipelining. Computer Organization Architectures for Embedded Computing. Wednesday 8 October 14

MIPS Pipelining Computer Organization Architectures for Embedded Computing Wednesday 8 October 14 Many slides adapted from: Computer Organization and Design, Patterson & Hennessy 4th Edition, 2011, MK

### Design of Digital Circuits 2017 Srdjan Capkun Onur Mutlu (Guest starring: Frank K. Gürkaynak and Aanjhan Ranganathan)

Microarchitecture Design of Digital Circuits 27 Srdjan Capkun Onur Mutlu (Guest starring: Frank K. Gürkaynak and Aanjhan Ranganathan) http://www.syssec.ethz.ch/education/digitaltechnik_7 Adapted from Digital

### We will study the MIPS assembly language as an exemplar of the concept.

MIPS Assembly Language 1 We will study the MIPS assembly language as an exemplar of the concept. MIPS assembly instructions each consist of a single token specifying the command to be carried out, and

### Lecture 2: The Instruction Set Architecture

Lecture 2: The Instruction Set Architecture COS / ELE 375 Computer Architecture and Organization Princeton University Fall 2015 Prof. David August 1 2 Quiz 0 3 Quiz 0 CD 3 Miles of Music 4 Pits and Lands

### Instruction-set Design Issues: what is the ML instruction format(s) ML instruction Opcode Dest. Operand Source Operand 1...

Instruction-set Design Issues: what is the format(s) Opcode Dest. Operand Source Operand 1... 1) Which instructions to include: How many? Complexity - simple ADD R1, R2, R3 complex e.g., VAX MATCHC substrlength,

### COMP 303 MIPS Processor Design Project 3: Simple Execution Loop

COMP 303 MIPS Processor Design Project 3: Simple Execution Loop Due date: November 20, 23:59 Overview: In the first three projects for COMP 303, you will design and implement a subset of the MIPS32 architecture

### Basic Processor Design

Basic Processor Design Design Instruction Set Design Datapath Design Control Unit This lecture deals with Instruction Set Design. 1001 Instruction Set Terminology Mnemonic (Instruction Name) SUBI Syntax

### MIPS Hello World. MIPS Assembly 1. # PROGRAM: Hello, World! # Data declaration section. out_string:.asciiz "\nhello, World!\n"

MIPS Hello World MIPS Assembly 1 # PROGRAM: Hello, World!.data # Data declaration section out_string:.asciiz "\nhello, World!\n".text # Assembly language instructions main: # Start of code section li \$v0,

### Computer Organization CS 206 T Lec# 2: Instruction Sets

Computer Organization CS 206 T Lec# 2: Instruction Sets Topics What is an instruction set Elements of instruction Instruction Format Instruction types Types of operations Types of operand Addressing mode

### MIPS Assembly Programming

COMP 212 Computer Organization & Architecture COMP 212 Fall 2008 Lecture 8 Cache & Disk System Review MIPS Assembly Programming Comp 212 Computer Org & Arch 1 Z. Li, 2008 Comp 212 Computer Org & Arch 2

### Shift and Rotate Instructions

Shift and Rotate Instructions Shift and rotate instructions facilitate manipulations of data (that is, modifying part of a 32-bit data word). Such operations might include: Re-arrangement of bytes in a

### Numbers: positional notation. CS61C Machine Structures. Faux Midterm Review Jaein Jeong Cheng Tien Ee. www-inst.eecs.berkeley.

CS 61C Faux Midterm Review (1) CS61C Machine Structures Faux Midterm Review 2002-09-29 Jaein Jeong Cheng Tien Ee www-inst.eecs.berkeley.edu/~cs61c/ Numbers: positional notation Number Base B B symbols

### William Stallings Computer Organization and Architecture 8 th Edition. Chapter 11 Instruction Sets: Addressing Modes and Formats

William Stallings Computer Organization and Architecture 8 th Edition Chapter 11 Instruction Sets: Addressing Modes and Formats Addressing Modes Immediate Direct Indirect Register Register Indirect Displacement

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

Today s Lecture Homework #2 Midterm I Feb 22 (in class closed book) MIPS Assembly Language Computer Science 14 Lecture 6 Outline Assembly Programming Reading Chapter 2, Appendix B 2 Review: A Program Review:

### CPU Organization. Hardware design. Vs. Microprogramming

CPU Organization Hardware design Vs. Microprogramming CPU Structure CPU must: Fetch instructions ti Interpret instructionsi Fetch data Process data Write data Source: Hamacher; Single-bus ORGN. CPU always

### EE 109 Unit 8 MIPS Instruction Set

1 EE 109 Unit 8 MIPS Instruction Set 2 Architecting a vocabulary for the HW INSTRUCTION SET OVERVIEW 3 Instruction Set Architecture (ISA) Defines the software interface of the processor and memory system

### MIPS ISA and MIPS Assembly. CS301 Prof. Szajda

MIPS ISA and MIPS Assembly CS301 Prof. Szajda Administrative HW #2 due Wednesday (9/11) at 5pm Lab #2 due Friday (9/13) 1:30pm Read Appendix B5, B6, B.9 and Chapter 2.5-2.9 (if you have not already done

### ECE170 Computer Architecture. Single Cycle Control. Review: 3b: Add & Subtract. Review: 3e: Store Operations. Review: 3d: Load Operations

ECE7 Computer Architecture Single Cycle Control Review: 3a: Overview of the Fetch Unit The common operations Fetch the : mem[] Update the program counter: Sequential Code: < + Branch and Jump: < something

### 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

Do-While Example In C++ do { z--; while (a == b); z = b; In assembly language loop: addi \$s2, \$s2, -1 beq \$s0, \$s1, loop or \$s2, \$s1, \$zero 25 Comparisons Set on less than (slt) compares its source registers

### Midterm. CS64 Spring Midterm Exam

Midterm LAST NAME FIRST NAME PERM Number Instructions Please turn off all pagers, cell phones and beepers. Remove all hats & headphones. Place your backpacks, laptops and jackets at the front. Sit in every

### CS61C Machine Structures. Lecture 10 - MIPS Branch Instructions II. 2/8/2006 John Wawrzynek. (www.cs.berkeley.edu/~johnw)

CS61C Machine Structures Lecture 10 - MIPS Branch Instructions II 2/8/2006 John Wawrzynek (www.cs.berkeley.edu/~johnw) www-inst.eecs.berkeley.edu/~cs61c/ CS 61C L10 MIPS Branch II (1) Compiling C if into

### CS311 Lecture: Pipelining, Superscalar, and VLIW Architectures revised 10/18/07

CS311 Lecture: Pipelining, Superscalar, and VLIW Architectures revised 10/18/07 Objectives ---------- 1. To introduce the basic concept of CPU speedup 2. To explain how data and branch hazards arise as

### COMP3221: Microprocessors and. and Embedded Systems. Instruction Set Architecture (ISA) What makes an ISA? #1: Memory Models. What makes an ISA?

COMP3221: Microprocessors and Embedded Systems Lecture 2: Instruction Set Architecture (ISA) http://www.cse.unsw.edu.au/~cs3221 Lecturer: Hui Wu Session 2, 2005 Instruction Set Architecture (ISA) ISA is

### CS/COE0447: Computer Organization

CS/COE0447: Computer Organization and Assembly Language Datapath and Control Sangyeun Cho Dept. of Computer Science A simple MIPS We will design a simple MIPS processor that supports a small instruction

### Computer Architecture. Chapter 3: Arithmetic for Computers

182.092 Computer Architecture Chapter 3: Arithmetic for Computers Adapted from Computer Organization and Design, 4 th Edition, Patterson & Hennessy, 2008, Morgan Kaufmann Publishers and Mary Jane Irwin

### CISC 360 Instruction Set Architecture

CISC 360 Instruction Set Architecture Michela Taufer October 9, 2008 Powerpoint Lecture Notes for Computer Systems: A Programmer's Perspective, R. Bryant and D. O'Hallaron, Prentice Hall, 2003 Chapter

### Instruction Set Architecture (Contd)

Instruction Set Architecture (Contd) Lecture 3 (Chapter 2) EEC170 FQ 2005 Review: MIPS Architecture Good example of RISC processor: Reduced Instruction-Set Computer RISC really a misnomer: architecture

### Instruction Set Architecture (ISA)

Instruction Set Architecture (ISA)... the attributes of a [computing] system as seen by the programmer, i.e. the conceptual structure and functional behavior, as distinct from the organization of the data

### Pipelining! Advanced Topics on Heterogeneous System Architectures. Politecnico di Milano! Seminar DEIB! 30 November, 2017!

Advanced Topics on Heterogeneous System Architectures Pipelining! Politecnico di Milano! Seminar Room @ DEIB! 30 November, 2017! Antonio R. Miele! Marco D. Santambrogio! Politecnico di Milano! 2 Outline!

### CS61C : Machine Structures

inst.eecs.berkeley.edu/~cs61c/su06 CS61C : Machine Structures Lecture #9: MIPS Procedures 2006-07-11 CS 61C L09 MIPS Procedures (1) Andy Carle C functions main() { int i,j,k,m;... i = mult(j,k);... m =

### CPE 335. Basic MIPS Architecture Part II

CPE 335 Computer Organization Basic MIPS Architecture Part II Dr. Iyad Jafar Adapted from Dr. Gheith Abandah slides http://www.abandah.com/gheith/courses/cpe335_s08/index.html CPE232 Basic MIPS Architecture

### Virtual Machines and Dynamic Translation: Implementing ISAs in Software

Virtual Machines and Dynamic Translation: Implementing ISAs in Software Krste Asanovic Laboratory for Computer Science Massachusetts Institute of Technology Software Applications How is a software application