Chapter 2 Instruction: Language of the Computer

Similar documents
ECE232: Hardware Organization and Design

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

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

ECE232: Hardware Organization and Design

Typical Processor Execution Cycle

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

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

Instruction Set Architecture. "Speaking with the computer"

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

Chapter 3. Instructions:

Instruction Set Design

Lecture 4: Instruction Set Architecture

Instructions: Language of the Computer

Chapter 2. Instructions:

Instruction Set Architectures

Instruction Set Principles and Examples. Appendix B

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

Chapter 2A Instructions: Language of the Computer

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

IC220 SlideSet #2: Instructions (Chapter 2)

Review of instruction set architectures

Computer Organization MIPS ISA

MIPS Instruction Set Architecture (1)

Math 230 Assembly Programming (AKA Computer Organization) Spring 2008

MIPS Memory Access Instructions

Chapter 2: Instructions How we talk to the computer

ADD R Operation : ACC = ACC + R SIZE : 1 byte, 8 bit Time : 3 T Cycle Work : Read R, Read ACC, Add, Write Result to ACC

Lecture 3: Instruction Set Architecture

COSC 6385 Computer Architecture. Instruction Set Architectures

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

ECE 486/586. Computer Architecture. Lecture # 6

Instruction Set Design and Architecture

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

RISC, CISC, and ISA Variations

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

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

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

COMP3211/COMP9211 Computer Architecture. Lecturer: Sri Parameswaran LiC: Oliver Diessel Demonstrators: Liang Tang & George Gong

CS3350B Computer Architecture MIPS Instruction Representation

Hakim Weatherspoon CS 3410 Computer Science Cornell University

Computer Model. What s in a computer? Processor Memory I/O devices (keyboard, mouse, LCD, video camera, speaker, disk, CD drive, )

EITF20: Computer Architecture Part2.1.1: Instruction Set Architecture

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

Instruction Set Architectures. Part 1

CPU Architecture and Instruction Sets Chapter 1

Computer Architecture

INSTITUTO SUPERIOR TÉCNICO. Architectures for Embedded Computing

COMPSCI 313 S Computer Organization. 7 MIPS Instruction Set

EITF20: Computer Architecture Part2.1.1: Instruction Set Architecture

Chapter 2: Instructions:

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

Review: What is a Computer?

Hardware Level Organization

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

CENG3420 L03: Instruction Set Architecture

EECS Computer Organization Fall Based on slides by the author and prof. Mary Jane Irwin of PSU.

software hardware Which is easier to change/design???

The MIPS Instruction Set Architecture

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

Lecture 3: The Instruction Set Architecture (cont.)

Lecture 3: The Instruction Set Architecture (cont.)

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

מבנה מחשבים Amar Lior Based on lectures notes from Arie Schlesinger

Instruction Set Architecture (ISA)

Course Administration

ECE331: Hardware Organization and Design

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

CSCI 402: Computer Architectures

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

CS4617 Computer Architecture

CS222: MIPS Instruction Set

CENG3420 Lecture 03 Review

Architecture I. Computer Systems Laboratory Sungkyunkwan University

Computer Architecture. MIPS Instruction Set Architecture

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

EC 413 Computer Organization

ECE 486/586. Computer Architecture. Lecture # 7

Instructions: Language of the Computer

CSEE 3827: Fundamentals of Computer Systems

ISA and RISCV. CASS 2018 Lavanya Ramapantulu

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

378: Machine Organization and Assembly Language

ECE 154A Introduction to. Fall 2012

Instruction Set Principles. (Appendix B)

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

Instruction Sets Ch 9-10

Instruction Sets Ch 9-10

CPS 104 Computer Organization and Programming

CA226 Advanced Computer Architecture

CHAPTER 5 A Closer Look at Instruction Set Architectures

ECE260: Fundamentals of Computer Engineering

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

Computer Architectures

EEC 581 Computer Architecture Lecture 1 Review MIPS

ECE369. Chapter 2 ECE369

Instruction Set Architecture

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

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

Topic Notes: MIPS Instruction Set Architecture

Instruction Set Architectures. CS301 Prof. Szajda

Transcription:

Chapter 2 Instruction: Language of the Computer 1 Table of Contents Ch.1 Introduction Ch. 2 Instruction: Machine Language Ch. 3-4 CPU Implementation Ch. 5 Cache and VM Ch. 6-7 I/O & Multiprocessors Computer User interface keyboard/ mouse screen/ speaker CPU Programmer interface instruction set Software interface (ch.2) ALU, Mux, Memory, Sequential circuit,... CPU designer interface component spec. connection spec. Hardware interface (ch.3-5) Textbook subtitle 2

Table of Contents Ch.1 Introduction Ch. 2 Instructions: Language of the Computer 2.1 Introduction 2.2 Operations (arithmetic, memory operations) 2.3 Operands 2.4 Signed and unsigned numbers 2.5 Representing instructions 2.6 Logical operations 2.7 Control flow operations 2.8 Supporting procedures 2.9 Comm. with people (ASCII) 2.10 MIPS addressing 2.11 Synchronization 2.12 Starting a program, Compiler 2.13 Example 2.14-21 Etc. Ch. 3 CPU Implementation: Arithmetic Ch. 4 CPU Implementation: Pipeline Ch. 5 Cache and Virtual Memory Ch. 6-7 I/O and Multiprocessors 3 Instructions: Language of the Machine More primitive than higher level languages e.g., no sophisticated control flow Very restrictive e.g., MIPS Arithmetic Instructions We ll be working with the MIPS instruction set architecture similar to other architectures developed since the 1980's used by NEC, Nintendo, Silicon Graphics, Sony (NEC MobileGear, Nitendo64, Sony Playstation, Aibo, STB, Routers, Printers, Fax machines,...) Design goals: maximize performance and minimize cost, reduce design time 4

