Lecture 4: Instruction Set Architecture

Similar documents
Instruction Set Principles and Examples. Appendix B

55:132/22C:160, HPCA Spring 2011

CS4617 Computer Architecture

Page 1. Structure of von Nuemann machine. Instruction Set - the type of Instructions

Instruction Set Architecture (ISA)

Instruction Set Architectures

EC 413 Computer Organization

EITF20: Computer Architecture Part2.1.1: Instruction Set Architecture

EC-801 Advanced Computer Architecture

ISA and RISCV. CASS 2018 Lavanya Ramapantulu

Instruction Set Architecture. "Speaking with the computer"

Instruction Set Principles. (Appendix B)

Review of instruction set architectures

CSCE 5610: Computer Architecture

CENG3420 Lecture 03 Review

Lecture 4: MIPS Instruction Set

CS3350B Computer Architecture MIPS Instruction Representation

Lecture 4: Instruction Set Design/Pipelining

Reminder: tutorials start next week!

Instructions: Language of the Computer

CSEE 3827: Fundamentals of Computer Systems

COSC 6385 Computer Architecture. Instruction Set Architectures

ECE 486/586. Computer Architecture. Lecture # 7

Chapter 2A Instructions: Language of the Computer

Computer Architecture

INSTITUTO SUPERIOR TÉCNICO. Architectures for Embedded Computing

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

EITF20: Computer Architecture Part2.1.1: Instruction Set Architecture

Math 230 Assembly Programming (AKA Computer Organization) Spring 2008

ISA: The Hardware Software Interface

Computer Organization MIPS ISA

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

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

Instruction Set Design

Instruction Set. Instruction Sets Ch Instruction Representation. Machine Instruction. Instruction Set Design (5) Operation types

CHAPTER 2: INSTRUCTION SET PRINCIPLES. Prepared by Mdm Rohaya binti Abu Hassan

Reduced Instruction Set Computer (RISC)

Chapter 2. Instruction Set Design. Computer Architectures. software. hardware. Which is easier to change/design??? Tien-Fu Chen

Instruction Sets Ch 9-10

Instruction Sets Ch 9-10

Typical Processor Execution Cycle

Lecture 3: Instruction Set Architecture

Instruction Set Architecture

CMSC Computer Architecture Lecture 2: ISA. Prof. Yanjing Li Department of Computer Science University of Chicago

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

Instruction Sets: Characteristics and Functions

Slides for Lecture 6

Course Administration

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

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

CS3350B Computer Architecture

Chapter 2: Instructions How we talk to the computer

CS 4200/5200 Computer Architecture I

CPU Architecture and Instruction Sets Chapter 1

Lecture 4: Review of MIPS. Instruction formats, impl. of control and datapath, pipelined impl.

Lecture 5: Instruction Set Architectures II. Take QUIZ 2 before 11:59pm today over Chapter 1 Quiz 1: 100% - 29; 80% - 25; 60% - 17; 40% - 3

17. Instruction Sets: Characteristics and Functions

Chapter 2 Instruction: Language of the Computer

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

Evolution of ISAs. Instruction set architectures have changed over computer generations with changes in the

Lecture 3: The Instruction Set Architecture (cont.)

Lecture 3: The Instruction Set Architecture (cont.)

Computer Architecture. MIPS Instruction Set Architecture

CS/ECE/752 Chapter 2 Instruction Sets Instructor: Prof. Wood

Systems Architecture I

Reduced Instruction Set Computer (RISC)

CSIS1120A. 10. Instruction Set & Addressing Mode. CSIS1120A 10. Instruction Set & Addressing Mode 1

Virtual Machines and Dynamic Translation: Implementing ISAs in Software

The MIPS Instruction Set Architecture

Chapter 2. Instruction Set Principles and Examples. In-Cheol Park Dept. of EE, KAIST

Unsigned Binary Integers

Unsigned Binary Integers

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

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

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

MIPS Memory Access Instructions

Computer Systems Architecture I. CSE 560M Lecture 3 Prof. Patrick Crowley

Prof. Hakim Weatherspoon CS 3410, Spring 2015 Computer Science Cornell University. See P&H Appendix , and 2.21

CENG3420 L03: Instruction Set Architecture

Instructions: Language of the Computer

Graduate Computer Architecture. Chapter 2. Instruction Set Principles

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

Instruction Set Architecture

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

Computer Architecture. The Language of the Machine

