Chapter 2 Instructions: Language of the Computer Part I.

Slides:



Advertisements
Similar presentations
Instruction Set Design
Advertisements

Lecture 13: 10/8/2002CS170 Fall CS170 Computer Organization and Architecture I Ayman Abdel-Hamid Department of Computer Science Old Dominion University.
Instruction Set-Intro
1 Lecture 3: Instruction Set Architecture ISA types, register usage, memory addressing, endian and alignment, quantitative evaluation.
1 ECE462/562 ISA and Datapath Review Ali Akoglu. 2 Instruction Set Architecture A very important abstraction –interface between hardware and low-level.
1 ECE369 ECE369 Chapter 2. 2 ECE369 Instruction Set Architecture A very important abstraction –interface between hardware and low-level software –standardizes.
CS3350B Computer Architecture Winter 2015 Lecture 4
Systems Architecture Lecture 5: MIPS Instruction Set
Chapter 2 Instructions: Language of the Computer
Chapter 2.
CS 61C L07 MIPS Intro (1) A Carle, Summer 2006 © UCB inst.eecs.berkeley.edu/~cs61c/su06 CS61C : Machine Structures Lecture #6: Intro to MIPS
CS61C L05 Introduction to MIPS Assembly Language : Arithmetic (1) Garcia, Fall 2011 © UCB Lecturer SOE Dan Garcia inst.eecs.berkeley.edu/~cs61c.
COMP3221 lec08-arith.1 Saeid Nooshabadi COMP 3221 Microprocessors and Embedded Systems Lecture 8: C/Assembler Data Processing
CS 61C L06 MIPS Intro (1) A Carle, Summer 2005 © UCB inst.eecs.berkeley.edu/~cs61c/su05 CS61C : Machine Structures Lecture #6: Intro to MIPS
CS61C L08 Introduction to MIPS Assembly Language: Arithmetic (1) Garcia © UCB Lecturer PSOE Dan Garcia inst.eecs.berkeley.edu/~cs61c.
Normal C Memory Management °A program’s address space contains 4 regions: stack: local variables, grows downward heap: space requested for pointers via.
RISC By Don Nichols. Contents Introduction History Problems with CISC RISC Philosophy Early RISC Modern RISC.
CIS 314: Introduction to MIPS Assembly Language: Arithmetic Fall 2005 I´ve been getting this a lot lately So, what are you teaching this term? Computer.
CS61C L08 Introduction to MIPS Assembly Language : Arithmetic (1) Garcia, Spring 2008 © UCB Lecturer SOE Dan Garcia inst.eecs.berkeley.edu/~cs61c.
ECE 15B Computer Organization Spring 2010 Dmitri Strukov Lecture 3: Arithmetic Instructions Partially adapted from Computer Organization and Design, 4.
Lecture 5 Sept 14 Goals: Chapter 2 continued MIPS assembly language instruction formats translating c into MIPS - examples.
CS1104 Assembly Language: Part 1
CIS 314 : Computer Organization Lecture 1 – Introduction.
CS 61C L08 Introduction to MIPS Assembly Language: Arithmetic (1) Garcia, Spring 2004 © UCB Lecturer PSOE Dan Garcia inst.eecs.berkeley.edu/~cs61c.
Implementation of a Stored Program Computer
COMPUTER ARCHITECTURE & OPERATIONS I Instructor: Hao Ji.
Data Transfer & Decisions I (1) Fall 2005 Lecture 3: MIPS Assembly language Decisions I.
CMPT 334 Computer Organization Chapter 2 Instructions: Language of the Computer [Adapted from Computer Organization and Design 5 th Edition, Patterson.
MIPS assembly. Computer What’s in a computer? Processor, memory, I/O devices (keyboard, mouse, LCD, video camera, speaker), disk, CD drive, …
CS 61C L2.1.2 MM and MIPS (1) K. Meinz, Summer 2004 © UCB CS61C : Machine Structures Lecture Garbage Collection & Intro to MIPS Kurt Meinz.
Implementation of a Stored Program Computer ITCS 3181 Logic and Computer Systems 2014 B. Wilkinson Slides2.ppt Modification date: Oct 16,
Reformatting a Machine 125 Million Miles Away! Mars rover “Opportunity” got its flash drive reformatted 9/8/14, reason: rover keeps rebooting. Happy news:
Lecture 4: MIPS Instruction Set Reminders: –Homework #1 posted: due next Wed. –Midterm #1 scheduled Friday September 26 th, 2014 Location: TODD 430 –Midterm.
1 Computer Architecture COSC 3430 Lecture 3: Instructions.
Computer Architecture (CS 207 D) Instruction Set Architecture ISA.
CPS3340 COMPUTER ARCHITECTURE Fall Semester, /08/2013 Lecture 10: MIPS Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL STATE.
Chapter 2 CSF 2009 The MIPS Assembly Language. Stored Program Computers Instructions represented in binary, just like data Instructions and data stored.
Adapted from Computer Organization and Design, Patterson & Hennessy, UCB ECE232: Hardware Organization and Design Part 5: MIPS Instructions I
DR. SIMING LIU SPRING 2016 COMPUTER SCIENCE AND ENGINEERING UNIVERSITY OF NEVADA, RENO CS 219 Computer Organization.
DR. SIMING LIU SPRING 2016 COMPUTER SCIENCE AND ENGINEERING UNIVERSITY OF NEVADA, RENO Session 7, 8 Instruction Set Architecture.
Instruction Set Architecture Chapter 3 – P & H. Introduction Instruction set architecture interface between programmer and CPU Good ISA makes program.
CS 61C: Great Ideas in Computer Architecture Intro to Assembly Language, MIPS Intro 1 Instructors: Vladimir Stojanovic & Nicholas Weaver
MIPS assembly. Computer  What’s in a computer?  Processor, memory, I/O devices (keyboard, mouse, LCD, video camera, speaker), disk, CD drive, …
Assembly Variables: Registers Unlike HLL like C or Java, assembly cannot use variables – Why not? Keep Hardware Simple Assembly Operands are registers.
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
CS61C L05 Introduction to MIPS Assembly Language : Arithmetic (1) Garcia, Spring 2014 © UCB TA/Guest Lecturer: Shreyas Chand inst.eecs.berkeley.edu/~cs61c.
Assembly Language Basic job of a CPU: execute lots of instructions. Instructions are the primitive operations that the CPU may execute. Different CPUs.
Computers’ Basic Organization
Computer Architecture & Operations I
Computer Architecture & Operations I
IT 251 Computer Organization and Architecture
Lecturer PSOE Dan Garcia
Instruction Set Architecture
Morgan Kaufmann Publishers
IT 251 Computer Organization and Architecture
Computer Architecture (CS 207 D) Instruction Set Architecture ISA
CSCI206 - Computer Organization & Programming
Systems Architecture I (CS ) Lecture 5: MIPS Instruction Set*
Systems Architecture Lecture 5: MIPS Instruction Set
The University of Adelaide, School of Computer Science
Chapter 2 Instructions: Language of the Computer
Hello to Jessy VanDivner listening from Ohio!
Computer Architecture
September 17 Test 1 pre(re)view Fang-Yi will demonstrate Spim
The University of Adelaide, School of Computer Science
Instructions in Machine Language
COMS 361 Computer Organization
CPU Structure CPU must:
CS334: MIPS language _Mars simulator Lab 2_1
Systems Architecture I (CS ) Lecture 5: MIPS Instruction Set*
Presentation transcript:

Chapter 2 Instructions: Language of the Computer Part I

Florida A & M University - Department of Computer and Information Sciences Instruction Set (Assembly Lang.) Instructions language of the machine primitive operations that the CPU may execute Instruction set commands understood set of instructions a particular CPU implements Computer design goal easy to build hardware and compiler, maximize performance, and minimize cost

Florida A & M University - Department of Computer and Information Sciences Instruction Set The repertoire of instructions of a computer Different computers have different instruction sets But with many of the same instruction types Early computers had very simple instruction sets Simplified implementation Many modern computers also have simple instruction sets

Florida A & M University - Department of Computer and Information Sciences Instruction Set Architectures Early trend was to add more and more instructions to new CPUs to do elaborate operations VAX architecture had an instruction to multiply polynomials! Reduced Instruction Set Computing (RISC) philosophy (Cocke IBM, Patterson, Hennessy, 1980s): Keep the instruction set small and simple Makes it easier to build fast hardware. Let software do complicated operations by composing simpler ones.

Florida A & M University - Department of Computer and Information Sciences RISC - Reduced Instruction Set Computer RISC philosophy fixed instruction lengths load-store instruction sets limited addressing modes limited operations MIPS, Sun SPARC, HP PA-RISC, IBM PowerPC, Intel (Compaq) Alpha, … Instruction sets are measured by how well compilers use them as opposed to how well assembly language programmers use them

Florida A & M University - Department of Computer and Information Sciences The MIPS Instruction Set MIPS Technologies – semiconductor company that built one of the first commercial RISC architectures commercialized Stanford MIPS Used as example throughout textbook Typical of many modern ISAs See MIPS Reference Data tear-out card, and Appendixes B and E MIPS is simple, elegant. Large share of embedded core market Applications in consumer electronics, network/storage equipment, cameras, printers, …

Florida A & M University - Department of Computer and Information Sciences Assembly Instructions Each statement (called an instruction), executes exactly one of a short list of simple commands Unlike in C++ (and most other HLLs) where each line can contain multiple operations Instructions are related to operations (=, +, -, *, /) in C++ or Java Ok, enough already…gimme my MIPS!

Florida A & M University - Department of Computer and Information Sciences MIPS Arithmetic Operations Syntax of Instructions: 12, 3, 4 where: 1 : operation by name 2 : operand getting result (“destination”) 3 : first operand for operation (“source1”) 4 : second operand for operation (“source2”)

Florida A & M University - Department of Computer and Information Sciences MIPS Arithmetic Instructions “ 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” three operands and one operation Design Principle 1: Simplicity favors regularity Regularity makes implementation simpler Simplicity enables higher performance at lower cost

Florida A & M University - Department of Computer and Information Sciences Arithmetic Operations Addition a = b + c (in C++) add a, b, c (in MIPS) Subtraction d = e - f (in C++) sub d, e, f (in MIPS)

Florida A & M University - Department of Computer and Information Sciences Arithmetic Operations How do the following C++ statement? a = b + c + d - e; Compiled into multiple MIPS instructions add a, b, c # a = b + c add a, a, d # a = a + d sub a, a, e # a = a – e Notice: A single line of C may become several lines of MIPS Notice: Everything after the hash mark on each line is ignored (comments)

Florida A & M University - Department of Computer and Information Sciences Arithmetic Example What about this example? f = (g + h) - (i + j); Use temporary variables? add temp1, g, h # temp1 = g + h add temp2, i, j # temp2 = i + j sub f, temp1, temp2 # f = temp1 – temp2 # = (g + h) – (i + j)

Florida A & M University - Department of Computer and Information Sciences Register Operands Arithmetic instructions use register operands ONLY MIPS has 32 registers in the CPU About half of them are freely available for calculations Benefit: Registers are the fastest memory Access time of < nanosecond (billionth of a sec) Disadvantage: -Registers are the fastest memory Access time of < nanosecond (billionth of a sec)

Florida A & M University - Department of Computer and Information Sciences Register Operands Drawback: Since registers are in hardware, there is a predetermined number of them Solution: MIPS code must use registers wisely. 32 registers in MIPS Design Principle 2: Smaller and faster main memory: millions of locations Each MIPS register is 32 bits wide 32-bit data called a word in MIPS Natural unit of access

Florida A & M University - Department of Computer and Information Sciences Register Operands MIPS has a bit registers Use for frequently accessed data Numbered 0 to 31 $0, $1, $2, …, $31 Has assembler names for easier coding $8 - $15  $t0, $t1, …, $t9 (temporary values) $16 - $23  $s0, $s1, …, $s7 (saved variables) Remaining 16 explained later

Florida A & M University - Department of Computer and Information Sciences Variables vs. Registers C++ variables int Farenheit, Celsius; char a, b, c, d, e; Must be declared first with a name & type Type must be same throughout program Registers Have no type Operation determines how register contents are treated

Florida A & M University - Department of Computer and Information Sciences Register Operand Examples a = b + c; Allocations: a:s0, b:$s1, c:$s2 MIPS assembly code: add $s0, $s1, $s2 a = b + c + d - e; Allocations: a, b, c, d, e: $s0, $s1, $s2, $s3, $s4 MIPS assembly code: add $s0, $s1, $s2 # a = b + c add $s0, $s0, $s3 # a = a + d sub $s0, $s0, $s4 # a = a - e

Florida A & M University - Department of Computer and Information Sciences Register Operand Example f = (g + h) - (i + j); Allocations: f:$s0, g:$s1, h:$s2, i:$s3, j:$s4 (g+h):$t0, (i+j):$t1, MIPS assembly code: add $t1, $s1, $s2 # temp1 = g + h add $t2, $s3, $s4 # temp2 = i + j sub $s0, $t1, $t2 # f = temp1 – temp2 # = (g + h)-(i + j)

Florida A & M University - Department of Computer and Information Sciences Register Operands Arithmetic instructions operands must be registers, — only 32 registers provided Compiler associates variables with registers What about programs with lots of variables ProcessorI/O Control Datapath Memory Input Output

Florida A & M University - Department of Computer and Information Sciences Memory 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. “Word addressing”  the index points to the start of a word (4 contiguous) bytes bits of data

Florida A & M University - Department of Computer and Information Sciences Memory Bytes are nice, but most data items use larger "words" For MIPS, a word is 32 bits or 4 bytes bytes with byte addresses from 0 to words with byte addresses 0, 4, 8, bits of data Registers hold 32 bits of data

Florida A & M University - Department of Computer and Information Sciences Memory Alignment MIPS requires the address of a word to start at an address that is a multiple of 4 bytes. Alignment Restriction: an object can be only be accessed using an address that is multiple of its size in bytes Word Aligned Not Aligned 0, 4, 8, or C hex Last hex digit of address is: 1, 5, 9, or D hex 2, 6, A hex, or E hex 3, 7, B hex, or F hex

Florida A & M University - Department of Computer and Information Sciences Memory Addressing Pitfall Rule: Word addresses are 0,4,8,12,… Word at address Q is followed by the word at address Q+4 Pitfall: assuming next word is at Q+1 Distinction: the next byte is at Q+1

Florida A & M University - Department of Computer and Information Sciences Registers vs. Memory Registers are faster to access than memory What if more variables than registers? Compiler tries to keep most frequently used variable in registers (register optimization) Less frequently used variables in memory: spilling Why not keep all variables in memory? Smaller is faster: registers are faster than memory