bits 5..0 the sub-function of opcode 0, 32 for the add instruction

Similar documents
ECE 30 Introduction to Computer Engineering


MIPS ISA and MIPS Assembly. CS301 Prof. Szajda

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

CS3350B Computer Architecture

MIPS PROJECT INSTRUCTION SET and FORMAT

EE 361 University of Hawaii Fall

Informatics 2C Computer Systems Practical 2 Deadline: 18th November 2009, 4:00 PM

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

Q1: /30 Q2: /25 Q3: /45. Total: /100

CS222: MIPS Instruction Set

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

CS61C Machine Structures. Lecture 13 - MIPS Instruction Representation I. 9/26/2007 John Wawrzynek. www-inst.eecs.berkeley.

Part 1 (70% of grade for homework 2): MIPS Programming: Simulating a simple computer

Computer Architecture

Brock Wilcox CS470 Homework Assignment 2

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

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

ECE 2035 Programming HW/SW Systems Fall problems, 6 pages Exam One 22 September Your Name (please print clearly) Signed.

ECE 2035 Programming HW/SW Systems Spring problems, 6 pages Exam One 4 February Your Name (please print clearly)

Chapter 2: Instructions:

EEM 486: Computer Architecture. Lecture 2. MIPS Instruction Set Architecture

Chapter 2. Instructions:

CS/COE1541: Introduction to Computer Architecture

MIPS Instruction Reference

CS3350B Computer Architecture MIPS Introduction

F. Appendix 6 MIPS Instruction Reference

Chapter 2A Instructions: Language of the Computer

Review of Last Lecture. CS 61C: Great Ideas in Computer Architecture. MIPS Instruction Representation II. Agenda. Dealing With Large Immediates

Course Administration

CS61C : Machine Structures

Mips Code Examples Peter Rounce

CS61C : Machine Structures

UCB CS61C : Machine Structures

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

ICS 233 COMPUTER ARCHITECTURE. MIPS Processor Design Multicycle Implementation

ECE 2035 Programming HW/SW Systems Fall problems, 7 pages Exam Two 23 October 2013

MIPS Coding Continued

CSSE 232 Computer Architecture I. I/O and Addressing

CS 4200/5200 Computer Architecture I

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

CS3350B Computer Architecture MIPS Instruction Representation

ECE468 Computer Organization & Architecture. MIPS Instruction Set Architecture

MIPS Instruction Set

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

Chapter 3. Instructions:

Computer Architecture

CS 61C: Great Ideas in Computer Architecture MIPS Instruction Formats

I-Format Instructions (3/4) Define fields of the following number of bits each: = 32 bits

MIPS Memory Access Instructions

2) Using the same instruction set for the TinyProc2, convert the following hex values to assembly language: x0f

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

Inf2C Computer Systems. Coursework 2. MIPS Multi-cycle Processor Design

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

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

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

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

Midterm. CS64 Spring Midterm Exam

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

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

Thomas Polzer Institut für Technische Informatik

ECE 2035 Programming HW/SW Systems Fall problems, 6 pages Exam Two 23 October Your Name (please print clearly) Signed.

ECE 486/586. Computer Architecture. Lecture # 7

Instructions: Language of the Computer

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

Control Instructions

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

CS61C L10 MIPS Instruction Representation II, Floating Point I (6)

CISC 662 Graduate Computer Architecture. Lecture 4 - ISA

ECE331: Hardware Organization and Design

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

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

CENG 3420 Lecture 06: Datapath

R-type Instructions. Experiment Introduction. 4.2 Instruction Set Architecture Types of Instructions

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

Levels of Programming. Registers

Laboratory Exercise 6 Pipelined Processors 0.0

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

Review of the Machine Cycle

CS 61C: Great Ideas in Computer Architecture. MIPS Instruction Formats

Lecture 9: Disassembly

CS3350B Computer Architecture Winter 2015

MIPS (SPIM) Assembler Syntax

CS61C : Machine Structures

ECE 2035 Programming HW/SW Systems Fall problems, 6 pages Exam One 19 September 2012

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

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

CS152 Computer Architecture and Engineering

Programming at different levels

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

ELEC 5200/6200 Computer Architecture and Design Spring 2017 Lecture 4: Datapath and Control

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

RISC-V Assembly and Binary Notation

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

Assembler. Lecture 8 CS301

CS 61c: Great Ideas in Computer Architecture

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

Instruction Set Architecture. "Speaking with the computer"

MIPS Instruction Format

Transcription:

