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

Size: px
Start display at page:

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

## Transcription

1 Machine Language Instructions Introduction Instructions Words of a language understood by machine Instruction set Vocabulary of the machine Current goal: to relate a high level language to instruction set of a machine Machine language vs. human language (restricted programming language) Most machines speak similar languages, or dialect of the same language Similar operations in a formal language (arithmetic, comparison) Close to like learning to drive one car mips instruction set Used by nec, Nintendo, Silicon Graphics, and Sony Designed since the early 1980s Hardware operations Arithmetic mips assembly language instruction Equivalent C statement: a = b + c; add a, b, c Too rigid in nature; to perform a = b + c + d + e; you have to do the following: add a, b, c # a = b + c add a, a, d # a = b + c + d add a, a, e # a = b + c + d + e Each line can contain only one instruction, and the instruction does not achieve much more than a primitive operation Comments terminate at the end of line Same number of operands for each instruction (three above) Keeping number of operands constant keeps hardware simple Design Principle 1 Simplicity favors regularity. Compiling a simple C program into mips assembly C Program Assembly a = b + c; add a, b, c d = a - e; sub d, a, e Compiling a slightly complex C program into mips assembly C Program Assembly f = ( g + h ) - ( i + j ) add t0, g, h add t1, i, j sub f, t0, t1 Somehow, the compiler needs to know to perform both additions before performing subtraction, and to use temporary variables

4 Machine Language Instructions 4 Registers are part of every instruction Registers \$s0 to \$s7 map onto registers 16 to 23 Registers \$t0 to \$t7 map onto registers 8 to 15 Translating a mips assembly instruction into machine language Consider the instruction add \$t0, \$s1, \$s2 Decimal representation \$s1 \$s2 \$t0 unused + Six fields, with field 0 and 5 indicating the operation to be performed, field 4 unused, and other fields indicating the registers to be used Binary representation in 32-bits bits 5 bits 5 bits 5 bits 5 bits 6 bits op rs rt rd shamt funct Layout of instruction is called instruction format All mips instructions are 32-bit long Numeric version is called machine instruction Sequence of machine instructions is called machine code mips fields Six fields are identified as op Basic operation, or opcode, described in 6 bits rs First register source operand rt Second register source operand rd Register destination shamt Shift amount, used in shift instructions funct Function; specific variant of operation in op field, also called function code Problem lw specifies two registers and a constant Limiting constant to 5 bits limits the offset to just 32; too small to be useful for accessing large arrays or structures Conflict to keep all instructions the same length and desire for a single instruction format Design Principle 3 Good design demands good compromises. mips compromise is to have the same length for all instructions but different format R-type format (register type) I-type format (data transfer instructions) op rs rt address 6 bits 5 bits 5 bits 16 bits 16-bit address allows access to an address in a range of ±2 15 from the base address (± bytes, ±2 13 or ±8192 words), base address is contained in register rs Consider the instruction: lw \$t0, 32(\$s3) # \$t0 = A[8] op rs rt address x23 0x13 0x08 0x0020

5 Machine Language Instructions 5 The rt field specifies the destination for this instruction, to receive the result of load (it was second source in R-type instruction) Complexity is reduced by keeping the instruction format similar First three fields in both R-type and I-type instructions are the same in length and name Formats are distinguished by the op field The funct field is recognized based on the bit pattern in the op field Example: Assume that base of A is in \$t1 and h corresponds to \$s2 C Program Assembly A[300] = h + A[300] lw \$t0, 1200(\$t1) # \$t0 = A[300] add \$t0, \$s2, \$t0 # \$t0 = h + A[300] sw \$t0, 1200(\$t1) # A[300] = h + A[300] Equivalent machine code is: 0x23 0x09 0x08 0x04B0 0x00 0x12 0x08 0x08 0x00 0x20 0x2B 0x09 0x08 0x04B0 For I-type instructions, base register is specified in second field (rs), destination (or source) is specified in third field (rt), and the offset in final field For R-type instructions, we need funct in sixth field, two source operands in second and third fields, and destination in fourth field The op for lw and sw differs in just one bit, with no difference in the rest of the fields Stored program concept Both instructions and data are kept in memory as bit patterns (or binary numbers) mips has 32 general purpose registers, each of length 32 bits mips can address 2 32 bytes (2 30 words) of memory Making decisions Conditional branches Decision making is implemented in a high level language by using an if statement Decision making in mips assembly language Start with two instructions beq register1, register2, label if ( register1 == register2 ) goto label bne register1, register2, label if ( register1!= register2 ) goto label Mnemonics are equivalent to branch if equal and branch if not equal, and are known as conditional branches Compiling C code into mips assembly; assume g, h, i, j, k correspond to registers \$s0 through \$s4 C Program Assembly if ( i == j ) go to L1; beq \$s2, \$s3, L1 f = g + h; add \$s0, \$s1, \$s2 L1: f = f - i; L1: sub \$s0, \$s0, \$s2 Label L1 corresponds to the address of the subtract instruction Modern programming languages almost never have any goto-statement, or discourage their use (see Compiling if-then-else into conditional branches

