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

Similar documents
ECE 486/586. Computer Architecture. Lecture # 8

Chapter 2. lw $s1,100($s2) $s1 = Memory[$s2+100] sw $s1,100($s2) Memory[$s2+100] = $s1

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

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

Instruction Set Architectures

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

ECE 486/586. Computer Architecture. Lecture # 7

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

Instruction Set Architecture. "Speaking with the computer"

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

Computer Architecture. Chapter 2-2. Instructions: Language of the Computer

Communicating with People (2.8)

EEC 581 Computer Architecture Lecture 1 Review MIPS

Computer Systems Laboratory Sungkyunkwan University

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

Systems Architecture I

Review of instruction set architectures

History of the Intel 80x86

Lecture 3: The Instruction Set Architecture (cont.)

Lecture 3: The Instruction Set Architecture (cont.)

Chapter 2A Instructions: Language of the Computer

Chapter 2. Instruction Set Architecture (ISA)

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

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

COE608: Computer Organization and Architecture

CENG3420 Lecture 03 Review

Procedure Calling. Procedure Calling. Register Usage. 25 September CSE2021 Computer Organization

Lecture 3: Instruction Set Architecture

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

Computer Architecture

CS/COE1541: Introduction to Computer Architecture

LECTURE 2: INSTRUCTIONS

Reminder: tutorials start next week!

CISC 662 Graduate Computer Architecture. Lecture 4 - ISA

CS3350B Computer Architecture MIPS Instruction Representation

CS222: MIPS Instruction Set

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

Instruction Set Principles. (Appendix B)

Instruction Set Architecture (ISA)

COMPSCI 313 S Computer Organization. 7 MIPS Instruction Set

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

2.7 Supporting Procedures in hardware. Why procedures or functions? Procedure calls

ISA and RISCV. CASS 2018 Lavanya Ramapantulu

MIPS (SPIM) Assembler Syntax


CS3350B Computer Architecture MIPS Procedures and Compilation

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

EN2910A: Advanced Computer Architecture Topic 02: Review of classical concepts

EC 413 Computer Organization

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

Computer Organization MIPS ISA

CS31001 COMPUTER ORGANIZATION AND ARCHITECTURE. Debdeep Mukhopadhyay, CSE, IIT Kharagpur. Instructions and Addressing

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

CS3350B Computer Architecture

CSCE 5610: Computer Architecture

Lecture 4: Instruction Set Architecture

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

CS3350B Computer Architecture MIPS Introduction

comp 180 Lecture 10 Outline of Lecture Procedure calls Saving and restoring registers Summary of MIPS instructions

Real instruction set architectures. Part 2: a representative sample

Thomas Polzer Institut für Technische Informatik

Unsigned Binary Integers

Unsigned Binary Integers

Lecture 4: Instruction Set Design/Pipelining

Computer Architecture

Course Administration

Instructions: Language of the Computer

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

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

Lecture 4: MIPS Instruction Set

CO Computer Architecture and Programming Languages CAPL. Lecture 13 & 14

EJEMPLOS DE ARQUITECTURAS

Programmable Machines

Programmable Machines

EC-801 Advanced Computer Architecture

Rechnerstrukturen. Chapter 2. Instructions: Language of the Computer

CSEE 3827: Fundamentals of Computer Systems

Topic Notes: MIPS Instruction Set Architecture

Chapter 2. Instructions: Language of the Computer

Processor Architecture

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

Computer Architecture. MIPS Instruction Set Architecture

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

ISA: The Hardware Software Interface

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

Chapter 2. Baback Izadi Division of Engineering Programs

Instruction Set Design and Architecture

MIPS%Assembly% E155%

Chapter 2. Computer Abstractions and Technology. Lesson 4: MIPS (cont )

EE 361 University of Hawaii Fall

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

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

Control Instructions. Computer Organization Architectures for Embedded Computing. Thursday, 26 September Summary

Control Instructions

MIPS ISA-II: Procedure Calls & Program Assembly

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

Instruction Set Design

EN164: Design of Computing Systems Topic 03: Instruction Set Architecture Design

Course Administration

Two processors sharing an area of memory. P1 writes, then P2 reads Data race if P1 and P2 don t synchronize. Result depends of order of accesses

Transcription:

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 Topics Appendix A: Sections A.6, A.9 and A.10 Branch Conditions Conditional branchesare said to be taken based upon a comparison or condition Next instruction to be executed is the target If condition or comparison is not met, branch is said to be not taken Next instruction executed is instruction following the branch instruction in the program PC + <length of branch instruction in bytes> Branch Condition Options Condition Codes Special bits set as a consequence of ALU operations Z last result was zero V last result had over/under flow C last result had a carry N last result was negative Condition Register (MIPS) Simple Uses register(s) BEQZ R1, Target # Branch to Target if R1 == 0 BEQ R1, R2, Target # Branch to Target if R1 == R2 Compare and Branch (VAX) BGEQ R1, R2, Target # Branch to target if R1 >= R2

