Instruction Set Architectures. CS301 Prof. Szajda

Similar documents
CENG3420 Lecture 03 Review

Instructions: Language of the Computer

Lecture 4: Instruction Set Architecture

Review of instruction set architectures

Computer Organization MIPS ISA

Run time environment of a MIPS program

Chapter 2A Instructions: Language of the Computer

Instruction Set Architecture. "Speaking with the computer"

Computer Architecture

CS3350B Computer Architecture MIPS Instruction Representation

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

MIPS Memory Access Instructions

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

Computer Organization CS 206 T Lec# 2: Instruction Sets

Math 230 Assembly Programming (AKA Computer Organization) Spring 2008

CS 61C: Great Ideas in Computer Architecture Intro to Assembly Language, MIPS Intro

CSE Introduction to Computer Architecture. Jeff Brown

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

MIPS PROJECT INSTRUCTION SET and FORMAT

CISC 662 Graduate Computer Architecture. Lecture 4 - ISA

Lecture 2. Instructions: Language of the Computer (Chapter 2 of the textbook)

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

Course Administration

EITF20: Computer Architecture Part2.1.1: Instruction Set Architecture

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

EC 413 Computer Organization

CS 61C: Great Ideas in Computer Architecture Intro to Assembly Language, MIPS Intro

I ve been getting this a lot lately So, what are you teaching this term? Computer Organization. Do you mean, like keeping your computer in place?

CS3350B Computer Architecture MIPS Introduction

5/17/2012. Recap from Last Time. CSE 2021: Computer Organization. The RISC Philosophy. Levels of Programming. Stored Program Computers

Recap from Last Time. CSE 2021: Computer Organization. Levels of Programming. The RISC Philosophy 5/19/2011

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

CS 61c: Great Ideas in Computer Architecture

Review 1/2 MIPS assembly language instructions mapped to numbers in 3 formats. CS61C Negative Numbers and Logical Operations R I J.

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

ISA and RISCV. CASS 2018 Lavanya Ramapantulu

Instruction Set Architecture (ISA)

EE108B Lecture 2 MIPS Assembly Language I. Christos Kozyrakis Stanford University

CS61C : Machine Structures

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

Chapter 2: Instructions:

EITF20: Computer Architecture Part2.1.1: Instruction Set Architecture

COMP MIPS instructions 2 Feb. 8, f = g + h i;

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

ECE232: Hardware Organization and Design

CS352H: Computer Systems Architecture

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

Computer Architecture. The Language of the Machine

Arithmetic for Computers

Instruction Sets: Characteristics and Functions Addressing Modes

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

CSCE 5610: Computer Architecture

CHAPTER 5 A Closer Look at Instruction Set Architectures

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

Chapter 2: Instructions How we talk to the computer

CENG3420 L03: Instruction Set Architecture

CS222: Dr. A. Sahu. Indian Institute of Technology Guwahati

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

Review: What is a Computer?

Instruction Set Principles and Examples. Appendix B

Lecture 3: The Instruction Set Architecture (cont.)

Lecture 3: The Instruction Set Architecture (cont.)

Levels of Programming. Registers

CS61C - Machine Structures. Lecture 6 - Instruction Representation. September 15, 2000 David Patterson.

ECE 154A Introduction to. Fall 2012

Computer Hardware Generations

Lecture 7: Examples, MARS, Arithmetic

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

Number Systems and Their Representations

COMP2121: Microprocessors and Interfacing. Instruction Set Architecture (ISA)

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

CS3350B Computer Architecture

Groups of two-state devices are used to represent data in a computer. In general, we say the states are either: high/low, on/off, 1/0,...

Systems Architecture I

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

CISC 360. Computer Architecture. Seth Morecraft Course Web Site:

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

Slide Set 5. for ENCM 369 Winter 2014 Lecture Section 01. Steve Norman, PhD, PEng

Reduced Instruction Set Computer (RISC)

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

101 Assembly. ENGR 3410 Computer Architecture Mark L. Chang Fall 2009

COS 140: Foundations of Computer Science

ECE232: Hardware Organization and Design

CS61C Machine Structures. Lecture 8 - Introduction to the MIPS Processor and Assembly Language. 9/14/2007 John Wawrzynek