7 Machine Language Instructions 7 while ( save[i] == k ) i = i + j; Modified C loop LOOP: if ( save[i]!= k ) go to EXIT; i = i + j; go to LOOP; EXIT: mips assembly code # Load save[i] into temporary register LOOP: add \$t1, \$s3, \$s3 # \$t1 = 2 * i add \$t1, \$t1, \$t1 # \$t1 = 4 * i add \$t1, \$t1, \$s6 # \$t1 = save + 4 * i -- &save[i] lw \$t0, 0(\$t1) # \$t0 = save[i] EXIT: bne \$t0, \$s5, EXIT # if ( save[i]!= k ) go to EXIT add \$s3, \$s3, \$s4 # i = i + j j LOOP # go to LOOP Comparing two numbers to find out which is larger Achieved by the instruction slt, (set on less than) The instruction slt \$t0, \$s1, \$s2 sets register \$t0 to 1 if \$s1 is less than \$s2; otherwise, it is reset (or set to 0) slt is R-type instruction, and instruction such as slt \$s1, \$s2, \$s3 translates as follows: op rs rt rd shamt funct 6 bits 5 bits 5 bits 5 bits 5 bits 6 bits beq 0x00 0x12 0x13 0x17 0x00 0x2A The \$zero register Conditions mips compiler uses the register \$zero to read the result of all conditional expressions Register \$zero is mapped to register 0 Compiling a less than test The C statement if ( a < b ) go to LESS; mips assembly code slt \$t0, \$s0, \$s1 # \$t0 = ( \$s0 < \$s1 )? 1 : 0; bne \$t0, \$zero, LESS # if ( \$t0!= 0 ) go to LESS; mips isa does not have an instruction to compare and branch in a single instruction but uses two faster and simpler instructions to achieve the effect slt is an R-type instruction Case/switch statement Consider the C code

10 Machine Language Instructions 10 int foobar ( const int g, const int h, const int i, const int j ) { int f = ( g + h ) - ( i + j ); } return ( f ); In assembly language: foobar: sub \$sp, \$sp, 12 # Make room for three words sw \$t1, 8(\$sp) # Save registers \$s0, \$t0, and \$t1 sw \$t0, 4(\$sp) sw \$s0, 0(\$sp) # Variables g, h, i, j correspond to \$a0, \$a1, \$a2, \$a3 add \$t0, \$a0, \$a1 # ( g + h ) add \$t1, \$a2, \$a3 # ( i + j ) sub \$v0, \$t0, \$t1 # ( g + h ) - ( i + j ); into return value lw \$s0, 0(\$sp) # Restore registers lw \$t0, 4(\$sp) lw \$t1, 8(\$sp) add \$sp, \$sp, 12 # Adjust stack pointer jr \$ra # Return to caller Convention to reduce register spilling Saved registers (\$s0 \$s7) must be saved by the called procedure and restored before return Temporary registers (\$t0 \$t9) need not be preserved by the called procedure The convention implies that we could have reduced the saving and restoration steps for temporary registers in the above code Nested procedures Procedures that do not call other procedures are known as leaf procedures All the registers, including \$ra and temporaries may need to be preserved, using the stack Recursive procedures may make it even more tough Compiling a recursive procedure to compute factorial int fact ( const int n ) { if ( n < 1 ) return ( 1 ); } return ( n * fact ( n - 1 ) ); Parameter n is the argument or \$a0 Assembly code

