CA226 Advanced Computer Architecture

Similar documents
CA226 Advanced Computer Architecture

MIPS Instructions: 64-bit Core Subset

CA226 Advanced Computer Architecture

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

Computer Systems and Architecture

The Evolution of Microprocessors. Per Stenström

The MIPS Instruction Set Architecture

CS 4200/5200 Computer Architecture I

CS3350B Computer Architecture MIPS Instruction Representation

TSK3000A - Generic Instructions

CSSE 232 Computer Architecture I. I/O and Addressing

Course Administration

EN2910A: Advanced Computer Architecture Topic 02: Review of classical concepts

Computer Architecture

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

ECE 30 Introduction to Computer Engineering

Reduced Instruction Set Computer (RISC)

Computer Architecture. The Language of the Machine

ICS 233 COMPUTER ARCHITECTURE. MIPS Processor Design Multicycle Implementation

MIPS Instruction Format

Reduced Instruction Set Computer (RISC)

CPU Architecture and Instruction Sets Chapter 1

Computer Architecture. MIPS Instruction Set Architecture

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

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

Instruction Set Architecture of. MIPS Processor. MIPS Processor. MIPS Registers (continued) MIPS Registers

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

MIPS Reference Guide

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

/ : Computer Architecture and Design Fall Midterm Exam October 16, Name: ID #:

The MIPS R2000 Instruction Set

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

Laboratory Exercise 6 Pipelined Processors 0.0

ICS 233 Computer Architecture & Assembly Language. ICS 233 Computer Architecture & Assembly Language

A Model RISC Processor. DLX Architecture

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

ECE 2035 Programming HW/SW Systems Spring problems, 6 pages Exam Two 11 March Your Name (please print) total

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

MIPS ISA and MIPS Assembly. CS301 Prof. Szajda

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

MIPS Instruction Set

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

MIPS Instruction Reference

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

M2 Instruction Set Architecture

MIPS Assembly Language. Today s Lecture

Today s Lecture. MIPS Assembly Language. Review: What Must be Specified? Review: A Program. Review: MIPS Instruction Formats

Anne Bracy CS 3410 Computer Science Cornell University. [K. Bala, A. Bracy, E. Sirer, and H. Weatherspoon]

Design for a simplified DLX (SDLX) processor Rajat Moona

ece4750-parc-isa.txt

MIPS%Assembly% E155%

CS3350B Computer Architecture MIPS Introduction

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

MIPS Assembly Language

A Processor. Kevin Walsh CS 3410, Spring 2010 Computer Science Cornell University. See: P&H Chapter , 4.1-3

Kernel Registers 0 1. Global Data Pointer. Stack Pointer. Frame Pointer. Return Address.

EE108B Lecture 3. MIPS Assembly Language II

ECE260: Fundamentals of Computer Engineering

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

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

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

F. Appendix 6 MIPS Instruction Reference

Examples of branch instructions

ISA and RISCV. CASS 2018 Lavanya Ramapantulu

5DV118 Computer Organization and Architecture Umeå University Department of Computing Science Stephen J. Hegner. Topic 3: Arithmetic

Anne Bracy CS 3410 Computer Science Cornell University. See P&H Chapter: , , Appendix B

SPIM Instruction Set

CS3350B Computer Architecture

1/26/2014. Previously. CSE 2021: Computer Organization. The Load/Store Family (1) Memory Organization. The Load/Store Family (2)

Flow of Control -- Conditional branch instructions

ECE 2035 A Programming Hw/Sw Systems Fall problems, 8 pages Final Exam 8 December 2014

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

Lectures 3-4: MIPS instructions

ece4750-tinyrv-isa.txt

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

ISA: The Hardware Software Interface

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

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

Question 0. Do not turn this page until you have received the signal to start. (Please fill out the identification section above) Good Luck!

Chapter 2: Instructions:

MIPS (SPIM) Assembler Syntax

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

ECE 15B Computer Organization Spring 2010

CA226 Advanced Computer Architecture

MACHINE LANGUAGE. To work with the machine, we need a translator.

ECE 2035 A Programming Hw/Sw Systems Spring problems, 8 pages Final Exam 29 April 2015

Instruction Frequency CPI. Load-store 55% 5. Arithmetic 30% 4. Branch 15% 4

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

ECE 2035 Programming HW/SW Systems Spring problems, 6 pages Exam Three 10 April 2013

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

Reminder: tutorials start next week!

ECE 2035 Programming HW/SW Systems Fall problems, 6 pages Exam Two 21 October 2016

EE 109 Unit 13 MIPS Instruction Set. Instruction Set Architecture (ISA) Components of an ISA INSTRUCTION SET OVERVIEW

MIPS Memory Access Instructions

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

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

COMPUTER ORGANIZATION AND DESIGN

Thomas Polzer Institut für Technische Informatik

Previously. CSE 2021: Computer Organization. Memory Organization. The Load/Store Family (1) 5/26/2011. Used to transfer data to/from DRAM.

ELE 818 * ADVANCED COMPUTER ARCHITECTURES * MIDTERM TEST *

Transcription:

Stephen Blott <stephen.blott@dcu.ie> Review of MIPS Instruction Set Table of Contents 1 2 Registers Memory Instructions r0 ; always 0 r1, r2,..., r31 ; general-purpose integer registers f0, f1, f2,..., f31 ; general-purpose floating-point registers The only instructions which access memory are: load instructions, and store instructions. All other instructions operate: register to register. 3 4