MIPS R-format Instructions. Representing Instructions. Hexadecimal. R-format Example. MIPS I-format Example. MIPS I-format Instructions

Instructions: Language of the Computer

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

Lecture 4: Instruction Set Design/Pipelining

ECE 486/586. Computer Architecture. Lecture # 7

UCB CS61C : Machine Structures

Instruction Set Architecture

MIPS Instruction Set

What is Computer Architecture? CSE Introduction to Computer Architecture. Why do I care? Which is faster? Allan Snavely

Assembly Programming

Instruction Set Architectures

CSEE 3827: Fundamentals of Computer Systems

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

Rui Wang, Assistant professor Dept. of Information and Communication Tongji University.

RISC, CISC, and ISA Variations

Lecture 4: MIPS Instruction Set

Transcription:

Instruction Set Architectures CS301 Prof. Szajda

Instruction Categories Arithmetic w x = x + 1 Memory w mem[addr] = x; Control w for(int i = 0; i < 10 ; i++)

Arguments to Arithmetic Operations Constant: x = x + 1 w Immediate addressing Data appears in constant part of instruction Data stored in register w Register direct or register addressing Data is in register specified in instruction Data stored in memory: mem[addr] = x w Direct addressing Explicitly state address in instruction w Register indirect Register holds address of data in memor

Memory Aside: Memory Hierarchy Registers w Small, fast to access, right next to circuitry that performs calculation w Few in number w Expensive! Both in circuitry and real-estate! Memory (logical and physical) w Larger, slower, further away than registers 4

Memory Aside: Data Each program has memory associated with it where data 0x7fffffff is stored That data is just like an array 0x7ff3fa8bc of memory cells w Smallest addressable component is a byte w Each cell is addressable by its byte location argc is 4B 0x0 Memory

Memory Aside: Data Each program has memory associated with it where data 0x7fffffff is stored That data is just like an array of memory cells w Smallest addressable component is a byte w Each cell is addressable by its byte location 0x5ffffd420 8 char string 0x0 Memory

Memory Aside: Instructions Each program has memory associated with it where data 0x7fffffff is stored That data is just like an array of memory cells w Smallest addressable component is a byte w Each cell is addressable by its byte location Instructions are also allocated space in memory 4 byte instr. 0xf5fd780 0x0 Memory

Stored Program Concept Very important: effectively allows the development of general purpose computer Treat instructions the same way as data Simplifies memory hardware and the software of computers Ex. Memory can contain source code for editing app, corresponding machine code, text program is using, and compiler that generated machine code! 8

Instruction Set Architecture (ISA) Specifies the instructions that the architecture understands Represents the interface between HW and SW Classified by number of addresses included in instructions Differentiated by how registers / memory used to specify data

Different Addressing Architectures 0 address architecture: Stack w Push operands onto stack w Operations automatically take operands from top of stack (pop) w Push result on to stack

Different Addressing Architectures Accumulator w Special register where results stored w accum = accum op addr 1 addr n w Advantage: don t have to specify as many addresses in instructions 1 address architecture w Assume one operand is in accumulator w Other address is specified w accum = accum op addr 1

Different Addressing Architectures 3 address architecture: MIPS w 2 inputs to operation w 1 output from operation w add addr 1, addr 2, addr 3 // addr 1 = addr 2 +addr 3 Nothing is implicit!

Addresses are Registers or Memory? Accumulator Architecture w 1 register for arithmetic (the accumulator) w 1 operand for memory w add addr // acc = acc + mem[addr] Accumulator both source and destination Dedicated Register Architecture w More registers w Each register with dedicated purpose Stack pointer w w Array index Has both accumulator-like instructions and MIPS-like instructions Multiply/div accumulator separate from other accumulators General Purpose Register Architecture w All registers used for any purpose w Two Kinds: Register-memory: one operand in memory Load-store: all operands in registers

