Chapter 2.

Slides:



Advertisements
Similar presentations
Henk Corporaal TUEindhoven 2011
Advertisements

Lecture 13: 10/8/2002CS170 Fall CS170 Computer Organization and Architecture I Ayman Abdel-Hamid Department of Computer Science Old Dominion University.
Goal: Write Programs in Assembly
Instruction Set-Intro
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.
CS1104 – Computer Organization PART 2: Computer Architecture Lecture 5 MIPS ISA & Assembly Language Programming.
ELEN 468 Advanced Logic Design
Systems Architecture Lecture 5: MIPS Instruction Set
Chapter 2 Instructions: Language of the Computer
331 W08.1Spring :332:331 Computer Architecture and Assembly Language Spring 2006 Week 8: Datapath Design [Adapted from Dave Patterson’s UCB CS152.
1 Instructions: Language of the Machine More primitive than higher level languages e.g., no sophisticated control flow Very restrictive e.g., MIPS Arithmetic.
Instructions Set Bo Cheng Instruction Set Design An Instruction Set provides a functional description of a processor. It is the visible.
1 Lecture 2: MIPS Instruction Set Today’s topic:  MIPS instructions Reminder: sign up for the mailing list cs3810 Reminder: set up your CADE accounts.
Lecture 5 Sept 14 Goals: Chapter 2 continued MIPS assembly language instruction formats translating c into MIPS - examples.
COMPUTER ARCHITECTURE & OPERATIONS I Instructor: Hao Ji.
1  2004 Morgan Kaufmann Publishers Chapter 2. 2  2004 Morgan Kaufmann Publishers Instructions: Language of the Machine We’ll be working with the MIPS.
ISA-2 CSCE430/830 MIPS: Case Study of Instruction Set Architecture CSCE430/830 Computer Architecture Instructor: Hong Jiang Courtesy of Prof. Yifeng Zhu.
MIPS assembly. Computer What’s in a computer? Processor, memory, I/O devices (keyboard, mouse, LCD, video camera, speaker), disk, CD drive, …
순천향대학교 정보기술공학부 이 상 정 1 2. Instructions: Language of the Computer.
CSE331 W02.1Irwin Fall 2001 PSU Computer Architecture Discussion Lecture # 2 MIPS Programming.
1 Computer Architecture COSC 3430 Lecture 3: Instructions.
Chapter 2 Instructions: Language of the Computer Part I.
Computer Organization and Architecture Instructions: Language of the Machine Hennessy Patterson 2/E chapter 3. Notes are available with photocopier 24.
Computer Architecture CSE 3322 Lecture 2 NO CLASS MON Sept 1 Course WEB SITE crystal.uta.edu/~jpatters.
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 6 Instruction Set Architecture 12/7/
 1998 Morgan Kaufmann Publishers MIPS arithmetic All instructions have 3 operands Operand order is fixed (destination first) Example: C code: A = B +
Computer Organization CS224 Fall 2012 Lessons 7 and 8.
Computer Organization Rabie A. Ramadan Lecture 3.
EE472 – Spring 2007P. Chiang, with Slide Help from C. Kozyrakis (Stanford) ECE472 Computer Architecture Lecture #3—Oct. 2, 2007 Patrick Chiang TA: Kang-Min.
Chapter 2 — Instructions: Language of the Computer — 1 Memory Operands Main memory used for composite data – Arrays, structures, dynamic data To apply.
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.
MIPS assembly. Computer  What’s in a computer?  Processor, memory, I/O devices (keyboard, mouse, LCD, video camera, speaker), disk, CD drive, …
1  1998 Morgan Kaufmann Publishers Instructions: Language of the Machine More primitive than higher level languages e.g., no sophisticated control flow.
CHAPTER 2 Instruction Set Architecture 3/21/
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
Computer Architecture & Operations I
Computer Architecture & Operations I
COMPUTER ARCHITECTURE & OPERATIONS I
Instruction Set Architecture
Morgan Kaufmann Publishers
ELEN 468 Advanced Logic Design
The University of Adelaide, School of Computer Science
Computer Architecture (CS 207 D) Instruction Set Architecture ISA
MIPS Assembly.
CSCI206 - Computer Organization & Programming
Instructions - Type and Format
Lecture 4: MIPS Instruction Set
Systems Architecture I (CS ) Lecture 5: MIPS Instruction Set*
MISP Assembly.
CSCI206 - Computer Organization & Programming
The University of Adelaide, School of Computer Science
Systems Architecture Lecture 5: MIPS Instruction Set
MIPS assembly.
Computer Architecture & Operations I
The University of Adelaide, School of Computer Science
Computer Architecture
September 17 Test 1 pre(re)view Fang-Yi will demonstrate Spim
3.
UCSD ECE 111 Prof. Farinaz Koushanfar Fall 2018
COMS 361 Computer Organization
COMS 361 Computer Organization
MIPS Assembly.
Review In last lecture, done with unsigned and signed number representation. Introduced how to represent real numbers in float format.
CPU Structure CPU must:
Systems Architecture I (CS ) Lecture 5: MIPS Instruction Set*
Instruction Set Architecture
Presentation transcript:

Chapter 2

Instructions: Language of the Machine We’ll be working with the MIPS instruction set architecture MIPS (originally an acronym for Microprocessor without Interlocked Pipeline Stages) is a RISC microprocessor architecture developed by MIPS Technologies. By the late 1990s it was estimated that one in three RISC chips produced were MIPS-based designs MIPS :It presently stands for million instructions per second similar to other architectures developed since the 1980's Almost 100 million MIPS processors manufactured in 2002 used by NEC, Nintendo, Cisco, Silicon Graphics, Sony, …

MIPS arithmetic All instructions have 3 operands Operand order is fixed (destination first) Example: C code: a = b + c MIPS ‘code’: add a, b, c “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”

4 Design Principles Design Principle 1: Simplicity favors regularity. Design Principle 2: Smaller is faster. Design Principle 3: Make the common case fast. Design Principle 4: Good design demands good compromises.

MIPS arithmetic Design Principle: Simplicity favors regularity. Of course this complicates some things... C code: a = b + c + d + e; MIPS code: add a, b, c add a, a, d add a, a, e Eg.1. a = b + c; d = a – e ; Show the MIPS code produced by the compiler Eg.2. f = (g + h) - ( i + j); Operands must be registers, only 32 registers provided Each register contains 32 bits. Design Principle: smaller is faster. Why?

Registers MIPS convention is to use two character names following a dollar sign to represent a register. Temporary registers $t0 thru $t7 correspond to registers 8-15 Registers for holding variables $s0 thru $s7 correspond to registers 16-23 Constant 0 $zero used for the constant 0 Also corresponds to register 0 It is the compiler’s job to associate program variables with registers. Eg. F =(g + h) – (i +j ); the variables f,g,h,I,j are assigned to the registers $s0,$s1,$s2,$s3,$s4 respectively. What is the complied MIPS code?

Registers vs. Memory Arithmetic instructions operands MUST be registers, — only 32 registers provided Compiler associates variables with registers What about programs with lots of variables Processor I/O Control Datapath Memory Input Output

Memory Organization Viewed as a large, single-dimension array, with an address. A memory address is an index into the array Assume that A is an array of 100 words, the compiler has associated the variables g and h with the registers $s1 and $s2 as before. The base address of the array is in $s3. Compile the C assignment statement g = h + A[8]; The data transfer instruction that copies data from memory to a register is called “load”. "Byte addressing" means that the index points to a byte of memory. 8 bits of data 1 8 bits of data 2 8 bits of data 3 8 bits of data 4 8 bits of data 5 8 bits of data 6 8 bits of data ...

Instructions Load and store instructions Example: C code: A[12] = h + A[8]; MIPS code: lw $t0, 32($s3) add $t0, $s2, $t0 sw $t0, 48($s3) Remember arithmetic operands are registers, not memory! Can’t write: add 48($s3), $s2, 32($s3)

Constants Small constants are used quite frequently (50% of operands) e.g., A = A + 5; B = B + 1; C = C - 18; Solutions? Why not? put 'typical constants' in memory and load them. create hard-wired registers (like $zero) for constants like zero. MIPS Instructions: addi $s3, $s3, 4 # $s3 = $s3 + 4 Design Principle: Make the common case fast. Constant operands occur frequently, and by including constants inside arithmetic instructions, they are much faster than if constants were loaded from memory.

Machine Language Board work: Binary Numbers Instructions, like registers, are also 32 bits long Example: add $t1, $s1, $s2 registers have numbers, $t1=9, $s1=17, $s2=18 Instruction Format: R-type (Register format) 000000 10001 10010 01000 00000 100000 op rs rt rd shamt funct Can you guess what the field names stand for? Board work: Binary Numbers

Machine Language Consider the load-word and store-word instructions, What would the regularity principle have us do? A conflict between the desire to keep all instructions the same length and the desire to have a single instruction format. New principle: Good design demands a compromise Introduce a new type of instruction format I-type for data transfer instructions other format was R-type for register Example: lw $t0, 32($s2) 35 18 9 32 op rs rt 16 bit number Although multiple formats complicate the hardware, we can reduce the complexity by keeping the formats similar. Formats are distinguished by the values in the first field.

Translating MIPS Assembly Level Language into machine language Eg. If $t1 has the base of the array A and $s2 corresponds to h, Compile into MIPS code. What is the machine language code for these instructions corresponding to the assignment statement A[300] = h + A[300];

Logical Operations Shift left logical(sll) and shift right logical(srl) Example Sll $t2, $s0, 4 # $t2 = $s0 << 4 bits R-format Shifting left corresponds to what arithmetic operation? Shifting right corresponds to what arithmetic operation? 16 10 4

Logical Operations AND and $t0, $t2, $t1 # $t0 = $t2 AND $t1 OR or $t0, $t2, $t1 # $t0 = $t2 OR $t1 NOT Implemented with NOR with one operand 0 (why?) nor $t0, $t2, 0 # $t0 = NOT ($t2) Also have immediate versions andi $t0, $t1, 0 ori $t0, $t1, 0

Control Decision making instructions alter the control flow, i.e., change the "next" instruction to be executed MIPS conditional branch instructions: bne $t0, $t1, Label beq $t0, $t1, Label Example: if (i==j) h = i + j; bne $s0, $s1, Label add $s3, $s0, $s1 Label: ....

Control MIPS unconditional branch instructions: j label Example: if (i!=j) beq $s4, $s5, L1 h=i+j; add $s3, $s4, $s5 else j L2 h=i-j; L1: sub $s3, $s4, $s5 L2: ...

So far: 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 bne $s4,$s5,L Next instr. is at Label if $s4 ≠ $s5 beq $s4,$s5,L Next instr. is at Label if $s4 = $s5 j Label Next instr. is at Label Formats: R I J op rs rt rd shamt funct op rs rt 16 bit address op 26 bit address