14 Machine Language Instructions 14 Compiler Assembler Pseudoinstructions Object file Machine language instructions Data allocation Information to put the instructions in memory (format) Symbol table Object file format Header Size and position of other pieces of file Text segment Actual machine language code Data segment Static data Dynamic data Relocation information Instructions and data words that depend on absolute addresses Symbol table Undefined symbols such as extern variables Debugging information Associating machine instructions with source language statements Linker, or linkage editor Loader Putting together independently assembled modules Place code and data modules symbolically in memory Determine the addresses of data and instruction labels Patch both the internal and external references Executable file Read executable file header to determine the size of text and data segments Allocate memory to hold text and data Copy text (instructions) and data from executable file into memory Copy parameters for main() to stack Initialize machine registers and stack pointer Start the program Examples on swap and sort Reading assignment Arrays versus pointers

15 Machine Language Instructions 15 Refer to earlier example on strcpy function, comparing with the one in the book C compiler treats arrays as pointers #include <iostream> int main() { using namespace std; int a[] = { 1, 2, 3, 4, 5, 6, 7, 8 }; cout << "a[6] = " << a[6] << endl; cout << "6[a] = " << 6[a] << endl; } return ( 0 ); The above code works because a[i] gets translated internally to *( a + i ) PowerPC and 80x86 ISA Instruction complexity, clock speed, and number of instructions executed by a given program IBM/Motorola PowerPC Similar to mips in most respects 32 integer registers Each instruction is 32-bits long Data transfer possible only through load and store Two more addressing modes and a few operations Indexed addressing Allows two registers to be added together during instruction execution mips code add \$t0, \$a0, \$s3 # \$a0 is array base; \$s3 is index lw \$t1, 0(\$t0) # \$t1 = \$a0[\$s3] PowerPC code lw \$t1, \$a0 + \$s3 # \$t1 = \$a0[\$s3] Update addressing Look at our pointer arithmetic version of strcpy Automatically increment the base pointer mips code lw \$t0, 4(\$s3) # \$t0 = *(\$s3 + 4 ) addi \$s3, \$s3, 4 # \$s3 += 4 PowerPC code lwu \$t0, 4(\$s3) # \$t0 = *(\$s3 + 4 ); \$s3 += 4 New instructions Load multiple and store multiple Transfer up to 32 words of data in one instruction; useful for copying large data Special counter register to speed up loops

### Chapter 2: Instructions:

Chapter 2: Instructions: Language of the Computer Computer Architecture CS-3511-2 1 Instructions: To command a computer s hardware you must speak it s language The computer s language is called instruction

### Chapter 2A Instructions: Language of the Computer

Chapter 2A Instructions: Language of the Computer Copyright 2009 Elsevier, Inc. All rights reserved. Instruction Set The repertoire of instructions of a computer Different computers have different instruction

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

Chapter 2 Instructions: Language of the Computer Adapted by Paulo Lopes Instruction Set The repertoire of instructions of a computer Different computers have different instruction sets But with many aspects

Branch Addressing Branch instructions specify Opcode, two registers, target address Most branch targets are near branch Forward or backward op rs rt constant or address 6 bits 5 bits 5 bits 16 bits PC-relative

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

Representing Instructions Instructions are encoded in binary Called machine code MIPS instructions Encoded as 32-bit instruction words Small number of formats encoding operation code (opcode), register

### COMPUTER ORGANIZATION AND DESIGN

COMPUTER ORGANIZATION AND DESIGN 5 th The Hardware/Software Interface Edition Chapter 2 Instructions: Language of the Computer 2.1 Introduction Instruction Set The repertoire of instructions of a computer

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

Chapter 2 Computer Abstractions and Technology Lesson 4: MIPS (cont ) Logical Operations Instructions for bitwise manipulation Operation C Java MIPS Shift left >>> srl Bitwise

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

Computer Organization and Structure Bing-Yu Chen National Taiwan University Instructions: Language of the Computer Operations and Operands of the Computer Hardware Signed and Unsigned Numbers Representing

### COMPSCI 313 S Computer Organization. 7 MIPS Instruction Set

COMPSCI 313 S2 2018 Computer Organization 7 MIPS Instruction Set Agenda & Reading MIPS instruction set MIPS I-format instructions MIPS R-format instructions 2 7.1 MIPS Instruction Set MIPS Instruction

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