CS2 Computer Systems note 1a Some MIPS instructions More details on these, and other instructions in the MIPS instruction set, can be found in Chapter 3 of Patterson and Hennessy. A full listing of MIPS instructions is given in Appendix A.10 of the same book. All instructions are a single 32-bit word, and each is word-aligned in memory, ie occupies bytes at addresses 4n, 4n+1, 4n+2 and 4n+3. Add Symbolic representation: add r1, r2, r3 Adds the contents of registers r2 and r3, and stores the result in register r1. (Overflow is ignored in the simulated processor in Practical 2) bits 31..26 the main opcode, 0 for the add instruction bits 25..21 first source register, r2 bits 20..16 second source register, r3 bits 15..11 destination register, r1 bits 5..0 the sub-function of opcode 0, 32 for the add instruction Subtract Symbolic representation: sub r1, r2, r3 Subtracts the contents of registers r3 from r2, and stores the result in register r1. (Overflow is ignored in the simulated processor in Practical 2) bits 31..26 the main opcode, 0 for the sub instruction bits 25..21 first source register, r2 bits 20..16 second source register, r3 bits 15..11 destination register, r1 1

bits 5..0 the sub-function of opcode 0, 34 for the sub instruction Add immediate Symbolic representation: addi r1, r2, n Adds the integer n to the contents of register r2, and stores the result in register r1. (Overflow is ignored in the simulated processor in Practical 2) bits 31..26 the opcode, 8 for the addi instruction bits 25..21 source register, r2 bits 20..16 destination register, r1 bits 15..0 the integer n, as a 16-bit 2 s-complement number, which is signextended Load word Symbolic representation: lw r1, n(r2) Adds the integer n to the contents of register r2, and uses the resulting integer to address memory and read the word at that address, which is stored in register r1. bits 31..26 the opcode, 35 for the lw instruction bits 25..21 base address register, r2 bits 20..16 register to be loaded, r1 bits 15..0 the integer n, as a 16-bit 2 s complement number, which is signextended Store word Symbolic representation: sw r1, n(r2) Adds the integer n to the contents of register r2, and uses the resulting integer to address memory, storing the word in register r1 at that address. bits 31..26 the opcode, 43 for the lw instruction bits 25..21 base address register, r2 2

bits 20..16 register to be stored, r1 bits 15..0 the integer n, as a 16-bit 2 s complement number, which is signextended Branch on equal Symbolic representation: beq r1, r2, label Compares the contents of registers r1 and r2, and if they are equal branches to the address indicated by label. bits 31..26 the opcode, 4 for the beq instruction bits 20..16 register r2 bits 15..0 an integer, represented as a 16-bit two s complement number, which is multiplied by 4 and sign-extended to 32 bits, and then added to the address of the following instruction, and the result stored in the Program Counter to effect the branch. Branch on not equal Symbolic representation: bne r1, r2, label Compares the contents of registers r1 and r2, and if they are not equal branches to the address indicated by label. bits 31..26 the opcode, 5 for the bne instruction bits 20..16 register r2 bits 15..0 an integer, represented as a 16-bit two s complement number, which is multiplied by 4 and sign-extended to 32 bits, and then added to the address of the following instruction, and the result stored in the Program Counter to effect the branch. Set less than Symbolic representation: slt r1, r2, r3 If the contents of register r2 is less than the contents of register r3, stores 1 into register r1, else stores 0 into register r1. The contents of r2 and r3 are interpreted as 32-bit 2 s-complement signed numbers. 3

bits 31..26 the opcode, 0 for the slt instruction bits 25..21 register r2 bits 20..16 register r3 bits 15..11 register r1 bits 5..0 the subfunction of opcode 0, 42 for the slt instruction Set less than immediate Symbolic representation: slti r1, r2, n If the contents of register r2 is less than the integer n, stores 1 into register r1, else stores 0 into register r1. The contents of r2 is interpreted as a 32-bit 2 s complement number. bits 31..26 the opcode, 10 for the slti instruction bits 25..21 register r2 bits 20..16 register r1 bits 15..0 the integer n, as a 16-bit 2 s-complement number, which is signextended to 32 bits before the comparison. Jump Symbolic representation: j target Unconditionally jump to the address indicated by target. bits 31..26 the opcode, 2 for the jump instruction bits 25..00 an integer, represented as a 26-bit number, which is multiplied by 4 and sign-extended to 32 bits, and then stored in the Program Counter to effect the branch. Jump and link Symbolic representation: jal target Save the address of the following instruction in register $ 31, and unconditionally jump to the address indicated by target. 4

bits 31..26 the opcode, 3 for the jal instruction bits 25..00 an integer, represented as a 26-bit number, which is multiplied by 4 and sign-extended to 32 bits, and then stored in the Program Counter to effect the branch. Jump register Symbolic representation: jr r1 Unconditionally jump to the address in register r1. bits 31..26 the opcode, 0 for the jr instruction bits 20..6 unused, set to 0 bits 5..0 the subfunction of opcode 0, 8 for the jr instruction Halt This final instruction is not a real MIPS instruction, but is included for the purposes of Practical 2. Symbolic representation: halt Causes the simulated processor/memory system in CS2 Practical 2 to halt. bits 31..26 the opcode, 0 for the halt instruction bits 25..6 unused, set to 0 bits 5..0 the subfunction of opcode 0, 12 for the halt instruction 2001-2004 Marcelo Cintra (2000 Tim Hopkins) 5