Computer Systems and Networks

Similar documents
Computer Systems and Networks

Computer Systems and Networks. ECPE 170 Jeff Shafer University of the Pacific. MIPS Assembly

Computer Systems and Networks

Computer Systems and Networks. ECPE 170 Jeff Shafer University of the Pacific. MIPS Assembly

Computer Systems and Networks. ECPE 170 Jeff Shafer University of the Pacific. MIPS Assembly

Topic Notes: MIPS Instruction Set Architecture

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

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

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

Chapter 2. Instructions:

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

Chapter 3. Instructions:

COMPSCI 313 S Computer Organization. 7 MIPS Instruction Set

Introduction to MIPS Processor

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: MIPS Instruction Set 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)

CSSE232 Computer Architecture I. Datapath

Lecture 6 Decision + Shift + I/O

EC 413 Computer Organization

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

MIPS Assembly Programming

CISC 662 Graduate Computer Architecture. Lecture 4 - ISA

378: Machine Organization and Assembly Language

Lecture 4: MIPS Instruction Set

Compiling Techniques

Please put your cellphone on vibrate

MIPS Memory Access Instructions

Programming with QtSpim: A User s Manual

The Program Counter. QtSPIM Register Display (Fixed-Point Registers) Erik Jonsson School of Engineering and Computer Science

Field 6-Bit Op Code rs Field rt Field 16-bit Immediate field

Supplement for MIPS (Section 4.14 of the textbook)

Lecture 7: Examples, MARS, Arithmetic

CS222: MIPS Instruction Set

Instructions: Language of the Computer

QtSPIM and MARS : MIPS Simulators

RISC-V Assembly and Binary Notation

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

Control MIPS unconditional branch instruction (i.e., jump)

CSEE 3827: Fundamentals of Computer Systems

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

MIPS and QTSPIM Recap. MIPS Architecture. Cptr280. Dr Curtis Nelson. Cptr280, Autumn

I ve been getting this a lot lately So, what are you teaching this term? Computer Organization. Do you mean, like keeping your computer in place?

Course Administration

COMP MIPS instructions 2 Feb. 8, f = g + h i;

Course Administration

ECE/CS 552: Introduction to Computer Architecture ASSIGNMENT #1 Due Date: At the beginning of lecture, September 22 nd, 2010

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

MIPS Processor Overview

Chapter 04: Instruction Sets and the Processor organizations. Lesson 08: Processor Instructions - Part 1

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

ECE232: Hardware Organization and Design

MIPS and Basic Assembly Language CS 64: Computer Organization and Design Logic Lecture #4

Chapter 2: Instructions:

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

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

Computer Architecture

CS 61C: Great Ideas in Computer Architecture Introduction to Assembly Language and RISC-V Instruction Set Architecture

A crash course in MIPS assembly programming

IC220 SlideSet #2: Instructions (Chapter 2)

CS3350B Computer Architecture MIPS Introduction

SPIM & MIPS. Department of Information and Management. Computer Organization and Structure 年 9 月 29 日星期 一

CPSC 330 Computer Organization

COE608: Computer Organization and Architecture

Computer Architecture

ECE Exam I - Solutions February 19 th, :00 pm 4:25pm

USING A SIMULATOR. QUICK INTRODUCTION From various sources For cs470

ECE 571 Advanced Microprocessor-Based Design Lecture 7

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

CS 4200/5200 Computer Architecture I

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

MIPS ISA and MIPS Assembly. CS301 Prof. Szajda

MODULE 4 INSTRUCTIONS: LANGUAGE OF THE MACHINE

Computer Architecture CS372 Exam 3

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

CENG3420 L03: Instruction Set Architecture

CENG3420 Lecture 03 Review

Levels of Programming. Registers

Lectures 3-4: MIPS instructions

ECE 30 Introduction to Computer Engineering

9/9/12. New- School Machine Structures (It s a bit more complicated!) CS 61C: Great Ideas in Computer Architecture IntroducMon to Machine Language