Stored Program Concept Instructions: Instructions are bits Programs are stored in memory to be read or written just like data Processor Memory memory for data, programs, compilers, editors, etc. Fetch

### Computer Organization MIPS ISA

CPE 335 Computer Organization MIPS ISA Dr. Iyad Jafar Adapted from Dr. Gheith Abandah Slides http://www.abandah.com/gheith/courses/cpe335_s08/index.html CPE 232 MIPS ISA 1 (vonneumann) Processor Organization

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

Computer Organization and Structure Bing-Yu Chen National Taiwan University Instructions: Language of the Computer Operations and Operands of the Computer Hardware Signed and Unsigned Numbers Representing

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

ENGN1640: Design of Computing Systems Topic 03: Instruction Set Architecture Design Professor Sherief Reda http://scale.engin.brown.edu School of Engineering Brown University Spring 2014 Sources: Computer

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

Instructions: Chapter 3 : MIPS Downloaded from: http://www.cs.umr.edu/~bsiever/cs234/ Language of the Machine More primitive than higher level languages e.g., no sophisticated control flow Very restrictive

### Architecture II. Computer Systems Laboratory Sungkyunkwan University

MIPS Instruction ti Set Architecture II Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Making Decisions (1) Conditional operations Branch to a

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

Chapter 3 MIPS Assembly Language Ó1998 Morgan Kaufmann Publishers 1 Instructions: Language of the Machine More primitive than higher level languages e.g., no sophisticated control flow Very restrictive

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

Introduction to the MIPS Lecture for CPSC 5155 Edward Bosworth, Ph.D. Computer Science Department Columbus State University Introduction to the MIPS The Microprocessor without Interlocked Pipeline Stages

### CS3350B Computer Architecture MIPS Introduction

CS3350B Computer Architecture MIPS Introduction Marc Moreno Maza http://www.csd.uwo.ca/~moreno/cs3350_moreno/index.html Department of Computer Science University of Western Ontario, Canada Thursday January

### MIPS Instruction Set Architecture (2)

