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

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

Supplement for MIPS (Section 4.14 of the textbook)

Computer Organization CS 206 T Lec# 2: Instruction Sets

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

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

Reminder: tutorials start next week!

ISA: The Hardware Software Interface

Grundlagen Microcontroller Processor Core. Günther Gridling Bettina Weiss

ECE 486/586. Computer Architecture. Lecture # 7

Lecture 4: Instruction Set Architecture

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

Instruction Set Architecture. "Speaking with the computer"

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

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

EC-801 Advanced Computer Architecture

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

ISA and RISCV. CASS 2018 Lavanya Ramapantulu

Lecture 4: RISC Computers

COMPUTER ORGANIZATION & ARCHITECTURE

Instruction Sets: Characteristics and Functions Addressing Modes

Lecture 4: Instruction Set Design/Pipelining

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

CSCE 5610: Computer Architecture

Chapter 2: Instructions How we talk to the computer

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

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

EC 413 Computer Organization

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

Chapter 2A Instructions: Language of the Computer

CENG3420 Lecture 03 Review

MIPS ISA. 1. Data and Address Size 8-, 16-, 32-, 64-bit 2. Which instructions does the processor support

Lecture 4: MIPS Instruction Set

ECE 486/586. Computer Architecture. Lecture # 8

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

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

Real instruction set architectures. Part 2: a representative sample

Lecture 4: RISC Computers

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

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

Instruction Set Architecture (ISA)

CISC 662 Graduate Computer Architecture. Lecture 4 - ISA

Mark Redekopp, All rights reserved. EE 357 Unit 11 MIPS ISA

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

Control Instructions

Computer Architecture

William Stallings Computer Organization and Architecture 8 th Edition. Chapter 11 Instruction Sets: Addressing Modes and Formats

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

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

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

REDUCED INSTRUCTION SET COMPUTERS (RISC)

Module 3 Instruction Set Architecture (ISA)

Control Hazards - branching causes problems since the pipeline can be filled with the wrong instructions.

Computer Systems Laboratory Sungkyunkwan University

RISC Principles. Introduction

COMP 303 Computer Architecture Lecture 3. Comp 303 Computer Architecture

SPRING TERM BM 310E MICROPROCESSORS LABORATORY PRELIMINARY STUDY

Review of instruction set architectures

The Instruction Set. Chapter 5

These actions may use different parts of the CPU. Pipelining is when the parts run simultaneously on different instructions.

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

Computer Architecture Homework #1 Due: September 7, 2007 (F) (4 PM in ITT 305 mailbox or under my office door, ITT 313)

Instruction Set Architecture

Instruction Set. Instruction Sets Ch Instruction Representation. Machine Instruction. Instruction Set Design (5) Operation types

Systems Architecture I

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

Lectures 3-4: MIPS instructions

Processor Architecture. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

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

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

Computer Architecture. The Language of the Machine

EE 361 University of Hawaii Fall

Thomas Polzer Institut für Technische Informatik

COMPSCI 313 S Computer Organization. 7 MIPS Instruction Set

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

Reduced Instruction Set Computer (RISC)

Unsigned Binary Integers

Unsigned Binary Integers

CSC 2400: Computer Systems. Towards the Hardware: Machine-Level Representation of Programs

Instruction Sets Ch 9-10

Instruction Sets Ch 9-10

Topic Notes: MIPS Instruction Set Architecture

Outline. What Makes a Good ISA? Programmability. Implementability

COSC 6385 Computer Architecture. Instruction Set Architectures

Processor Architecture

Pipelining, Branch Prediction, Trends

MIPS Assembly Programming

Basic Assembly Instructions

Chapter 13 Reduced Instruction Set Computers

Instruction Set Architectures

CSE A215 Assembly Language Programming for Engineers

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

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

Computer Organization MIPS ISA

Code Generation. Lecture 30

COE608: Computer Organization and Architecture

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

Computer Architecture

ECE232: Hardware Organization and Design. Computer Organization - Previously covered