Computer Architecture I (1DT016) Cary Laxer, Ph.D. Visiting Lecturer

Computer Organization MIPS ISA

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

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

Programmable Machines

Chapter 2. Instruction Set Architecture (ISA)

Instructions: Assembly Language

ECE 473 Computer Architecture and Organization Lab 4: MIPS Assembly Programming Due: Wednesday, Oct. 19, 2011 (30 points)

Processor design - MIPS

CS232 Final Exam May 5, 2001

ECE232: Hardware Organization and Design

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

Control Instructions

Programming the processor

Programmable Machines

MIPS Assembly (FuncDons)

CSSE232 Computer Architecture. Logic and Decision Opera:ons

COMP 303 MIPS Processor Design Project 3: Simple Execution Loop

MIPS (SPIM) Assembler Syntax

Processor Architecture

Transcription:

University of the Pacific LECTURE 15: MIPS (FOR LAB 10) Computer Systems and Networks Dr. Pallipuram (vpallipuramkrishnamani@pacific.edu)

Notes on MIPS Lectures When in a MIPS lecture, pay complete attention and work only on MIPS exercises. You snooze, you lose! Work on the remaining labs outside of class. In class, we will now focus ONLY on MIPS programming Missing out on lectures can lead to a significantly steep learning curve Pay attention and you ll love it! (except for a lot of typing)

Class Today MIPS Practice for Lab 10

Class to Date Human Compiler Compiler Linker (C Code) (Assembly code) (Object file / binary code) (Executable program)

Class Now Human (Assembly code) Assembler (Object file / binary code) Linker (Executable Program)

MIPS Background Microprocessor without Interlocked Pipeline Stages Embedded devices Cisco/Linksys routers Cable boxes MIPS processor is buried inside System-on-a-Chip (SOC) Gaming / entertainment Nintendo 64 Playstation, Playstation 2, PSP

MIPS Design RISC What does this mean? Reduced Instruc?on Set Compu?ng Simplified design for instruc?ons Use more instruc?ons to accomplish same task But each instruc?on runs much faster! 32 bits (originally) What does this mean? 1 word = 32 bits Size of data processed by an integer add instruc?on New(er) MIPS64 design is 64 bits, but we won t focus on that

Why should I learn MIPS? Computer Science majors -- Compilers optimize assembly to improve performance. One day, you ll develop such efficient compilers ECPE majors -- Assembly language will help you design Microcontroller applications. One day, you may be the coder for a microcontroller that goes on a space mission CS and ECPE majors -- You will collaborate and develop the next-generation processors

ISA DefiniOon Instruction Set Architecture is an interface between hardware and software Instruction Set Architecture defines format for arithmetic/ logic instructions, addressing instructions, and branching instructions. We will broadly divide ISA into these classes: Arithmetic instructions Branching instructions Addressing instructions

Recap of a typical Processor We will ac?vely use registers to fetch data and perform ALL arithme?c and logic computa?ons ALU CPU Cache Memory 1. Registers ì ì ì ì On the CPU itself Very close to ALU Tiny Access?me: 1 cycle registers Load values into registers and try performing everything with them 2. Memory ì Off- chip ì Large ì Access?me: 100+ cycles

Registers in MIPS MIPS design: 32 integer registers, each holding 32 bits Word size = 32 bits Name Use $zero $s0-$s7 $t0-$t9 Constant value: ZERO Local variables Temporary registers This is only 19 where are the rest of the 32? Reserved by conven?on for other uses We ll learn a few more later

ArithmeOc InstrucOons

Add InstrucOons Add (perform addition using registers) add <destination> <source 1> <source 2> E.g.: add $t0, $s1, $s2 #t0 = s1 + s2 add $s1, $s1, $s2 #s1 = s1 + s2 Add Immediate addi <destination> <source 1> <signed value> E.g.: addi $s0, $s1, -2 #s0 = s1-2 addi $s1, $s1, 1 #s1++ addi $t1, $zero, 6 # t1 = 6

