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

Similar documents
Instructions: Language of the Computer

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

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

CS3350B Computer Architecture

Chapter 2. Instruction Set. RISC vs. CISC Instruction set. The University of Adelaide, School of Computer Science 18 September 2017

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

Chapter 2A Instructions: Language of the Computer

MIPS Instruction Set Architecture (1)

ECE232: Hardware Organization and Design

Chapter 1. Computer Abstractions and Technology

CSEE 3827: Fundamentals of Computer Systems

CS3350B Computer Architecture MIPS Introduction

Computer Organization and Structure. Bing-Yu Chen National Taiwan University

Architecture I. Computer Systems Laboratory Sungkyunkwan University

COMPUTER ORGANIZATION AND DESIGN

EN164: Design of Computing Systems Lecture 09: Processor / ISA 2

ECE260: Fundamentals of Computer Engineering

Computer Architecture. Lecture 2 : Instructions

ECE 154A Introduction to. Fall 2012

Chapter 2. Instructions: Language of the Computer

CS3350B Computer Architecture MIPS Instruction Representation

ECE232: Hardware Organization and Design

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

Computer Organization and Structure. Bing-Yu Chen National Taiwan University

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

Rechnerstrukturen. Chapter 2. Instructions: Language of the Computer

MIPS Memory Access Instructions

Computer Architecture

Instructions: Language of the Computer

Math 230 Assembly Programming (AKA Computer Organization) Spring 2008

Chapter 2. Baback Izadi Division of Engineering Programs

LECTURE 2: INSTRUCTIONS

Course Administration

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

CSCI 402: Computer Architectures

Computer Architecture Computer Science & Engineering. Chapter 2. Instructions: Language of the Computer BK TP.HCM

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

Chapter 2. Instructions: Language of the Computer. Jiang Jiang

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

Computer Organization MIPS ISA

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

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

Mark Redekopp, All rights reserved. EE 352 Unit 3 MIPS ISA

Unsigned Binary Integers

Unsigned Binary Integers

IC220 SlideSet #2: Instructions (Chapter 2)

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

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

Chapter 2. Instructions: Language of the Computer

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

Thomas Polzer Institut für Technische Informatik

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

Chapter 2. Instructions: Language of the Computer

Chapter 2: Instructions:

CISC 662 Graduate Computer Architecture. Lecture 4 - ISA

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

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

Computer Systems Laboratory Sungkyunkwan University

Lecture #6 Intro MIPS; Load & Store

ECE 486/586. Computer Architecture. Lecture # 7

Operations, Operands, and Instructions

Instruction Set Architecture of. MIPS Processor. MIPS Processor. MIPS Registers (continued) MIPS Registers

Chapter 2. Instructions: Language of the Computer

A Processor. Kevin Walsh CS 3410, Spring 2010 Computer Science Cornell University. See: P&H Chapter , 4.1-3

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

COMPUTER ORGANIZATION AND DESIGN. 5 th Edition. The Hardware/Software Interface. Chapter 2. Instructions: Language of the Computer

ISA and RISCV. CASS 2018 Lavanya Ramapantulu

Chapter 2. Instruction Set. The MIPS Instruction Set. Arithmetic Operations. Instructions: Language of the Computer

COMPUTER ORGANIZATION AND DESIGN. 5 th Edition. The Hardware/Software Interface. Chapter 2. Instructions: Language of the Computer

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

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

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

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

CENG3420 Lecture 03 Review

Character Is a byte quantity (00~FF or 0~255) ASCII (American Standard Code for Information Interchange) Page 91, Fig. 2.21

A Processor! Hakim Weatherspoon CS 3410, Spring 2010 Computer Science Cornell University. See: P&H Chapter , 4.1-3

Chapter 2. Instructions: Language of the Computer

Instruction Set. The MIPS Instruction Set. Chapter 2

Chapter 2. Instructions: Language of the Computer

Chapter 2. Instructions: Language of the Computer. Baback Izadi ECE Department

Instruction Set Architecture part 1 (Introduction) Mehran Rezaei

The Processor: Instruction-Level Parallelism

EE 109 Unit 13 MIPS Instruction Set. Instruction Set Architecture (ISA) Components of an ISA INSTRUCTION SET OVERVIEW