COMPUTER ORGANIZATION AND DESIGN

Preventing Stalls: 1

Transcription:

Instruction-set Design Issues: what is the format(s) Opcode Dest. Operand Source Operand 1... 1) Which instructions to include: How many? Complexity - simple ADD R1, R2, R3 complex e.g., VAX MATCHC substrlength, substr, strlength, str looks for a substring within a string 2) Which built-in data types: integer, floating point, character, etc. 3) Instruction format: Length (fixed, variable) number of address (2, 3, etc) field sizes 4) Number of registers 5) Addressing modes supported - how are the memory addresses of variables/data determining Lecture 2-1

Number of Operands 3 Address MOVE (X b Y) ADD (X b Y + Z) SUB (X b Y - Z) MUL (X b Y * Z) DIV (X b Y / Z) 2 Address MOVE (X b Y) ADD (X b X + Y) ADD (X b X - Y) MUL (X b X * Y) DIV (X b X / Y) 1 Address (Accumulator machine) LOAD M STORE M ADD M SUB M MUL M DIV M 0 Address (Stack machine) PUSH M POP M ADD SUB MUL DIV D = A + B * C (Postorder Traversal: A B C * + ) 3 Address MUL D, B, C ADD D, D, A 2 Address MOVE D, B MUL D, C ADD D, A 1 Address (Accumulator machine) LOAD B MUL C ADD A STORE D 0 Address (Stack machine) PUSH A PUSH B PUSH C MUL ADD POP D Load/Store Architecture - operands for arithmetic operations must be from/to registers LOAD R1, B LOAD R2, C MUL R3, R1, R2 LOAD R4, A ADD R3, R4, R3 STORE R3, D Lecture 2-2

Flow of Control How do we "jump around" in the code to execute high-level language statements such as if-then-else, while-loops, for-loops, etc. Two Paths Possible TRUE Execute then-body Jump over else-body always after then-body if (x < y) then FALSE Jump over // code of then-body then-body else if x >= y Execute // code of else-body else-body end if Conditional branch - used to jump to "else" if x >= y Unconditional branch - used to always jump "end if" Labels are used to name spots in the code (memory) ("if:", "else:", and "end_if:" in below example) Test-and-Jump version of the if-then-else (Used in MIPS) if: bge x, y, else... j end_if else:... end_if: Lecture 2-3

Set-Then-Jump version of the if-then-else (Used in Pentium) if: cmp x, y jge else... j end_if else:... end_if: The "cmp" instruction performs x - y with the result used to set the condition codes SF - (Sign Flag, n) set if result is < 0 ZF - (Zero Flag, z) set if result = 0 CF - (Carry Flag, c) set if unsigned overflow OF - (Overflow Flag, v) set if signed overflow For example, the "jge" instruction checks to see if ZF = 1 or SF = 1, i.e., if the result of x - y is zero or negative. Lecture 2-4

Machine-Language Representation of Branch/Jump Instructions (How are labels (e.g., end_if ) in the code located???) a) direct/absolute addressing - the memory address of where the label resides is put into the machine language instruction (EA, effective address = direct) e.g., assume label "end_if" is at address 8000 16 end_if: j end_if Opcode 8000. How relocatable is the code in memory if direct addressing is used? How many bits are needed to represent a direct address? b) Relative/PC-relative - base-register addressing where the PC is the implicitly referenced register while: bge R8, R9, end_while PC = 4000 Opcode 8 9 40. "end_while" label 40 addresses from "bge" b while end_while: PC = 4040 Opcode -40 Unconditional pc-relative branches are possible too Lecture 2-5

Machine-Language Representation of Variables/Operands (How are labels (e.g., sum, score, etc.) in the code located???) a) Register - operand is contained in a register add r9, r4, r2 Opcode 9 4 2 b) Direct/absolute addressing - the memory address of where the label resides is put into the machine language instruction (EA, effective address = direct) e.g., assume label "sum" is at address 8000 16 and score is at address 8004 add sum, sum, score Opcode 8000 8000 8004. 32 bits 32 bits 32 bits.. c) Immediate - part of the contains the value addi r9, #2 Opcode 9 2 d) Register Indirect - operand is pointed at by an address in a register addri r9, (r4), r2 Opcode 9 4 2 Register File r4 4000 4000 Memory EA = (r4) Lecture 2-6