MIPS arithmetic All instructions have 3 operands Operand order is fixed (destination first) Example: C code: A = B + C MIPS code: add $s0, $s1, $s2 (associated with variables by compiler) 5 MIPS arithmetic Design Principle: simplicity favors regularity. Why? Of course this complicates some things... C code: A = B + C + D; E = F - A; MIPS code: add $t0, $s1, $s2 add $s0, $t0, $s3 sub $s4, $s5, $s0 Operands must be registers, only 32 registers provided Design Principle: smaller is faster. Why? 6

MIPS arithmetic How about memory operand? For example my_account = my_account + deposit_amount; Data Data is stored in memory Each variable has its address Memory address content variable 160 149000 my_account... Translate to MIPS code [160] = [160] + [200]; 200 100 deposit_amount But, MIPS does not allow memory operands in the arithmetic operation 7 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 Compiler tries to keep the most frequently used variables in registers and places the rest in memory (spilling registers) Compiler uses load/store to move variables between registers and memory Control Input Memory Datapath Output Processor I/O 8

General Purpose Registers Dominate 1975-1995 all machines use general purpose registers Advantages of registers registers are faster than memory registers are easier for a compiler to use - e.g., (A*B) (C*D) (E*F) can do multiplies in any order vs. stack registers can hold variables - memory traffic is reduced, so program is sped up (since registers are faster than memory) - code density improves (since register named with fewer bits than memory location) 9 Memory Organization Viewed as a large, single-dimension array, with an address. A memory address is an index into the array "Byte addressing" means that the index points to a byte of memory. (Since 1980, almost every machine uses addresses to level of 8 bits.) 0 1 2 3 4 5 6... 10

Memory Organization For referring a data item, we usually use word because a byte is too small to represent data. For MIPS, a word is 32 bits or 4 bytes. 0 4 8 12... 32 bits of data 32 bits of data 32 bits of data 32 bits of data Registers hold 32 bits of data If MIPS has 10-bit address pin How many bytes are addressable? How many words are addressable? What is the address range? 2 32 bytes with byte addresses from 0 to 2 32-1 2 30 words with byte addresses 0, 4, 8,... 2 32-4 11 Memory Addressing 2 questions for design of ISA: Since we could read a 32-bit word as four loads of bytes from sequential byte addresses or as one load word from a single byte address, => how do byte addresses map onto words? Can a word be placed on any byte boundary? E.g., -A byte can hold a value of upto 255 (2^8-1) -A word can hold a value of upto 2^32-1 -[160] = 149000 = 2 46 08 (hexa) => 00 02 46 08 (4 bytes or a word) (So, the next address is 164 ) -[160]w = 00 02 46 08 Memory address content 160 149000=00024608 -[160]b=00, [161]b=02, [162]b=46, [163]=08??? => Big endian -[160]b=08, [161]b=46, [162]b=02, [163]=00??? => Little endian 00 02 46 08 08 46 02 00 OR 12

Addressing Objects: Endianess and Alignment Big Endian: address of most significant byte = word address IBM 360/370, Motorola 68k, MIPS, Sparc, HP PA Little Endian:address of least significant byte = word address Intel 80x86, DEC Vax, DEC Alpha (Windows NT) msb 3 2 1 0 little endian byte 0 lsb 0 1 2 3 big endian byte 0 0 1 2 3 Alignment: require that objects fall on address that is multiple of their size e.g., [161]w incurs CPU error Aligned Not Aligned 13 Endian-ness Internetworking with TCP/IP Vol.I, Douglas Comer, 4 th Edition, 2002 Ch.4 Classful Internet Address Section 4.17 Network Byte Order, pp. 74-75 14

Data Transfer (Memory) Instructions Load and store instructions The only instructions to access memory Example: address Memory variable C code: A = B + C $s4 B MIPS code: lw $s0, ($s3) lw $s1, ($s4) lw $s2, ($s5) add $s0, $s1, $s2 $s3 $s5 $s3 : the data itself = 160 ($s3) : data in memory addressed by $s3 = 00024608 A C Store word has destination last 15 Data Transfer (Memory) Instructions Load and store instructions with indexed addressing Example: Memory C code: MIPS code: lw $s2, h lw $s3, A Right??? (h and A) A[8] = h + A[8]; lw $t0, 32($s3) add $t0, $s2, $t0 sw $t0, 32($s3) why not A,A+1,A+2, A+3,? $s3 A A+4 A+8 A+12 A+16 A+20 A+24 A+28 A+32 A+36 16

Basic ISA Classes Stack (0 register): 0 address add # tos tos + next Accumulator (1 register): 1 address add A # acc acc + mem[a] 1+x address addx A # acc acc + mem[a + x] General Purpose Register: 2 address add A B # EA(A) EA(A) + EA(B) 3 address add A B C # EA(A) EA(B) + EA(C) Load/Store: 3 address add Ra Rb Rc # Ra Rb + Rc load Ra Rb # Ra mem[rb] store Ra Rb # mem[rb] Ra 17 Comparison of ISA Classes Bytes per instruction? Number of Instructions? Cycles per instruction? Comparing Number of Instructions Code sequence for C = A + B for four classes of instruction sets: Stack Accumulator Register Register (register-memory) (load-store) Push A Load A Load R1,A Load R1,A Push B Add B Add R1,B Load R2,B Add Store C Store C, R1 Add R3,R1,R2 Pop C Store C,R3 18

So far we ve learned: MIPS loading words but addressing bytes arithmetic on registers only 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 19