Chapter 2: Instructions How we talk to the computer

Similar documents
Instruction Set Architectures. Part 1

Instruction Set Architecture. "Speaking with the computer"

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

Typical Processor Execution Cycle

Lecture 4: Instruction Set Design/Pipelining

Instruction Set Principles and Examples. Appendix B

Lecture 4: Instruction Set Architecture

Outline. What Makes a Good ISA? Programmability. Implementability

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

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

Lecture 4: RISC Computers

Outline. What Makes a Good ISA? Programmability. Implementability. Programmability Easy to express programs efficiently?

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

Introduction to Computers & Programming

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

William Stallings Computer Organization and Architecture. Chapter 11 CPU Structure and Function

RISC, CISC, and ISA Variations

CS4617 Computer Architecture

CHAPTER 5 A Closer Look at Instruction Set Architectures

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

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

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

INSTITUTO SUPERIOR TÉCNICO. Architectures for Embedded Computing

Instruction Set Design

Review of instruction set architectures

EITF20: Computer Architecture Part2.1.1: Instruction Set Architecture

Hakim Weatherspoon CS 3410 Computer Science Cornell University

Instruction Set Architecture (ISA)

Alternate definition: Instruction Set Architecture (ISA) What is Computer Architecture? Computer Organization. Computer structure: Von Neumann model

ISA and RISCV. CASS 2018 Lavanya Ramapantulu

UNIT- 5. Chapter 12 Processor Structure and Function

Instruction Set II. COMP 212 Computer Organization & Architecture. COMP 212 Fall Lecture 7. Instruction Set. Quiz. What is an Instruction Set?

COSC 6385 Computer Architecture. Instruction Set Architectures

Chapter 2 Instruction: Language of the Computer

Virtual Machines and Dynamic Translation: Implementing ISAs in Software

Instructions: Language of the Computer

CSE Introduction to Computer Architecture. Jeff Brown

ECE 486/586. Computer Architecture. Lecture # 7

CSCE 5610: Computer Architecture

CHAPTER 5 A Closer Look at Instruction Set Architectures

From CISC to RISC. CISC Creates the Anti CISC Revolution. RISC "Philosophy" CISC Limitations

Computer Architecture and Organization. Instruction Sets: Addressing Modes and Formats

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

EC-801 Advanced Computer Architecture

EITF20: Computer Architecture Part2.1.1: Instruction Set Architecture

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

CPU Structure and Function. Chapter 12, William Stallings Computer Organization and Architecture 7 th Edition

ECE 486/586. Computer Architecture. Lecture # 8

COMPUTER ORGANIZATION & ARCHITECTURE

Chapter 2A Instructions: Language of the Computer

RISC Principles. Introduction

Chapter 12. CPU Structure and Function. Yonsei University

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

Instruction content (2/2) Instruction content (1/2) The Instruction Set. Chapter 9. Each instruction must contain 4 basic pieces of information

General Purpose Processors

Instruction Set Architectures

Lecture 4: RISC Computers

CHAPTER 5 A Closer Look at Instruction Set Architectures

EC 413 Computer Organization

Computer Organization CS 206 T Lec# 2: Instruction Sets

INTEL Architectures GOPALAKRISHNAN IYER FALL 2009 ELEC : Computer Architecture and Design

Instruction Set Principles. (Appendix B)

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

Processing Unit CS206T

CENG3420 Lecture 03 Review

Lecture 4: ISA Tradeoffs (Continued) and Single-Cycle Microarchitectures

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

COS 140: Foundations of Computer Science

Addressing Modes. Immediate Direct Indirect Register Register Indirect Displacement (Indexed) Stack

Real instruction set architectures. Part 2: a representative sample

Overview. EE 4504 Computer Organization. Much of the computer s architecture / organization is hidden from a HLL programmer

Architectures & instruction sets R_B_T_C_. von Neumann architecture. Computer architecture taxonomy. Assembly language.

Reminder: tutorials start next week!

Instruction Set Architecture

Lecture 4: MIPS Instruction Set

What is Computer Architecture?

CS 31: Intro to Systems ISAs and Assembly. Martin Gagné Swarthmore College February 7, 2017

CPU Structure and Function

Control Hazards. Branch Prediction

Computer Architecture, RISC vs. CISC, and MIPS Processor

COMPUTER ORGANIZATION & ARCHITECTURE

Computer Architectures

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

Instruction Set Architectures. CS301 Prof. Szajda

Chapter 11. Instruction Sets: Addressing Modes and Formats. Yonsei University

CS3350B Computer Architecture MIPS Instruction Representation

Math 230 Assembly Programming (AKA Computer Organization) Spring 2008

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

Instruction Sets: Characteristics and Functions Addressing Modes

Computer Architecture

We briefly explain an instruction cycle now, before proceeding with the details of addressing modes.

EITF20: Computer Architecture Part2.2.1: Pipeline-1

CS 265. Computer Architecture. Wei Lu, Ph.D., P.Eng.

CPU Structure and Function

Interfacing Compiler and Hardware. Computer Systems Architecture. Processor Types And Instruction Sets. What Instructions Should A Processor Offer?

Processor Organization and Performance

Topics Power tends to corrupt; absolute power corrupts absolutely. Computer Organization CS Data Representation

ISA: The Hardware Software Interface

Computer Architecture

Computer Architecture is...??? CSE 240A -- Principles of Computer Architecture. Computer Architecture is...??? Computer Architecture is...???