MIPS Instruction Set Architecture (2) Jinkyu Jeong (jinkyu@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu EEE3050: Theory on Computer Architectures, Spring 2017, Jinkyu

### Thomas Polzer Institut für Technische Informatik

Thomas Polzer tpolzer@ecs.tuwien.ac.at Institut für Technische Informatik Branch to a labeled instruction if a condition is true Otherwise, continue sequentially beq rs, rt, L1 if (rs == rt) branch to

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

Chapter 2 Instructions: Language of the Computer Instruction Set The repertoire of instructions of a computer Different computers have different instruction sets But with many aspects in common Early computers

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

ELEC 5200-001/6200-001 Computer Architecture and Design Fall 2013 Instruction Set Architecture (Chapter 2) Victor P. Nelson, Professor & Asst. Chair Vishwani D. Agrawal, James J. Danaher Professor Department

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

Lecture 2 Instructions: Language of the Computer (Chapter 2 of the textbook) Instructions: tell computers what to do Chapter 2 Instructions: Language of the Computer 2 Introduction Chapter 2.1 Chapter

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

Control Instructions Computer Organization Architectures for Embedded Computing Thursday, 26 September 2013 Many slides adapted from: Computer Organization and Design, Patterson & Hennessy 4th Edition,

### Control Instructions

Control Instructions Tuesday 22 September 15 Many slides adapted from: and Design, Patterson & Hennessy 5th Edition, 2014, MK and from Prof. Mary Jane Irwin, PSU Summary Previous Class Instruction Set

### CENG3420 Lecture 03 Review

CENG3420 Lecture 03 Review Bei Yu byu@cse.cuhk.edu.hk 2017 Spring 1 / 38 CISC vs. RISC Complex Instruction Set Computer (CISC) Lots of instructions of variable size, very memory optimal, typically less

### Instructions: Language of the Computer

CS359: Computer Architecture Instructions: Language of the Computer Yanyan Shen Department of Computer Science and Engineering 1 The Language a Computer Understands Word a computer understands: instruction

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

Instructions: ti Language of the Computer Rui Wang, Assistant professor Dept. of Information and Communication Tongji University it Email: ruiwang@tongji.edu.cn Computer Hierarchy Levels Language understood

### CS222: MIPS Instruction Set

CS222: MIPS Instruction Set Dr. A. Sahu Dept of Comp. Sc. & Engg. Indian Institute of Technology Guwahati 1 Outline Previous Introduction to MIPS Instruction Set MIPS Arithmetic's Register Vs Memory, Registers

### Levels of Programming. Registers

Levels of Programming COSC 2021: Computer Organization Instructor: Dr. Amir Asif Department of Computer Science York University Handout # 3: MIPS Instruction Set I Topics: 1. Arithmetic Instructions 2.

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

Computer Science 324 Computer Architecture Mount Holyoke College Fall 2009 Topic Notes: MIPS Instruction Set Architecture vonneumann Architecture Modern computers use the vonneumann architecture. Idea:

### CS3350B Computer Architecture

CS3350B Computer Architecture Winter 2015 Lecture 4.1: MIPS ISA: Introduction Marc Moreno Maza www.csd.uwo.ca/courses/cs3350b [Adapted d from lectures on Computer Organization and Design, Patterson & Hennessy,

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

Stored Program Concept nstructions: nstructions are bits Programs are stored in memory to be read or written just like data Processor Memory memory for data, programs, compilers, editors, etc. Fetch &

### Instructions: Assembly Language

Chapter 2 Instructions: Assembly Language Reading: The corresponding chapter in the 2nd edition is Chapter 3, in the 3rd edition it is Chapter 2 and Appendix A and in the 4th edition it is Chapter 2 and

### Chapter 2. Instruction Set Architecture (ISA)

Chapter 2 Instruction Set Architecture (ISA) 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:

### MODULE 4 INSTRUCTIONS: LANGUAGE OF THE MACHINE

MODULE 4 INSTRUCTIONS: LANGUAGE OF THE MACHINE 1 ARCHITECTURE MODEL The basic instruction set of a computer is comprised of sequences of REGISTER TRANSFERS. Example: Add A, B, C Register B # A

### ECE369. Chapter 2 ECE369

Chapter 2 1 Instruction Set Architecture A very important abstraction interface between hardware and low-level software standardizes instructions, machine language bit patterns, etc. advantage: different

### MIPS (SPIM) Assembler Syntax

MIPS (SPIM) Assembler Syntax Comments begin with # Everything from # to the end of the line is ignored Identifiers are a sequence of alphanumeric characters, underbars (_), and dots () that do not begin

### Machine Instructions - II. Hwansoo Han

Machine Instructions - II Hwansoo Han Conditional Operations Instructions for making decisions Alter the control flow - change the next instruction to be executed Branch to a labeled instruction if a condition

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

Instructions: MIPS ISA Chapter 2 Instructions: Language of the Computer 1 PH Chapter 2 Pt A Instructions: MIPS ISA Based on Text: Patterson Henessey Publisher: Morgan Kaufmann Edited by Y.K. Malaiya for

### CS3350B Computer Architecture MIPS Instruction Representation

CS3350B Computer Architecture MIPS Instruction Representation Marc Moreno Maza http://www.csd.uwo.ca/~moreno/cs3350_moreno/index.html Department of Computer Science University of Western Ontario, Canada

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

EN164: Design of Computing Systems Topic 03: Instruction Set Architecture Design Professor Sherief Reda http://scale.engin.brown.edu Electrical Sciences and Computer Engineering School of Engineering Brown

### comp 180 Lecture 10 Outline of Lecture Procedure calls Saving and restoring registers Summary of MIPS instructions

Outline of Lecture Procedure calls Saving and restoring registers Summary of MIPS instructions Procedure Calls A procedure of a subroutine is like an agent which needs certain information to perform a

### Computer Science and Engineering 331. Midterm Examination #1. Fall Name: Solutions S.S.#:

Computer Science and Engineering 331 Midterm Examination #1 Fall 2000 Name: Solutions S.S.#: 1 41 2 13 3 18 4 28 Total 100 Instructions: This exam contains 4 questions. It is closed book and notes. Calculators

### Systems Architecture I

Systems Architecture I Topics Assemblers, Linkers, and Loaders * Alternative Instruction Sets ** *This lecture was derived from material in the text (sec. 3.8-3.9). **This lecture was derived from material

### MIPS%Assembly% E155%

MIPS%Assembly% E155% Outline MIPS Architecture ISA Instruction types Machine codes Procedure call Stack 2 The MIPS Register Set Name Register Number Usage \$0 0 the constant value 0 \$at 1 assembler temporary

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

CSCI 402: Computer Architectures Instructions: Language of the Computer (3) Fengguang Song Department of Computer & Information Science IUPUI Recall Big endian, little endian Memory alignment Unsigned

### Computer Architecture

Computer Architecture Chapter 2 Instructions: Language of the Computer Fall 2005 Department of Computer Science Kent State University Assembly Language Encodes machine instructions using symbols and numbers

### Computer Architecture

CS3350B Computer Architecture Winter 2015 Lecture 4.2: MIPS ISA -- Instruction Representation Marc Moreno Maza www.csd.uwo.ca/courses/cs3350b [Adapted from lectures on Computer Organization and Design,

Fall 2017 EE 3613: Computer Organization Chapter 2: Instruction Set Architecture 2/4 Avinash Kodi Department of Electrical Engineering & Computer Science Ohio University, Athens, Ohio 45701 E-mail: kodi@ohio.edu

### Lecture 4: MIPS Instruction Set

Lecture 4: MIPS Instruction Set No class on Tuesday Today s topic: MIPS instructions Code examples 1 Instruction Set Understanding the language of the hardware is key to understanding the hardware/software

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

CSE2021 Computer Organization Chapter 2: Part 2 Procedure Calling Procedure (function) performs a specific task and return results to caller. Supporting Procedures Procedure Calling Calling program place

Fall 2018 EE 3613: Computer Organization Chapter 2: Instruction Set Architecture Introduction 4/4 Avinash Karanth Department of Electrical Engineering & Computer Science Ohio University, Athens, Ohio 45701

### EEC 581 Computer Architecture Lecture 1 Review MIPS

EEC 581 Computer Architecture Lecture 1 Review MIPS 1 Supercomputing: Suddenly Fancy 2 1 Instructions: Language of the Machine More primitive than higher level languages e.g., no sophisticated control

### Topic Notes: MIPS Instruction Set Architecture

Computer Science 220 Assembly Language & Comp. Architecture Siena College Fall 2011 Topic Notes: MIPS Instruction Set Architecture vonneumann Architecture Modern computers use the vonneumann architecture.

### Chapter 3. Instructions:

Chapter 3 1 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

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

Chapter 2 Instructions: Language of the Computer HW#1: 1.3 all, 1.4 all, 1.6.1, 1.14.4, 1.14.5, 1.14.6, 1.15.1, and 1.15.4 Due date: one week. Practice: 1.5 all, 1.6 all, 1.10 all, 1.11 all, 1.14 all,

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

CISC 662 Graduate Computer Architecture Lecture 4 - ISA MIPS ISA Michela Taufer http://www.cis.udel.edu/~taufer/courses Powerpoint Lecture Notes from John Hennessy and David Patterson s: Computer Architecture,

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

CSE 2021: Computer Organization Recap from Last Time load from disk High-Level Program Lecture-2 Code Translation-1 Registers, Arithmetic, logical, jump, and branch instructions MIPS to machine language

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

CSE 2021: Computer Organization Recap from Last Time load from disk High-Level Program Lecture-3 Code Translation-1 Registers, Arithmetic, logical, jump, and branch instructions MIPS to machine language

### Lecture 5: Procedure Calls

Lecture 5: Procedure Calls Today s topics: Memory layout, numbers, control instructions Procedure calls 1 Memory Organization The space allocated on stack by a procedure is termed the activation record

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

CSE141: Introduction to Computer Architecture CSE 141 Computer Architecture Spring 2005 Lecture 3 Instruction Set Architecute Pramod V. Argade April 4, 2005 Instructor: TAs: Pramod V. Argade (p2argade@cs.ucsd.edu)

### CISC 662 Graduate Computer Architecture. Lecture 4 - ISA

CISC 662 Graduate Computer Architecture Lecture 4 - ISA Michela Taufer http://www.cis.udel.edu/~taufer/courses Powerpoint Lecture Notes from John Hennessy and David Patterson s: Computer Architecture,

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

Computer Science 324 Computer Architecture Mount Holyoke College Fall 2007 Topic Notes: MIPS Instruction Set Architecture vonneumann Architecture Modern computers use the vonneumann architecture. Idea:

### Assembly Language Programming. CPSC 252 Computer Organization Ellen Walker, Hiram College

Assembly Language Programming CPSC 252 Computer Organization Ellen Walker, Hiram College Instruction Set Design Complex and powerful enough to enable any computation Simplicity of equipment MIPS Microprocessor

### Do-While Example. In C++ In assembly language. do { z--; while (a == b); z = b; loop: addi \$s2, \$s2, -1 beq \$s0, \$s1, loop or \$s2, \$s1, \$zero

Do-While Example In C++ do { z--; while (a == b); z = b; In assembly language loop: addi \$s2, \$s2, -1 beq \$s0, \$s1, loop or \$s2, \$s1, \$zero 25 Comparisons Set on less than (slt) compares its source registers

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

Announcements HW1 is due on this Friday (Sept 12 th ) Appendix A is very helpful to HW1. Check out system calls on Page A-48. Ask TA (Liquan chen: liquan@ece.rutgers.edu) about homework related questions.

### Chapter 2. Instructions:

Chapter 2 1 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

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

EN164: Design of Computing Systems Lecture 09: Processor / ISA 2 Professor Sherief Reda http://scale.engin.brown.edu Electrical Sciences and Computer Engineering School of Engineering Brown University

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

Chapter 2 1 MIPS Instructions Instruction Meaning add \$s1,\$s2,\$s3 \$s1 = \$s2 + \$s3 sub \$s1,\$s2,\$s3 \$s1 = \$s2 \$s3 addi \$s1,\$s2,4 \$s1 = \$s2 + 4 ori \$s1,\$s2,4 \$s2 = \$s2 4 lw \$s1,100(\$s2) \$s1 = Memory[\$s2+100]

### ECE 30 Introduction to Computer Engineering

ECE 30 Introduction to Computer Engineering Study Problems, Set #3 Spring 2015 Use the MIPS assembly instructions listed below to solve the following problems. arithmetic add add sub subtract addi add

### COMP 303 Computer Architecture Lecture 3. Comp 303 Computer Architecture

COMP 303 Computer Architecture Lecture 3 Comp 303 Computer Architecture 1 Supporting procedures in computer hardware The execution of a procedure Place parameters in a place where the procedure can access

### Reduced Instruction Set Computer (RISC)

Reduced Instruction Set Computer (RISC) Reduced Instruction Set Computer (RISC) Focuses on reducing the number and complexity of instructions of the machine. Reduced number of cycles needed per instruction.

### CS/COE1541: Introduction to Computer Architecture

CS/COE1541: Introduction to Computer Architecture Dept. of Computer Science University of Pittsburgh http://www.cs.pitt.edu/~melhem/courses/1541p/index.html 1 Computer Architecture? Application pull Operating

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

Computer Architecture Chapter 2-2 Instructions: Language of the Computer 1 Procedures A major program structuring mechanism Calling & returning from a procedure requires a protocol. The protocol is a sequence

### Communicating with People (2.8)

Communicating with People (2.8) For communication Use characters and strings Characters 8-bit (one byte) data for ASCII lb \$t0, 0(\$sp) ; load byte Load a byte from memory, placing it in the rightmost 8-bits

### CENG3420 L03: Instruction Set Architecture

CENG3420 L03: Instruction Set Architecture Bei Yu byu@cse.cuhk.edu.hk (Latest update: January 31, 2018) Spring 2018 1 / 49 Overview Introduction Arithmetic & Logical Instructions Data Transfer Instructions

### Reduced Instruction Set Computer (RISC)

Reduced Instruction Set Computer (RISC) Focuses on reducing the number and complexity of instructions of the ISA. RISC Goals RISC: Simplify ISA Simplify CPU Design Better CPU Performance Motivated by simplifying

### All instructions have 3 operands Operand order is fixed (destination first)

Instruction Set Architecture for MIPS Processors Overview Dr. Arjan Durresi Louisiana State University Baton Rouge, LA 70803 durresi@csc.lsu.edu These slides are available at: http://www.csc.lsu.edu/~durresi/_07/

### LECTURE 2: INSTRUCTIONS

LECTURE 2: INSTRUCTIONS Abridged version of Patterson & Hennessy (2013):Ch.2 Instruction Set The repertoire of instructions of a computer Different computers have different instruction sets But with many

### Computer Architecture Instruction Set Architecture part 2. Mehran Rezaei

Computer Architecture Instruction Set Architecture part 2 Mehran Rezaei Review Execution Cycle Levels of Computer Languages Stored Program Computer/Instruction Execution Cycle SPIM, a MIPS Interpreter

### CS3350B Computer Architecture MIPS Procedures and Compilation

CS3350B Computer Architecture MIPS Procedures and Compilation Marc Moreno Maza http://www.csd.uwo.ca/~moreno/cs3350_moreno/index.html Department of Computer Science University of Western Ontario, Canada

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

101 Assembly ENGR 3410 Computer Architecture Mark L. Chang Fall 2009 What is assembly? 79 Why are we learning assembly now? 80 Assembly Language Readings: Chapter 2 (2.1-2.6, 2.8, 2.9, 2.13, 2.15), Appendix

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

Today s topics CS/COE1541: Introduction to Computer Architecture MIPS operations and operands MIPS registers Memory view Instruction encoding A Review of MIPS ISA Sangyeun Cho Arithmetic operations Logic

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

Chapter 1 Computer Abstractions and Technology Lesson 3: Understanding Performance Manufacturing ICs 1.7 Real Stuff: The AMD Opteron X4 Yield: proportion of working dies per wafer Chapter 1 Computer Abstractions

### Computer Organization and Design

Computer Organization and Design The Hardware/Software Interface Chapter 2 - Introductions: Language of the Computer Dr. Feng Li fli@sdu.edu.cn https://funglee.github.io 1 Contents of Chapter 2 l 2.1 Introduction

### Instruction Set Architecture part 1 (Introduction) Mehran Rezaei

Instruction Set Architecture part 1 (Introduction) Mehran Rezaei Overview Last Lecture s Review Execution Cycle Levels of Computer Languages Stored Program Computer/Instruction Execution Cycle SPIM, a

### Overview. Introduction to the MIPS ISA. MIPS ISA Overview. Overview (2)

Introduction to the MIPS ISA Overview Remember that the machine only understands very basic instructions (machine instructions) It is the compiler s job to translate your high-level (e.g. C program) into

### Instruction Set Architecture

Computer Architecture Instruction Set Architecture Lynn Choi Korea University Machine Language Programming language High-level programming languages Procedural languages: C, PASCAL, FORTRAN Object-oriented

### Architecture I. Computer Systems Laboratory Sungkyunkwan University

MIPS Instruction ti Set Architecture I Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Architecture (1) the attributes of a system as seen by the

### Instructions: Language of the Computer

Instructions: Language of the Computer Tuesday 22 September 15 Many slides adapted from: and Design, Patterson & Hennessy 5th Edition, 2014, MK and from Prof. Mary Jane Irwin, PSU Summary Previous Class

### Instruction Set Architecture. "Speaking with the computer"

Instruction Set Architecture "Speaking with the computer" The Instruction Set Architecture Application Compiler Instr. Set Proc. Operating System I/O system Instruction Set Architecture Digital Design

### EC 413 Computer Organization

EC 413 Computer Organization Review I Prof. Michel A. Kinsy Computing: The Art of Abstraction Application Algorithm Programming Language Operating System/Virtual Machine Instruction Set Architecture (ISA)

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

1 5. Addressing Modes MIPS Addressing Modes 2 Addressing takes care of where to find data instruction We have seen, so far three addressing modes of MIPS (to find data): 1. Immediate addressing: provides

### Lectures 3-4: MIPS instructions

Lectures 3-4: MIPS instructions Motivation Learn how a processor s native language looks like Discover the most important software-hardware interface MIPS Microprocessor without Interlocked Pipeline Stages

### MIPS Functions and Instruction Formats

MIPS Functions and Instruction Formats 1 The Contract: The MIPS Calling Convention You write functions, your compiler writes functions, other compilers write functions And all your functions call other

### Chapter 2. Baback Izadi Division of Engineering Programs

Chapter 2 Baback Izadi Division of Engineering Programs bai@engr.newpaltz.edu Instruction Set Language of the Machine The repertoire of instructions of a computer Different computers have different instruction

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

ECE232: Hardware Organization and Design Part 6: MIPS Instructions II http://www.ecs.umass.edu/ece/ece232/ Adapted from Computer Organization and Design, Patterson & Hennessy, UCB Computer Organization