EE 109 Unit 8 MIPS Instruction Set

Anne Bracy CS 3410 Computer Science Cornell University. [K. Bala, A. Bracy, E. Sirer, and H. Weatherspoon]

MIPS Instruction Set Architecture (2)

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

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

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

Instructions: Language of the Computer. Euiseong Seo Computer Systems Laboratory Sungkyunkwan University

Reduced Instruction Set Computer (RISC)

Instruction encoding. MIPS Instruction encoding

CS 430 Computer Architecture. C/Assembler Arithmetic and Memory Access William J. Taffe. David Patterson

CS222: MIPS Instruction Set

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

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

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

Computer Architecture. MIPS Instruction Set Architecture

EC 413 Computer Organization

CS 61c: Great Ideas in Computer Architecture

Transcription:

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

Chapter Summary Stored-program concept Assembly language Number representation Instruction representation Supporting procedures in hardware MIPS addressing Some real-world stuff Fallacies and Pitfalls Chapter 2 Instructions: Language of the Computer 2

Stored-Program Concept Program instructions are stored in the memory. Every cycle, an instruction is read from the memory (fetched). The instruction is examined to decide what to do (decode) Then we perform the operation stated in the instruction (execute) Fetch-Decode-Execute cycle. Chapter 2 Instructions: Language of the Computer 5

Instruction Set The repertoire of instructions of a computer Different computers have different instruction sets But with many aspects in common Early computers had very simple instruction sets Simplified implementation Many modern computers also have simple instruction sets RISC vs. CISC 2.1 Introduction Chapter 2 Instructions: Language of the Computer 6

The MIPS Instruction Set Used as the example throughout the book Stanford MIPS commercialized by MIPS Technologies (www.mips.com) Large share of embedded core market Applications in consumer electronics, network/storage equipment, cameras, printers, Typical of many modern ISAs See MIPS Reference Data tear-out card, and Appendixes B and E Chapter 2 Instructions: Language of the Computer 7

The Four Design Principles 1. Simplicity favors regularity. 2. Smaller is faster. 3. Make the common case fast. 4. Good design demands good compromises Chapter 2 Instructions: Language of the Computer 8

Arithmetic Operations Add and subtract, three operands Two sources and one destination add a, b, c # a gets b + c All arithmetic operations have this form Design Principle 1: Simplicity favors regularity Regularity makes implementation simpler Simplicity enables higher performance at lower cost 2.2 Operations of the Computer Hardware Chapter 2 Instructions: Language of the Computer 9

Arithmetic Example C code: f = (g + h) - (i + j); Compiled MIPS code: (almost, this is not really assembly) add t0, g, h # temp t0 = g + h add t1, i, j # temp t1 = i + j sub f, t0, t1 # f = t0 - t1 Chapter 2 Instructions: Language of the Computer 10

Register Operands Arithmetic instructions use register operands MIPS has a 32 32-bit register file Use for frequently accessed data Numbered 0 to 31 32-bit data called a word Assembler names $t0, $t1,, $t9 for temporary values $s0, $s1,, $s7 for saved variables Design Principle 2: Smaller is faster c.f. main memory: millions of locations 2.3 Operands of the Computer Hardware Chapter 2 Instructions: Language of the Computer 11

Chapter 2 Instructions: Language of the Computer 12

Register Operand Example C code: f = (g + h) - (i + j); f,, j in $s0,, $s4 Compiled MIPS code: ( This is a real assembly) add $t0, $s1, $s2 add $t1, $s3, $s4 sub $s0, $t0, $t1 Chapter 2 Instructions: Language of the Computer 13

Memory Operands Main memory used for composite data Arrays, structures, dynamic data To apply arithmetic operations Load values from memory into registers Store result from register to memory Memory is byte addressed Each address identifies an 8-bit byte Words are aligned in memory Address must be a multiple of 4 MIPS is Big Endian (The commercial MIPS, not really, but in this course) Most-significant byte at least address of a word c.f. Little Endian: least-significant byte at least address Chapter 2 Instructions: Language of the Computer 14