Conditional Branch Instructions Condition is result of comparing two registers bne, beq if(i == j) => bne r17, r18, Target h = i + j; add r19, r17, r18 Target: Conditional Branch Instructions Target address is PC-relative Exploits spatial locality ½ of branches in SPEC2000 < 16 instructions away Saves bits of encoding (store offset, not absolute address) Facilitates position independent code Provides range of +2 15-1 to -2 15 instructions from PC I op rs rt Immediate op 10001 10010 0000000000000010 Unconditional Branch Instructions Jump instruction j, jr, jal if(i == j) => bne r17, r18, L1 h = i + j; add r19, r17, r18 else j L2 h = i j; L1: sub r19, r17, r18 L2: Target address is pseudo-direct Value is in words Concatenate with PC[31:28] and 00 Target must be in same 256 MB space as PC Return from Procedure Set return value Restore state At least register containing PC for return address Any saved registers Transfer control to caller MIPS implementation JR Jump Register JR R31 PC R31

Summary: MIPS Control Flow Instructions Constants Small constants are used frequently (50% of operands) e.g., A = A + 5 B = B -1 Design Principle: Make the common case fast Solution: immediate addressing mode addi r18, r18, 4 andi r19, r20, 11 slti r21, r20, 4 But immediate field in an I-type instruction is only 16-bits wide How to deal with larger constants (which need > 16 bits)? Dealing with Larger Constants We d like to be able to load a 32 bit constant into a register For example, load register r5 with a 32-bit sequence of alternating 1s and 0s (101010.10) Must use two instructions New load upper immediate (lui) instruction lui r5, 1010101010101010 1010101010101010 0000000000000000 Then must get the lower order bits right ori r5, r5, 1010101010101010 1010101010101010 0000000000000000 ori 0000000000000000 1010101010101010 Filled with zeroes Alternative ISAs Design Alternative Provide more powerful instructions Goal is to reduce number of instructions executed Danger is a slower clock cycle time and/or higher CPI Example: Lets look briefly at IA-32 1010101010101010 1010101010101010

IA-32 History 1978: Intel 8086 is announced (16-bit architecture) 1980: 8087 floating point coprocessor is added 1982: 80286 increases address space to 24 bits 1985: 80386 extends address space to 32 bits, new addressing modes 1989 1995: 80486, Pentium, Pentium Pro add a few more instructions 1997: 57 new MMX instructions added to Pentium-II 1999: Pentium-III added another 70 instructions (SSE) 2001: Another 144 instructions (SSE2) 2004: Address space extended to 64 bits 2004: More multimedia extensions (SSE3) IA-32 History This history illustrates the impact of the golden handcuffs of compatibility Adding new features as someone might add clothing to a packed bag What the 80x86 lacks in style is made up in quantity, making it beautiful from the right perspective IA-32 Overview IA-32 Registers Complexity Instructions from 1 to 17 bytes long One operand must act as both a source and destination One operand can come from memory Complex addressing modes E.g., base or scaled index with 8 or 32 bit displacement Saving grace Most frequently used instructions are not too difficult to build Compilers often avoid the portions of the ISA that are too slow

IA-32 Typical Instructions IA-32 Instruction Formats Four major types of integer instructions Data movement (move, push, pop) Arithmetic and logical (destination can be either register or memory) Control flow (use of condition code CC flags) String instructions (such as string move and string compare) ISA Summary Instruction set complexity affects the instruction count vs. CPI/clock rate tradeoff RISC: higher instruction count but easier to decode and pipeline (higher clock rate, lower CPI) CISC: lower instruction count but higher CPI Fallacy There is such a thing as a typical program Problems with the above argument: Wide variations of instruction frequencies, addressing modes, operand types etc. exist between applications, even belonging to the same class Design principles Simplicity favors regularity Smaller is faster Make the common case fast

Fallacy An architecture with flaws cannot be successful Counter-example: Intel x86 (IA32) Several unpopular architectural decisions over the years Segmentation vs. paging Extended accumulators vs. GPRs Stack for floating point operations Very complex ISA But enormously successful, because Chosen by IBM for first PC Moore s law provided resources to build an internal RISC-like core High volume permits higher R&D costs needed to support complexity Fallacy You can design a flawless architecture Why not? Technologies change with time; tradeoffs thought to be correct at one time may look like mistakes with technology evolution Example: VAX (1975) Emphasized the importance of code size efficiency Used compact but complex instructions to reduce code size Didn t anticipate the future importance (five years later of) On-chip caches Pipelining Pitfall Innovating at the ISA level to reduce code size without accounting for the compiler Architects struggle to reduce code size (30% --40% code size reduction considered a major achievement at ISA level) Different compiler strategies can change code size by much larger factors (2x) Pitfall Designing a high-level instruction set feature specifically oriented to supporting a high-level language structure Example: VAX CALLS instruction Too general for the most frequent case, resulting in unneeded work and a slower instruction Conclusion: Architect should start with the tightest code the compiler can produce before propose ISA innovations to save space