Sub InstrucOons Sub (perform addition using registers) sub <destination> <source 1> <source 2> E.g.: sub $t0, $s1, $s2 #t0 = s1 - s2 sub $s1, $s1, $s2 #s1 = s1 - s2

Problem 1: Convert this snippet to assembly g = 15; h = 20; i = 5; j= 18; f = (g + h) (i+j); Assume Map: $s0 = g $s1 = h $s2 = i $s3 = j $s4 = f Currently, your computer only knows add and sub instructions!

Branching InstrucOons ASSEMBLY FOR IF- ELSE, FOR, WHILE, AND SUCH..

Can you dumb it down for the Computer? IF A is greater than or equal to B OR if A is greater than 6, then branch to instruction(s) that set(s) C to A. Then, jump to outside if-else. ELSE branch to instruction(s) that set(s) C to B-A. Many ways! Choose what fits you the best! if((a>=b) A>6) C=A; else C=B-A; //outside if-else

Branching InstrucOons Branch on equal: beq <register 1>, <register 2>, label #if register 1 is equal to register 2, then branch to label. Branch on not equal: bne <register 1>, <register 2>, label #if register 1 is not equal to register 2, then branch to label. Branch on greater than: bgt <register 1>, <register 2>, label #if register 1 is greater than register 2, then branch to label.

Branching InstrucOons Branch on greater than equal to: bge <register 1>, <register 2>, label #if register 1 is greater than or equal to register 2, then branch to label. Branch on less than: blt <register 1>, <register 2>, label #if register 1 is less than register 2, then branch to label. Branch on less than or equal to: ble <register 1>, <register 2>, label #if register 1 is less than or equal to register 2, then branch to label.

Problem 2: Convert the following to Assembly if((a>=b) A>6) C=A; else C=B-A; Currently, your computer only understands add, sub, and some branching. Better dumb it down for it! Assume Map: $s0 = C $s1 = A $s2 = B

Problem 3: Convert the following to Assembly sum=0; for(i=0;i<10;i++) { sum+=i; } Currently, your computer only understands add, sub, and some branching. Better dumb it down for it! Assume Map: $s0 = sum $t0 = i

Problem 4: Convert the following to Assembly sum=0; for(i=0;i<10;i++) { j=i; while(j<2*i) { sum=sum+j; j++; } } Currently, your computer only understands add, sub, and some branching. Better dumb it down for it! Assume Map: $s0 = sum $s1 = i $s2 = j

In- Class ParOcipaOon: 10 minutes Use as many registers while(1) { sum=sum+i; i--; if(i<=0) break; else continue; } Currently, your computer only understands add, sub, and some branching. Better dumb it down for it! Assume Map: $s0 = sum $s1 =i

You are prepared for Lab 10 Parts 1, 2, and 3 MAKE PROGRESS ON THESE UNTIL NEXT CLASS

USE THIS CODE AS A STUB. Also on Lab 10 Page (a link) # Declare main as a global function # Pound is for comments.globl main # All program code is placed after the #.text assembler directive.text # The label 'main' represents the starting point main: #fill out main here # Exit program by syscall li $v0, 10 # select exit syscall syscall # Exit the program Assembler directive.data.data # Reserves space in memory for word with initial value 0 # used to store Z in memory value:.word 0

Storing a value in Memory In the end of the stub, note a.data section E.g.:.data value:.word 0 # a word set to zero msg:.asciiz "Hello World!\n #a string pow2:.word 1, 2, 4, 8, 16, 32, 64, 128 #an initialized array of integers

Next Class MIPS for Labs 10, 11 and 12 Arrays and memory accesses in Assembly Writing Functions in assembly

For Next Class Carefully go through MIPS example programs (see Lab 10 page). Teach yourself: printf in MIPS scanf in MIPS Finish SPIM tutorial on Lab 10 page. In the next class, I will assume you know your way around SPIM