From Source Code to Machine Language High Level Language Program Compiler temp = v[k]; v[k] = v[k+1]; v[k+1] = temp; ISA Assembly Language Program Assembler Machine Language Program Machine Interpretation lw $15, 0($2) lw $16, 4($2) sw $16, 0($2) sw $15, 4($2) 1000110001100010000000000000000 1000110011110010000000000000100 1010110011110010000000000000000 1010110001100010000000000000100 Hardware ALUOP[0:3] <= InstReg[9:11] & MASK

Classifying Instruction Types CISC: Complex Instruction Set Computer w Create instructions for specific operations Square root w Create composite instructions Load then add then store w Allow both memory and register addressing w Allow multiple operands in each instruction w Variable instruction length w Examples: VAX, Motorola 68K, Intel x86 RISC: Reduced Instruction Set Computer w Include small number of basic instructions Load, store, add, subtract w Small number of operands permitted to instructions w Fixed instruction length w Examples: MIPS, PowerPC, SPARC, HP PA-RISC

Classifying Instruction Types CISC: w Make hardware like software to make compilation easier w Also optimize program size RISC: w VERY much easier to decode instructions Simple instructions have implications for program performance w Benefit of RISC is really when it comes to hardware 16

CISC Example Pentium 4: Note instruction length is variable!

RISC Example I-type: used by immediate and data transfer functions R-type: used for register functions

Storing Numbers

Unsigned Numbers In general, value of i th digit d is d Base i w 1011 2 = 11 10 31 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 most significant bit least significant bit 32b allows you to represent 2 32 different 32b patterns w 0 to 2 32-1 (4,294,967,295) 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

Sign and Magnitude Single bit used to represent positive or negative Problems: w Which bit for sign? First? Last? w 2 representations for zero w Adders may need additional cycle to figure out sign

Signed Numbers: Two s Complement Used in today s computers Use leading bit to represent positive or negative w 0: positive w 1: negative Positive numbers have same representation but have one less bit to use w 32b: 0 to 2 31-1 (2,147,483,647) Negative numbers w 32b: -1 to -2 31 (-2,147,483,648) -1: 32 1s -2 31 : 1(31 0s)

Signed Numbers: Two s Complement Converting from two s complement to decimal (x 31-2 31 )+ (x 30 2 30 )+... +(x 1 2 1 )+ (x 0 2 0 ) where x i means the i th bit of x Convert between decimal and two s complement w 1(27 1s)1100

Converting from Positive to Negative Value 6 is represented in 8b as 0 0 0 0 0 1 1 0 Value -6 is represented in 8b as 1 1 1 1 1 0 1 0 Technique: w Invert every bit w Add one Works to convert negative to positive too!

Examples What is the 2 s complement representation of (assume 8b) w -3 w -62 What is the decimal value for these 2 s complement numbers? w 10010011 w 11110100

Nifty Benefits of Two s Complement Addition of negative number works correctly w Add 7 to -5 + 0 1 1 1 1 0 1 1 0 0 1 0 w Add 2 to -5 + 0 0 1 0 1 0 1 1 1 1 0 1

Overflow When can adding/subtracting two numbers result in overflow? w Addition: (carry into sign bit) Positive + Positive = Negative 4b values: 0111 + 0111 = 1110 Negative + Negative = Positive 4b values: 1001 + 1001 = 0010 w Subtraction: (borrow from sign bit) Positive - Negative = Negative 4b values: 0100-1001 =?? Negative - Positive = Positive 4b values: 1001-0110 = 0011 (This is -7-6, which should be -13, i.e., 10011)

Overflow w/ Unsigned Numbers Unsigned integers generally used for memory addresses Want to ignore overflow Two types of add/sub instructions w add/addi/sub - overflow causes exception w addu/addiu/subu - overflow does not cause exception

Comparisons Need to distinguish between signed and unsigned numbers for comparison slt / slti - assumes numbers are signed sltu / sltiu - assumes numbers are unsigned

Sign Extension Converting from smaller number of bits to larger number of bits w Immediate fields are 16b but registers are 32b Convert 16b to 32b w Copy most significant bit 16 times and prepend w 0000 0000 0000 0010 0000 0000 0000 0000 0000 0000 0000 0010 Positive #s have infinite number of preceding 0s w 1111 1111 1111 1110 1111 1111 1111 1111 1111 1111 1111 1110 Negative #s have infinite number of preceding 1s