Chapter 3. Instructions:

Similar documents
Chapter 2. Instructions:

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

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

Chapter 2. Instruction Set Architecture (ISA)

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)

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

CS222: MIPS Instruction Set

Chapter 2: Instructions:

COMPSCI 313 S Computer Organization. 7 MIPS Instruction Set

ECE369. Chapter 2 ECE369

EEC 581 Computer Architecture Lecture 1 Review MIPS

Topic Notes: MIPS Instruction Set Architecture

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

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

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

Instructions: Language of the Computer

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

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

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

Computer Architecture

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

MIPS (SPIM) Assembler Syntax

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

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

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

IC220 SlideSet #2: Instructions (Chapter 2)

CS3350B Computer Architecture MIPS Introduction

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

CS3350B Computer Architecture

Chapter 2A Instructions: Language of the Computer

We will study the MIPS assembly language as an exemplar of the concept.

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

Levels of Programming. Registers

Course Administration

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

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

Lecture 4: MIPS Instruction Set

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

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

MIPS%Assembly% E155%

MIPS Memory Access Instructions

Instruction Set Design and Architecture

CISC 662 Graduate Computer Architecture. Lecture 4 - ISA

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

CS/COE1541: Introduction to Computer Architecture

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

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

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

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

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

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

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

ECE232: Hardware Organization and Design

Branch Addressing. Jump Addressing. Target Addressing Example. The University of Adelaide, School of Computer Science 28 September 2015

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

Instructions: Assembly Language

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

(Refer Slide Time: 1:40)

ECE 30 Introduction to Computer Engineering

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

Control Instructions

Computer Organization MIPS ISA

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

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

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

CENG3420 L03: Instruction Set Architecture

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

COMP 303 Computer Architecture Lecture 3. Comp 303 Computer Architecture

COMPUTER ORGANIZATION AND DESIGN

Lecture 3: The Instruction Set Architecture (cont.)

Lecture 3: The Instruction Set Architecture (cont.)

ECE 154A Introduction to. Fall 2012

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

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

Chapter 2 Instruction: Language of the Computer

Computer Science 2500 Computer Organization Rensselaer Polytechnic Institute Spring Topic Notes: MIPS Programming

ENCM 369 Winter 2013: Reference Material for Midterm #2 page 1 of 5

Processor design - MIPS

Computer Architecture

MIPS Hello World. MIPS Assembly 1. # PROGRAM: Hello, World! # Data declaration section. out_string:.asciiz "\nhello, World!\n"

Instruction Set Architecture. "Speaking with the computer"

CS 4200/5200 Computer Architecture I

ECE232: Hardware Organization and Design

COE608: Computer Organization and Architecture

Quick Review. lw $t0, 4($a0) Registers x Memory. $a0 is simply another name for register 4 $t0 is another name for register (green sheet)

CS3350B Computer Architecture MIPS Instruction Representation

Chapter 2. Instructions: Language of the Computer

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

Programming the processor

CS61C Machine Structures. Lecture 12 - MIPS Procedures II & Logical Ops. 2/13/2006 John Wawrzynek. www-inst.eecs.berkeley.

Concepts Introduced in Chapter 3

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

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

Thomas Polzer Institut für Technische Informatik

Architecture I. Computer Systems Laboratory Sungkyunkwan University

Computer Architecture. MIPS Instruction Set Architecture

Lecture 5: Procedure Calls

LECTURE 2: INSTRUCTIONS

Transcription:

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 the MIPS instruction set architecture similar to other architectures developed since the 1980's used by NEC, Nintendo, Silicon Graphics, Sony Design goals: maximize performance and minimize cost, reduce design time 2

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) 3 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? 4

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 Control Input Memory Datapath Output Processor I/O 5 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. 0 1 2 3 4 5 6... 6

Memory Organization Bytes are nice, but most data items use larger "words" 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... 2 32 bytes with byte addresses from 0 to 2 32-1 2 30 words with byte addresses 0, 4, 8,... 2 32-4 Words are aligned i.e., what are the least 2 significant bits of a word address? 7 Instructions Load and store instructions Example: C code: MIPS code: A[8] = h + A[8]; lw $t0, 32($s3) add $t0, $s2, $t0 sw $t0, 32($s3) Store word has destination last Remember arithmetic operands are registers, not memory! 8

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 9 Stored Program Concept 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 & Execute Cycle Instructions are fetched and put into a special register Bits in the register "control" the subsequent actions Fetch the next instruction and continue 10

Control Decision making instructions alter the control flow, i.e., change the "next" instruction to be executed MIPS conditional branch instructions: bne $t0, $t1, Label beq $t0, $t1, Label Example: if (i==j) h = i + j; bne $s0, $s1, Label add $s3, $s0, $s1 Label:... 11 Control MIPS unconditional branch instructions: j label Example: if (i!=j) beq $s4, $s5, Lab1 h=i+j; add $s3, $s4, $s5 else j Lab2 h=i-j; Lab1: sub $s3, $s4, $s5 Lab2:... Can you build a simple for loop? 12

Control Flow We have: beq, bne, what about Branch-if-less-than? New instruction: if $s1 < $s2 then $t0 = 1 slt $t0, $s1, $s2 else $t0 = 0 Can use this instruction to build "blt $s1, $s2, Label" can now build general control structures Note that the assembler needs a register to do this, there are policy of use conventions for registers 13 Policy of Use Conventions Name Register number Usage $zero 0 the constant value 0 $v0-$v1 2-3 values for results and expression evaluation $a0-$a3 4-7 arguments $t0-$t7 8-15 temporaries $s0-$s7 16-23 saved $t8-$t9 24-25 more temporaries $gp 28 global pointer $sp 29 stack pointer $fp 30 frame pointer $ra 31 return address 14

Constants Small constants are used quite frequently (50% of operands) e.g., A = A + 5; B = B + 1; C = C - 18; Solutions? Why not? put 'typical constants' in memory and load them. create hard-wired registers (like $zero) for constants like one. MIPS Instructions: addi $29, $29, 4 slti $8, $18, 10 andi $29, $29, 6 ori $29, $29, 4 How do we make this work? 15 Assembly Language vs. Machine Language Assembly provides convenient symbolic representation much easier than writing down numbers e.g., destination first Machine language is the underlying reality e.g., destination is no longer first Assembly can provide 'pseudoinstructions' e.g., move $t0, $t1 exists only in Assembly would be implemented using add $t0,$t1,$zero When considering performance you should count real instructions 16