RISC, CISC, and ISA Variations

Computer Systems Laboratory Sungkyunkwan University

CS3350B Computer Architecture MIPS Introduction

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

ECE232: Hardware Organization and Design

Hakim Weatherspoon CS 3410 Computer Science Cornell University

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

MIPS Instruction Set Architecture (1)

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

ECE 486/586. Computer Architecture. Lecture # 8

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)

COMPUTER ORGANIZATION & ARCHITECTURE

CA226 Advanced Computer Architecture

CISC 662 Graduate Computer Architecture. Lecture 4 - ISA

Transcription:

Lecture 4: Instruction Set Architecture ISA types, register usage, memory addressing, endian and alignment, quantitative evaluation Reading: Textbook (5 th edition) Appendix A Appendix B (4 th edition) 1 What Is ISA? Instruction set architecture is the structure of a computer that a machine language programmer (or a compiler) must understand to write a correct (timing independent) program for that machine. For IBM System/360, 1964 ISA types: Stack, Accumulator, and General-purpose register ISA is mature and stable Why do we study it? 2 1

MIPS: A "Typical" RISC ISA 32-bit fixed format instruction (3 formats) 32 32-bit GPR (R0 contains zero, DP takes pair) 3-address, reg-reg arithmetic instruction Single address mode for load/store: base + displacement no indirection Simple branch conditions Delayed branch 3 Example: MIPS Assembly Code ; C code: ; c = (a <= b)? (a - b) : (b - a); ; a -- MEM(4), b -- MEM(8), c -- MEM(12) ; R8 -- a, R9 -- b, R10 -- tmp, R11 -- c lw $8, 4($0) ; load a to reg 8 lw $9, 8($0) ; load b to reg 9 slt $10, $9, $8 ; set reg 10 if b < a beq $10, $0, +2 ; no, skip next two sub $11, $9, $8 ; c=b-a beq $0, $0, +1 ; skip next sub $11, $8, $9 ; c=a-b sw $9, 12($0) ; store c 4 2

MIPS Instruction Format (32-bit) Register-Register 31 26 25 21 20 16 15 11 10 6 5 0 Op 31 26 25 21 20 16 15 0 Op Op Rs1 Register-Immediate Branch Op Rs2 Rd Rs1 Rd immediate 31 26 25 0 target Opx 31 26 25 21 20 16 15 0 Jump / Call Rs1 Rs2 immediate 5 Example: MIPS Binary Code 100011_00000_01000_0000000000000100 // lw $8, 4($0) 100011_00000_01001_0000000000001000 // lw $9, 8($0) 000000_01001_01000_01010_00000_101010 // slt $10, $9, $8 000100_01010_00000_0000000000000010 // beq $10, $0, +2 000000_01001_01000_01011_00000_100010 // sub $11, $9, $8 000100_00000_00000_0000000000000001 // beq $0, $0, +1 000000_01000_01001_01011_00000_100010 // sub $11, $8, $9 101011_00000_01011_0000000000001100 // sw $9, 12($0) 6 3

Stack ISA Implicit operands on stack Ex. C = A + B Push A Push B Add Pop C Good code density; used in 60 s-70 s; now in Java VM 7 Accumulator ISA The accumulator provides an implicit input, and is the implicit place to store the result. Ex. C = A + B Load A Add B Store C Used before 1980 8 4

General-purpose Registers General-purpose registers are preferred by compilers Reduce memory traffic Improve program speed Improve code density Usage of general-purpose registers Holding temporal variables in expression evaluation Passing parameters Holding variables GPR and RISC and CISC RISC ISA is extensively used for desktop, server, and embedded: MIPS, PowerPC, UltraSPARC, ARM, MIPS16, Thumb CISC: IBM 360/370, VAX, and Intel 80x86 9 Variants of GPR Architecture Number of operands in ALU instructions: two or three Add R1, R2, R3 Add R1, R2 Maximal number of memory operands in ALU instructions: zero, one, two, or three Load R1, A Load R1, A Load R2, B Add R3, R1, B Add R3, R1, R2 Three popular combinations register-register (load-store): 0 memory, 3 operands register-memory: 1 memory, 2 operands memory-memory: 2 memories, 2 operands; or 3 memories, 3 operands 10 5

