IC220 SlideSet #2: Instructions (Chapter 2)

Similar documents
Chapter 3. Instructions:

Chapter 2. Instructions:

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

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

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

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

Chapter 2: Instructions:

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

COMPSCI 313 S Computer Organization. 7 MIPS Instruction Set

ECE369. Chapter 2 ECE369

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

Hardware Level Organization

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

Operations, Operands, and Instructions

CSEE 3827: Fundamentals of Computer Systems

Chapter 2 Instruction: Language of the Computer

EECS Computer Organization Fall Based on slides by the author and prof. Mary Jane Irwin of PSU.

Chapter 2. Instruction Set Architecture (ISA)

Lecture 3 Machine Language. Instructions: Instruction Execution cycle. Speaking computer before voice recognition interfaces

CS222: MIPS Instruction Set

ECE232: Hardware Organization and Design

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

EN164: Design of Computing Systems Lecture 09: Processor / ISA 2

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

Math 230 Assembly Programming (AKA Computer Organization) Spring MIPS Intro

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

ECE260: Fundamentals of Computer Engineering

Lecture 4: Instruction Set Architecture

Instructions: Language of the Computer

EEC 581 Computer Architecture Lecture 1 Review MIPS

Topic Notes: MIPS Instruction Set Architecture

Introduction. Datapath Basics

Architecture I. Computer Systems Laboratory Sungkyunkwan University

Unsigned Binary Integers

Unsigned Binary Integers

CS3350B Computer Architecture

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

Computer Architecture. Lecture 2 : Instructions

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

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

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

CS/COE0447: Computer Organization

CS/COE0447: Computer Organization

CSCI 402: Computer Architectures

Math 230 Assembly Programming (AKA Computer Organization) Spring 2008

ECE232: Hardware Organization and Design

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

Lecture 4: MIPS Instruction Set

Chapter 4. The Processor Designing the datapath

Computer Architecture

MIPS Instruction Set Architecture (1)

CS3350B Computer Architecture MIPS Introduction

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

Computer Architecture

Levels of Programming. Registers

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

Chapter 2A Instructions: Language of the Computer

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

CS3350B Computer Architecture MIPS Instruction Representation

Instruction Set Architecture

378: Machine Organization and Assembly Language

CISC 662 Graduate Computer Architecture. Lecture 4 - ISA

Computer Model. What s in a computer? Processor Memory I/O devices (keyboard, mouse, LCD, video camera, speaker, disk, CD drive, )

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

CS 61c: Great Ideas in Computer Architecture

(Refer Slide Time: 1:40)

Pipelining Analogy. Pipelined laundry: overlapping execution. Parallelism improves performance. Four loads: Non-stop: Speedup = 8/3.5 = 2.3.

ECE 154A Introduction to. Fall 2012

CENG3420 L03: Instruction Set Architecture

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

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

Processor (I) - datapath & control. Hwansoo Han

Instructions: Language of the Computer

Chapter 4. The Processor

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

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

ECE 486/586. Computer Architecture. Lecture # 7

Computer Organization MIPS ISA

ADD R Operation : ACC = ACC + R SIZE : 1 byte, 8 bit Time : 3 T Cycle Work : Read R, Read ACC, Add, Write Result to ACC

Concepts Introduced in Chapter 3

Chapter 4. The Processor

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

Mark Redekopp and Gandhi Puvvada, All rights reserved. EE 357 Unit 15. Single-Cycle CPU Datapath and Control

ECE260: Fundamentals of Computer Engineering

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

Chapter 1. Computer Abstractions and Technology

Chapter 4. The Processor

The Processor. Z. Jerry Shi Department of Computer Science and Engineering University of Connecticut. CSE3666: Introduction to Computer Architecture

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

CS 4200/5200 Computer Architecture I

MIPS (SPIM) Assembler Syntax

The Processor: Datapath and Control. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

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

The Processor (1) Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

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

Chapter 4. Instruction Execution. Introduction. CPU Overview. Multiplexers. Chapter 4 The Processor 1. The Processor.

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

Pipelining. CSC Friday, November 6, 2015

Chapter 4. The Processor

