CS222: MIPS Instruction Set

Similar documents
Chapter 3. Instructions:

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

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

Chapter 2. Instructions:

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

Chapter 2: Instructions:

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

CS/COE1541: Introduction to Computer Architecture

COMPSCI 313 S Computer Organization. 7 MIPS Instruction Set

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

CS3350B Computer Architecture MIPS Introduction

MIPS%Assembly% E155%

Instructions: Language of the Computer

EEC 581 Computer Architecture Lecture 1 Review MIPS

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

Chapter 2. Instruction Set Architecture (ISA)

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

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

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

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

CISC 662 Graduate Computer Architecture. Lecture 4 - ISA

CS3350B Computer Architecture

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

ECE369. Chapter 2 ECE369

Course Administration

Chapter 2A Instructions: Language of the Computer

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

CS 4200/5200 Computer Architecture I

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. Computer Abstractions and Technology. Lesson 4: MIPS (cont )

Computer Organization MIPS ISA

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

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

COMPUTER ORGANIZATION AND DESIGN

Computer Architecture

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

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

CS222: Dr. A. Sahu. Indian Institute of Technology Guwahati

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

Lecture 4: MIPS Instruction Set

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

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

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

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

Computer Architecture

CS3350B Computer Architecture MIPS Instruction Representation

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

LECTURE 2: INSTRUCTIONS

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

CS31001 COMPUTER ORGANIZATION AND ARCHITECTURE. Debdeep Mukhopadhyay, CSE, IIT Kharagpur. Instructions and Addressing

CENG3420 L03: Instruction Set Architecture

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

Topic Notes: MIPS Instruction Set Architecture

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

CENG3420 Lecture 03 Review

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

Lecture 5: Procedure Calls

Instruction Set Architecture. "Speaking with the computer"

Levels of Programming. Registers

Architecture I. Computer Systems Laboratory Sungkyunkwan University

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

Lectures 3-4: MIPS instructions

Unsigned Binary Integers

Unsigned Binary Integers

CSEE 3827: Fundamentals of Computer Systems

Instructions: Language of the Computer

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

Control Instructions

Chapter 2. Instructions: Language of the Computer

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

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

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

Instructions: Language of 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

ECE468 Computer Organization & Architecture. MIPS Instruction Set Architecture

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

Instruction Set Design and Architecture

MIPS Memory Access Instructions

Reduced Instruction Set Computer (RISC)


Computer Architecture. The Language of the Machine

MIPS (SPIM) Assembler Syntax

Chapter 2. Baback Izadi Division of Engineering Programs

(Refer Slide Time: 1:40)

CS 61c: Great Ideas in Computer Architecture

Reduced Instruction Set Computer (RISC)

Five classic components

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

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

Programmable Machines

Computer Organization MIPS Architecture. Department of Computer Science Missouri University of Science & Technology

Instructions: Assembly Language

Computer Architecture. MIPS Instruction Set Architecture

MIPS Datapath. MIPS Registers (and the conventions associated with them) MIPS Instruction Types

Review of instruction set architectures

Communicating with People (2.8)

CS3350B Computer Architecture MIPS Procedures and Compilation

CS/COE0447: Computer Organization

Programmable Machines

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

Transcription:

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 Name Byte Ordering Instruction types and format Control instructions Constant t in MIPS ISA MIPS ALP

Example: Instruction Set Architecture MIPS Representative of architectures developed since the 1980's Used by NEC, Nintendo, Silicon Graphics, Sony Real architecture but easy to understand MIPS: Microprocessor without Interlocked p Pipeline Stages : ISA MIPS: Millions Instructions Per Sec: Measure

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)

MIPS Arithmetic Simplicity favors regularity Operands must be registers, only 32 registers provided (smaller is faster) Expressions need to be broken C code MIPS code A = B + C + D; add $t0, $s1, $s2 E = F A; add $s0, $t0, $s3 sub $s4,,$ $s5,,$ $s0

Registers vs. Memory Scalars mapped to registers Structures, arrays etc in memory Control Input Datapath Memory Output Processor I/O

Memory Organization Viewed as a large, singledimension 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 8 bits of data 1 2 8 bits of data 8 bits of data 3 8 bits of data 4 5 8 bits of data 8 bits of data 6 8 bits of data