Register-Memory Architecture There is no implicit operand One input operand is register, and one in memory Ex. C = A + B Load R1, A Add R3, R1, B Store R3, C Processors include VAX, 80x86 11 Register-Register (Load-Store) Both operands are registers Values in memory must be loaded into a register and stored back Ex. C = A + B Load R1, A Load R2, B Add R3, R1, R2 Store R3, C Processors: MIPS, SPARC 12 6

How Many Registers? If the number of registers increases: Allocate more variables in registers (fast accesses) Reducing spill code Reducing memory traffic Longer register specifiers (difficult encoding) Increasing register access time (physical registers) More registers to save in context switch MIPS64: 32 general-purpose registers 13 ISA and Performance CPU time = #inst CPI cycle time RISC with Register-Register instructions Simple, fixed-length instruction encoding Simple code generation Regularity in CPI Higher instruction counts Lower instruction density CISC with Register-memory instructions No extra load to accessing memory operands Easy encoding (?) Operands not equivalent Restricted #registers due to memory address encoding Irregularity in CPI 14 7

Memory Addressing Instructions see registers, constant values, and memory Addressing mode decides how to specify an object to access Object can be memory location, register, or a constant Memory addressing is complicated Memory addressing involves many factors Memory addressing mode Object size byte ordering alignment For a memory location, its effective address is calculated in a certain form of register content, immediate address, and PC, as specified by the addressing mode 15 Little or Big: Where to Start? Byte ordering: Where is the first byte? Big-endian:IBM, SPARC, Mororola Little-endian: Intel, DEC Supporting both: MIPS, PowerPC 00000003 00000002 00000001 00000000 Number 0x5678 Little-endian 5 6 7 8 Big-endian 8 7 6 5 16 8

Alignment Align n-byte objects on n-byte boundaries (n = 1, 2, 4, 8) One aligned position, n-1 misaligned positions Misaligned access is undesirable Expensive logic, slow references Aligning in registers may be necessary for bytes and half words 17 MIPS Data Addressing Modes Register ADD $16, $7, $8 Immediate ADDI $17, $7, 100 Displacement LW $18, 100($9) Only these three are supported for data addressing 18 9

Storage Used by Compilers Register storage Holding temporary variables in expression evaluation Passing parameters Holding variables Memory storages consists of Stack: to hold local variables Global data area: to hold statically declared objects Heap: to hold dynamic objects 19 Memory Addressing Seen in CISC Direct (absolute) Register indirect Indexed Scaled Autoincrement Autodecrement Memory indirect And more ADD R1, (1001) SUB R2, (R1) ADD R1, (R2 + R3) SUB R2, 100(R2)[R3] ADD R1, (R2)+ SUB R2, -(R1) ADD R1, @(R3) (see textbook p-a9) 20 10

Choosing Memory Addressing Modes Choosing complex addressing modes Close to addressing in high-level language May reduce instruction count (thus fast) Increase implementation complexity (may increase cycle time) Increase CPI RISC ISA comes with simple memory addressing, and CISC ISA with complex ones 21 Frequency of Addressing Modes? Usage of address modes, VAX machine, SPEC89 22 11

Usage of Immediate Operands In RISC Alpha, SPEC CINT2000 & CFP2000 23 Immediate Size in RISC Alpha, SPEC CINT2000 & CFP2000; <6% are ve; 50-70% 24 fit in 8 bits; 75-80% in 16 bits 12

Displacement Size in RISC Displacement bit size: Alpha ISA, SPEC CPU2000 Integer and FP; most +ve; majority of large 14+ bits are ve; about 1% of 25 displacements need more than 16 bits. Operands size, type and format In MIPS Opcode encodes operand size Ex. ADD for signed integer, ADDU for unsigned integer, ADD.D for double-precision FP Most common types include Integer: complement binary numbers Character: ASCII Floating point: IEEE standard 754, single-precision or double-precision Decimal format 4-bits for one decimal digit (0-9), one byte for two decimal digits Necessary for business applications Fixed Point format in DSP processors: Representing fractions in (-1, +1) 11000101 fixed point = -0.1000101 2 26 13

Dynamic Instruction Mix (MIPS) SPEC2K Int SPEC2K FP Load 26% 15% Store 10% 2% Add 19% 23% Compare 5% 2% Cond br 12% 4% Cond mv 2% 0% Jump 1% 0% LOGIC 18% 4% FP load 15% FP store 7% FP others 19% 27 Compiler Effects Architectures change for the needs of compilers How do compilers use registers? How many? How do compilers use addressing modes? Anything that compilers do not like? 28 14