Load Instructions Memory Objects Examples: All registers are: ld r4,n(r0) ; load 8-byte word from address N into r4 ld r2,0(r1) ; load 8-byte word from address in r1 into r2 ld r3,8(r1) ; load 8-byte word from address in r1 plus 8 into r3 The first register is always the target, the source is memory. Addressing is always by displacement: ld r5,x(r1) ; load from memory address "X plus the contents of r1" 64 bits, or 8 bytes Memory objects may be: bytes (1 byte) half words (2 bytes) words (4 bytes) double words (8 bytes) 5 6 Aside Load Objects It is unfortunate: that the directive ".word" in fact reserves a double word of memory. lb r2,n(r0) ; load a single byte from address N lh r2,n(r0) ; load a two-byte value from address N lw r2,n(r0) ; load a four-byte value from address N ld r2,n(r0) ; load an eight-byte value from address N The computed memory address: must be appropriately aligned meaning: ` N%"size" = 0 ` 7 8

Load: Floating Point Stores l.d f1,n(r0) ; load a floating-point value ; into a floating-point register Addressing: is the same as for integer loads. Stores are the same: sb r2,n(r0) ; store a single byte to address N sh r2,n(r0) ; store a two-byte value to address N sw r2,n(r0) ; store a four-byte value to address N sd r2,n(r0) ; store an eight-byte value to address N s.d f1,n(r0) ; store a floating-point value to address N 9 10 Loads again, Loads and Signs For bytes, half words and words: there are also unsigned load instructions. lbu r2,n(r0) ; load a single byte from address N, unsigned lhu r2,n(r0) ; load a two-byte value from address N, unsigned lwu r2,n(r0) ; load a four-byte value from address N, unsigned Why? And why only in these three cases? Signed loads: are sign extended: the most significant bit is duplicated into the unloaded bits For unsigned loads: this is not done. And for double-word loads: this is unnecessary. 11 12

Arithmetic Instructions Integer Arithmetic dadd r3,r1,r2 ; r3 = r1 + r2 dsub r3,r1,r2 ; r3 = r1 - r2 dmul r3,r1,r2 ; r3 = r1 * r2 ddiv r3,r1,r2 ; r3 = r1 / r2 (any remainder is discarded) 13 14 Floating-Point Arithmetic Immediates add.d f3,f1,f2 ; f3 = f1 + f2 sub.d f3,f1,f2 ; f3 = f1 - f2 mul.d f3,f1,f2 ; f3 = f1 * f2 div.d f3,f1,f2 ; f3 = f1 / f2 ; Note: These require floating point registers. An immediate value is: a constant the argument value is included in the instruction itself Examples: daddi r3,r1,1 ; r3 = r1 + 1 daddi r3,r0,addr ; load immediate ADDR into r3 Contrast with: dadd r3,r1,r2 ; r3 = r1 + r2 15 16

Logical Operations Set Instructions Register-register: and r3,r2,r1 or r3,r2,r1 xor r3,r2,r1 Register-immediate: ; r3 = r2 bitwise-and r1 ; r3 = r2 bitwise-or r1 ; r3 = r2 bitwise-xor r1 slt r3,r1,r2 ; set r3 if r1 < r2, otherwise r3 = 0 slti r3,r1,value ; set r3 if r1 < VALUE, otherwise r3 = 0 A register is "set": if it is not zero. andi r3,r2,value ; r3 = r2 bitwise-and VALUE ori r3,r2,value ; r3 = r2 bitwise-or VALUE xori r3,r2,value ; r3 = r2 bitwise-xor VALUE 17 18 Shift Instructions Branches and Jumps dsll r2,r1,bits dsrl r2,r1,bits dsra r2,r1,bits ; logical shift left by BITS bits ; logical shift right by BITS bits ; arithmetic shift right by BITS bits ; sign extended 19 20

Jumps Branches Jumps are unconditional: Branches are conditional: j ADDR ; jump to immediate ADDR jal ADDR ; jump to immediate ADDR ; leaving return address in r31 jr r1 Note ; jump to address in r1 The instruction following a jump is in the branch delay slot, if enabled. beq r1,r2,addr bne r1,r2,addr ; branch to ADDR if r1 == r2 ; branch to ADDR if r1!= r2 beqz r1,addr ; branch to ADDR if r1 == 0 bnez r1,addr ; branch to ADDR if r1!= 0 Note The instruction following a branch is in the branch delay slot, if enabled. 21 22 Assembler Directives Data and Code Segments Directives are not instructions: rather, they instruct the assembler in its operation.data.text ; start of data (memory) segment ; memory directives go here ; start of code segment ; instructions go here 23 24

This is correct too Data Segment.text.data ; start of code segment ; instructions go here ; start of data (memory) segment ; memory directives go here B:.byte 1 ; allocate a byte, 1 byte H:.word16 1 ; allocate a half word, 2 bytes W:.word32 1 ; allocate a word, 4 bytes D:.word 1 ; allocate a double, 8 bytes F:.double 1.0 ; allocate a floating-point value Note In each case, the memory allocated is suitably aligned. 25 26 Data Segment A:.space 1024 ; leave 1024 bytes unallocated ; for example, space for an array S:.asciiz "Hello" ; allocate a null-terminated string Done <script> (function() { var mathjax = 'mathjax/mathjax.js?config=asciimath'; var element; element = document.createelement('script'); element.async = false; element.src = mathjax; element.type = 'text/javascript'; (document.getelementsbytagname('head')[0] document.body).appendchild(element); })(); </script> 27 28