Register Names and Purpose Name Register number Usage $zero 0 the constant value 0 $v0-$v1 2-3 values for results $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 R1: reserved for Architecture, R26 27:reserved for OS

Words and Bytes 2 32 bytes : byte addresses from 0 to 2 32 1 2 30 words : byte addresses 0, 4, 8,... 2 32 4 Big endian byte order Little endian byte order 0 1 2 3 4 5 6 7 3 2 1 0 d 7 6 5 4 3 2 1 0 Non aligned word 7 6 5 4

Instructions to access memory Load and store instructions Example: C code: A[8] = h + A[8]; MIPS code: lw $t0, 32($s3) add $t0, $s2, $t0 sw $t0, 32($s3)

A simple example What does this code do? swap(int v[ ],int k){ int temp; temp = v[k] swap: v[k] = v[k+1]; muli $2, $5,4 v[k+1] = temp; add $2, $4,$2 } lw $15, 0($2) lw $16, 4($2) sw $16, 0($2) sw $15, 4($2) jr $31

Instruction Format R Type : instructions use opcode 000000. This group Contains all instructions that do not require an immediate value, target offset, memory addressdisplacement displacement, or memory address to specify an operand. Includes arithmetic and logic with all operands in registers, shift instructions, and register direct jump instructions (jalr and jr). I Type : Opcodes except 000000, 00001x, and 0100xx This group includes instructions with an immediate operand, branch instructions, and load and store instructions. In the MIPS architecture, all memory accesses are handled by the main processor, so coprocessor load and store instructions are included in this group. J Type : instructions ti use opcode 00001x. This group consists of the two direct jump instructions (j and jal). These instructions ti require a memory address to specify their operand. 12

Machine Language Instructions are 32 bits long Registers have numbers 0.. 31, e.g., $t0=8, $t1=9,,$ $s0=16,,$ $s1=17 etc. Instruction Format: Example: add $t0, $s1, $s2 000000 10001 10010 01000 00000 100000 op rs rt rd shamt funct Shamt: Shift amount, funct: function

Machine Language lw / sw and the regularity principle? New principle: Good design demands a compromise new format (I type), other format was R Example: lw $t0, 32($s2) 35 18 9 32 op rs rt 16 bit number Lw $dst imm($src) : $dst M [$src+imm] Refers from M location, it a type of Addressing

Control Intruction Decision making instructions alter the control flow MIPS conditional branch instructions: bne and beq Example: if (i == j) bne $s0, $s1, Label h = i + j; add $3$0$1 $s3, $s0, $s1 Label:...

Control Intruction 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:...

Comparison less or greater slt: set if less than than slt $t0, $s1, $s2 if $s1 < $s2 then $t0 = 1 else $t0 = 0 Can use this instruction to build blt $s1 $s2 Can use this instruction to build blt $s1, $s2, Label, ble $s1, $s2, Label

Format of Instructions for Control beq, bne j I format op rs rt 16 bit number J format (new) op 26 bit number slt R format :set if less than op rs rt rd shamt funct

Constants Used quite frequently (50% of operands) e.g., A = A + 5; B = B + 1; C = C 18; Solutions? data in memory, initialized at load time put constants within ihi instructionsi

Constants in MIPS instructions addi $29, $29, 4 i is for immediate slti $8, $18, 10 andi $29, $29, 6 ori $29, $29, 4 I Format is used op rs rt 16 bit number

A special constant 0 is a special constant, hard wired into register $0 (also called $zero) add $s2, $s4, $zero means move from $s4 to $s2

How about larger constants? To load a 32 bit constant into a register, we use two instructions one instruction fills this one instruction fills this 1010101010101010 1111000011110000

Loading larger constants new "load upper immediate" instruction lui $t0, 1010101010101010 then get the lower order bits right, ie i.e., ori $t0, $t0, 1111000011110000 1010101010101010 0000000000000000 0000000000000000 1111000011110000 1010101010101010 1111000011110000

Summary of Instructions learnt Instructions Format add, sub, addi, subi R, I and, or, andi, ori R, I slt, slti R, I beq, bne I j J lw, sw I lui I