Transcription:

Chapter 2: Instructions How we talk to the computer 1

The Instruction Set Architecture that part of the architecture that is visible to the programmer - instruction formats - opcodes (available instructions) - number and types of registers - storage access, addressing modes - exceptional conditions 2

Overall goals of ISA Can be implemented by simple hardware Can be implemented by fast hardware Instructions do useful things Easy to write (or generate) machine code i.e. good interface to compiler 3

The Instruction Execution Cycle Instruction Fetch Obtain instruction from program storage Instruction Decode Determine required actions and instruction size Operand Fetch Execute Result Store Locate and obtain operand data Compute result value or status Deposit results in storage for later use Next Instruction Determine successor instruction 4

Key ISA decisions instruction length are all instructions the same length? how many registers? where do operands reside? e.g., can you add contents of memory to a register? instruction format (encoding) operands operations which bits designate what?? how many? how big? immediates? how are memory addresses computed? what operations are provided?? 5

Running examples We ll look at four example ISA s: - Digital s VAX (1977) uber-complex ( eval polynomial ) - Intel s x86 (1978) - ugly, but ubiquitous (IBM PC) - MIPS focus of text, used in SGI/embedded machines - PowerPC used in Mac s, IBM high-end computers,... VAX and x86 are CISC ( Complex Instruction Set Computers ) MIPS and PowerPC are RISC ( Reduced Instruction Set Computers ) - almost all machines of 80 s and 90 s are RISC including VAX s successor, the DEC Alpha 6

Instruction Length Variable: x86 Instructions vary from 1 to 17 Bytes long VAX from 1 to 54 Bytes Fixed: MIPS, PowerPC, and most other RISC s: all instruction are 4 Bytes long 7

Instruction Length Variable-length instructions (x86, VAX): - require multi-step fetch and decode. - difficult to determine start of next instruction this is a bottleneck in x86 architecture -> trace cache added to P4 to address this, but abandoned in Core 2 Duo because of power + allow for a more flexible and compact instruction set. Fixed-length instructions (RISC s) + allow easy fetch and decode. + simplify pipelining and parallelism. - inefficient use of instruction bits (some things can not be encoded in one instr e.g., 32 bit immediates) Future: Post-RISC ideas -> allow limited set of variable length encodings, but ensure that the encoding allows for fast decoding + fast determination of 8 next instruction (e.g., Heads and Tails architecture by Asanovic)

How many registers? All computers have a small set of registers, stored in a register file ( RF ) RF: Small Memory to hold values that will be used soon Typical instruction will use 2 or 3 registers as input Advantages of a larger number: Fewer memory operations Easier to do several operations at once Higher Performance, as long as does not impact cycle time Advantages of a small number of registers: Less hardware Faster access (shorter wires, fewer gates) Faster context switch (when all registers need saving) Generally, these factors have become less important over time 9

How many registers? VAX 16 registers R15 is program counter (PC) Cute: Loading R15 is a jump instruction, Add is branch, etc. x86 8 general purpose regs Fine print some restrictions apply Plus floating point and special purpose registers x86-64 16 general purpose regs Most RISC s have 32 int and 32 floating point regs Plus some special purpose ones PowerPC has 8 four-bit condition registers, a count register (to hold loop index), and others. Itanium has 128 fixed, 128 float, and 64 predicate registers 10

Where do operands reside? Stack machine: Push A loads memory into 1 st register ( top of stack ), moves other regs down Pop C takes top of stack, puts in memory at C Add combines contents of first two registers, moves rest up. Accumulator machine: Only 1 register (called the accumulator ) Instructions include store A (store what s in acc into A) load A (load what s in A into acc, overwriting) add A (add what s in A to value in acc) 11

Where do operands reside? Register-Memory machine : Arithmetic instructions can use data in registers and/or memory Instructions include: Add A, B, C //Get values from memory locations B and C, add them and put into memory in A Load-Store Machine (aka Register-Register Machine): Arithmetic instructions can only use data in registers. Instructions are like you know from SPARC Load R2, A Store B, R3 Add R4, R3, R2 12

Load-store architectures can do: add r1=r2+r3 load r3, M(address) store r1, M(address) can t do: add r1=r2+m(address) forces heavy dependence on registers, which is exactly what you want in today s CPUs - more instructions + fast implementation (e.g., easy pipelining) 13

Where do operands reside? VAX: register-memory Very general. 0, 1, 2, or 3 operands can be in reg/mem x86: register-memory... But floating-point registers are a stack. Not as general as VAX instructions RISC machines: Always load-store machines Stack, Accumulator machines? 14

Comparing the Number of Instructions Code sequence for C = A + B Stack Accumulator Register-Memory Load-Store Push A Load A Add C,A,B Load R1, A Push B Add B Load R2, B Add Store C Add R3, R1, R2 Pop C Store C, R3 What else might you compare for? 15

Comparing the Number of Instructions Code sequence for A = X*Y+ X*Z Stack Accumulator Register-Memory Load-Store 16

a a a instruction length Key ISA decisions are all instructions the same length? how many registers? where do operands reside? e.g., can you add contents of memory to a register? instruction format operands operations which bits designate what?? how many? how big? how are memory addresses computed? what operations are provided?? 17

Instruction formats -what does each bit mean? Having many different instruction formats... complicates decoding uses instruction bits (to specify the format) Machine needs to determine quickly, This is a 6-byte instruction This instruction probably branches to XXX... 18