Transcription:

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 Illustrate basic instruction set design principles Credits: Much course material in some way derived from Official textbook (Copyright Morgan Kaufmann) Prof. Margarget McMahon (USNA) 1 2 Instructions: MIPS arithmetic Language of the Machine More primitive than higher level languages All instructions have 3 operands Operand order is fixed Very restrictive e.g., MIPS Arithmetic Instructions Example: C code: A = B + C We ll be working with the MIPS instruction set architecture similar to other architectures developed since the 1980's used by Tivo, Cisco routers, Nintendo 6, Sony PlayStation on New Horizons spacecraft that reached Pluto in July 2015! MIPS code: add $s0, $s1, $s2 Design principles: to be found Design goals: 3

MIPS arithmetic Registers vs. Memory Design Principle #1: simplicity favors regularity. Why? Design Principle #2: smaller is faster. Why? Of course this complicates some things... C code: A = B + C + D; E = F - A; MIPS code: add $t0, $s1, $s2 add $s0, $t0, $s3 sub $s, $s5, $s0 Therefore, arithmetic instruction operands must be registers And only 32 registers provided Control Datapath Memory Input Output Processor I/O Compiler associates variables with registers What about programs with lots of variables? 5 6 Memory Organization Memory Organization Viewed as a large, single-dimension array, with an address. A memory address is an index into the array "Byte addressing" means that the index points to a byte of memory. 0 1 2 3 5 6... Bytes are nice, but most data items use larger "words" For MIPS, a word is 32 bits or bytes. 0 8 12... Valid byte addresses: 0, 1, 2, 3,,. 2 32-1 Valid word addresses 0,, 8,... 2 32 - Words are aligned Registers hold 7 8

Array layout in memory Memory Instructions Load and store instructions Example: C code: MIPS code: A[8] = h + A[8]; lw $t0, 32($s3) add $t0, $s2, $t0 sw $t0, 32($s3) For lw/sw, address always = register value + offset How about this? add $t0, 32($s3), $t0 9 10 So far we ve learned: Ex 2-1 to 2-3 Machine Language MIPS loading words but addressing bytes arithmetic on registers only Instruction Meaning add $s1, $s2, $s3 $s1 = $s2 + $s3 sub $s1, $s2, $s3 $s1 = $s2 $s3 lw $s1, 100($s2) $s1 = Memory[$s2+100] sw $s1, 100($s2) Memory[$s2+100] = $s1 Instructions, like registers and words of data, are also 32 bits long Example: add $t0, $s1, $s2 registers have numbers, $t0=8, $s1=17, $s2=18 Instruction Format (r-type): 000000 10001 10010 01000 00000 100000 11 12

Machine Language Example Part 1 Consider the load-word and store-word instructions, What would the regularity principle have us do? BIG IDEA: Make the common case fast Principle #3: Good design demands a compromise Introduce a new type of instruction format I-type for data transfer instructions Example: lw $t0, ($s2) What is the machine code for the following: A[300] = h + A[300]; Variable h is assigned register $s2 Array A base address is assigned register $t1 Do the assembly code first, then machine language instructions, and then machine code 35 18 8 op rs rt 16 bit number Where's the compromise? 13 1 Example Part 2 Example Part 3 What is the machine code for the following: A[300] = h + A[300]; Variable h is assigned register $s2 & Array A base address is assigned register $t1 First part of answer: lw $t0, 1200($t1) # Temporary reg $t0 gets A[300] add $t0, $s2, $t0 # Temporary reg $t0 gets h + A[300] sw $t0, 1200($t1) # Stores h + A[300] back into A[300] Second part of answer (DECIMAL): 35 9 8 1200 0 18 8 8 0 32 3 9 8 1200 What is the machine code for the following: A[300] = h + A[300]; Variable h is assigned register $s2 & Array A base address is assigned register $t1 First part of answer: lw $t0, 1200($t1) # Temporary reg $t0 gets A[300] add $t0, $s2, $t0 # Temporary reg $t0 gets h + A[300] sw $t0, 1200($t1) # Stores h + A[300] back into A[300] Second part of answer (BINARY): 100011 01001 01000 0000 0100 1011 0000 000000 10010 01000 01000 00000 100000 101011 01001 01000 0000 0100 1011 0000 15 16

Stored Program Computers QUICK REVIEW 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 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 Design Principles 3 of them Arithmetic Operands Order Location of data Register MIPS provides Memory Organization Bits / Bytes / Words Alignment 17 18