e) Base-register addressing / Displacement - operand is pointed at by an address in a register plus offset Load r9, 40(r2) Memory Opcode 9 40 2 Register File 4040 EA = (r2) + 40 r2 4000 4000+40 Often the reference register is the stack pointer register to manipulate the run-time stack, or a global pointer to a block of global variables. A Program's Address Space Heap Stack Data Global Program Area Unused 5 3 0 (X) (Y) (SUM) Load R3, Y Load R2, X Add R1,R2,R3 Store R1, SUM Stack Pointer Register, $29/$sp Global Pointer Register, $28/$gp Program Counter, pc Lecture 2-7

f) Indexing - contains a memory address and a register containing an index addindex r9, A(r2) Opcode 9 8000 2 Reg. File Opcode 9 8000 2 r2 10 EA = A + (r2) 8000 8010 Useful for array access. Lecture 2-8

Reduced Instruction Set Computers (RISC) Two approaches to instruction set design: 1) CISC (Complex Instruction Set Computer) e.g., VAX 1960 s: Make assembly language (AL) as much like high-level language (HLL) as possible to reduce the semantic gap between AL and HLL Alleged Reasons: reduce compiler complexity and aid assembly language programming - compilers not too good at the time (e.g., they did not allocate registers very efficiently) reduce the code size - (memory limited at this time) improve code efficiency - complex sequence of instructions implemented in microcode (e.g., VAX MATCHC substrlength, substr, strlength, str that looks for a substring within a string) Characteristics of CISC: high-level like s variable format and number of cycles many addressing modes (VAX 22 addressing modes) Problems with CISC: complex hardware needed to implement more and complex instructions which slows the execution of simpler instructions compiler can rarely figure out when to use complex instructions (verified by studies of programs) variability in instruction format and instruction execution time made CISC hard to pipeline 2) RISC (1980 s) Addresses these problems to improve speed. Lecture 2-9

RISC Instruction-Set Architecture (ISA) can be effectively pipelined Instruction pipelining through the CPU speeds up program execution like an assembly-line speeds up manufacturing of a car. A car assembly line might split up building a car into four stages: Chassis Motor Interior Exterior Assume that the whole car assembly process takes 4 hours. If you divide the process into four equal stages of an hour each, then ideally we can complete a car every hour. Problems occur if the stages are not equally balanced for all cars. The main RISC philosophy (mid-80 s and after) is to design the assembly language (AL) to optimize the instruction pipeline to speed program execution. Table 13.1 - characteristics of some CISC and RISC processors Lecture 2-10

The architectural characteristics of RISC machines include: one instruction completion per clock cycle. (This means that each pipeline stage needs fit in one clock cycle) large number of registers with register-to-register operations (e.g., ADD R2, R3, R4, where R2 gets the results of R3 + R4). Register operands are already in the CPU so they are fast to access. simple addressing modes because complex address calculations might take longer that one clock cycle simple, fixed-length instruction formats. Fixed-length instructions require a fixed amount of time to fetch. Simple instruction formats can be decoded in a clock cycle. MIPS instruction formats are all 32-bits, and are as follows Arithmetic: add R1, R2, R3 opcode opcode dest reg operand operand 1 reg 2 reg unused Unconditional Branch/"jump": j somelabel large offset from PC or absolute address Arithmetic with immediate: addi R1, R2, 8 opcode opcode opcode operand operand 1 reg 2 reg Conditional Branch: beq R1, R2, end_if operand operand 1 reg 2 reg Load/Store: lw R1, 16(R2) operand reg base reg immediate value PC-relative offset to label offset from base reg hardwired control unit. The simple instructions can be performed using hardwired control unit that allows for a fast clock cycle Lecture 2-11