Memory Access Another way to put it Big Endian: leftmost byte is word address Little Endian: rightmost byte is word address little endian Bytes address LSB MSB 0 1 2 3 big endian MSB LSB Alignment restriction: requires that objects fall on address that is multiple of their size Aligned Not Aligned 0 1 2 3 Chapter 2 Instructions: Language of the Computer 15

Big-Endian Little-Endian "Little-Endian" by R. S. Shaw - Own work. Licensed under Public Domain via Commons - https://commons.wikimedia.org/wiki/file:little- Endian.svg#/media/File:Little-Endian.svg Chapter 2 Instructions: Language of the Computer 16

Loading and Storing Bytes MIPS provides special instructions to move bytes lb sb $t0, 1($s3) #load byte from memory $t0, 6($s3) #store byte to memory What 8 bits get loaded and stored? load byte places the byte from memory in the rightmost 8 bits of the destination register what happens to the other bits in the register? store byte takes the byte from the rightmost 8 bits of a register and writes it to the byte in memory leaving the other bytes in the memory word unchanged Chapter 2 Instructions: Language of the Computer 17

Example Given the following code sequence and memory state what is the state of the memory after executing the code? 24 20 16 12 8 4 0 add lb sb Memory 0x 0 0 0 0 0 0 0 0 0x 0 0 0 0 0 0 0 0 0x 0 0 0 0 0 0 0 0 0x 1 0 0 0 0 0 1 0 0x 0 1 0 0 0 4 0 2 0x F F F F F F F F 0x 0 0 9 0 1 2 A 0 Data $s3, $zero, $zero $t0, 1($s3) $t0, 6($s3) What value is left in $t0? 24 20 16 12 8 4 0 $t0 = 0x00000090 What word is changed in Memory and to what? mem(4) = 0xFFFF90FF What if the machine was little Endian? $t0 = 0x00000012 mem(4) = 0xFF12FFFF Chapter 2 Instructions: Language of the Computer 18

Example Byte address $3 0x10001000 0xF2 0x10001002 $12 lbu $12, 2($3) Chapter 2 Instructions: Language of the Computer 19

Example Byte address $3 0x10001000 0xF2 0x10001002 $12 lb $12, 2($3) Chapter 2 Instructions: Language of the Computer 20

Example Byte address $3 0x10001000 $11 $12 0xA011C1D1?? 0x10001002 sb $12, 2($3) Chapter 2 Instructions: Language of the Computer 21

Byte/Halfword Operations Could use bitwise operations MIPS byte/halfword load/store String processing is a common case lb rt, offset(rs) lh rt, offset(rs) Sign extend to 32 bits in rt lbu rt, offset(rs) lhu rt, offset(rs) Zero extend to 32 bits in rt sb rt, offset(rs) sh rt, offset(rs) Store just rightmost byte/halfword Chapter 2 Instructions: Language of the Computer 22

Memory Operand Example 1 C code: g = h + A[8]; g in $s1, h in $s2, base address of A in $s3 Compiled MIPS code: Index 8 requires offset of 32 4 bytes per word lw $t0, 32($s3) # load word add $s1, $s2, $t0 offset base register Chapter 2 Instructions: Language of the Computer 23

Memory Operand Example 2 C code: A[12] = h + A[8]; h in $s2, base address of A in $s3 Compiled MIPS code: Index 8 requires offset of 32 lw $t0, 32($s3) # load word add $t0, $s2, $t0 sw $t0, 48($s3) # store word Chapter 2 Instructions: Language of the Computer 24

Registers vs. Memory Registers are faster to access than memory Operating on memory data requires loads and stores More instructions to be executed Compiler must use registers for variables as much as possible Only spill to memory for less frequently used variables Register optimization is important! Chapter 2 Instructions: Language of the Computer 25

Immediate Operands Constant data specified in an instruction addi $s3, $s3, 4 No subtract immediate instruction Just use a negative constant addi $s2, $s1, -1 Design Principle 3: Make the common case fast Small constants are common Immediate operand avoids a load instruction Chapter 2 Instructions: Language of the Computer 26

The Constant Zero MIPS register 0 ($zero) is the constant 0 Cannot be overwritten Useful for common operations E.g., move between registers add $t2, $s1, $zero Chapter 2 Instructions: Language of the Computer 27