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. 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

Topic Notes: MIPS Instruction Set Architecture

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

Chapter 2. Instructions:

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

Chapter 3. Instructions:

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

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

EC 413 Computer Organization

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

CSSE232 Computer Architecture I. Datapath

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)

CISC 662 Graduate Computer Architecture. Lecture 4 - ISA

COMPSCI 313 S Computer Organization. 7 MIPS Instruction Set

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

Introduction to MIPS Processor

Lecture 4: MIPS Instruction Set

MIPS Memory Access Instructions

Programming with QtSpim: A User s Manual

Lecture 7: Examples, MARS, Arithmetic

MIPS Assembly Programming

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

Lecture 6 Decision + Shift + I/O

CS222: MIPS Instruction Set

Supplement for MIPS (Section 4.14 of the textbook)

Instructions: Language of the Computer

RISC-V Assembly and Binary Notation

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

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

CSEE 3827: Fundamentals of Computer Systems

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?

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

Course Administration

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

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

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

378: Machine Organization and Assembly Language

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

Chapter 2: Instructions:

ECE 571 Advanced Microprocessor-Based Design Lecture 7

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

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

Compiling Techniques

ECE232: Hardware Organization and Design

CPSC 330 Computer Organization

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

Levels of Programming. Registers

Lectures 3-4: MIPS instructions

CS3350B Computer Architecture MIPS Introduction

CENG3420 Lecture 03 Review

Computer Architecture

COE608: Computer Organization and Architecture

Computer Organization MIPS ISA

ECE 30 Introduction to Computer Engineering

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

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

CS 4200/5200 Computer Architecture I

CENG3420 L03: Instruction Set Architecture

Computer Architecture Homework #1 Due: September 7, 2007 (F) (4 PM in ITT 305 mailbox or under my office door, ITT 313)

MODULE 4 INSTRUCTIONS: LANGUAGE OF THE MACHINE

MIPS ISA and MIPS Assembly. CS301 Prof. Szajda

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

#1 #2 with corrections Monday, March 12 7:00pm to 8:30pm. Please do not write your U of C ID number on this cover page.

Course Administration

Instructions: Assembly Language

Computer Architecture CS372 Exam 3

Programmable Machines

Programming at different levels

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

Chapter 2. Instruction Set Architecture (ISA)

CS232 Final Exam May 5, 2001

MIPS Assembly (FuncDons)

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

Computer Internals ECE2036. Lecture 2. ECE2036 Computer Internals Spring / 12

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

IC220 SlideSet #2: Instructions (Chapter 2)

Programmable Machines

Assembly language Simple, regular instructions building blocks of C, Java & other languages Typically one-to-one mapping to machine language

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

Control Instructions

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

Modern Instruc?on Sets

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

Please put your cellphone on vibrate

CS 61C: Great Ideas in Computer Architecture More RISC-V Instructions and How to Implement Functions

CSSE232 Computer Architecture. Logic and Decision Opera:ons

Solutions for Chapter 2 Exercises

Assembly language Simple, regular instructions building blocks of C, Java & other languages Typically one-to-one mapping to machine language

Processor design - MIPS

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

CSc 256 Midterm 1 Fall 2011

Advanced processor designs

Lecture 4: Instruction Set Architecture

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

Assignment 1: Pipelining Implementation at SPIM Simulator

MIPS Processor Overview

Transcription:

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

Some Deadlines Lab 8 hard deadline 17 th NOV 5 AM Lab 9 due 15 th NOV 5 AM J MIPS lab 10 DUE 18 th NOV 5 AM

Class Today MIPS Practice for Lab 10. 8 AM 9 AM. Those still working on networking -- Labs 08 and 09. Those that are done with network programming go through SPIM tutorial on Lab 10 page

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 the microcontroller that goes on a space mission CS and ECPE majors -- You will collaborate and develop 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 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 (add a value to a register) 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

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

Problem 2: TreaOng your Computer Like a 2 nd Grader While speaking in assembly with computer, treat it like a 2 nd grader. Challenge: how would you explain the following to a 2 nd grader. Write down the most basic instruction in English: if((a>=b) A>6) C=A; else C=B-A;

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 3: Convert the following to Assembly if((a>=b) A>6) C=A; else C=B-A; Try doing everything with as many registers Assume Map: $s0 = C $s1 = A $s2 = B

Problem 4: Convert the following to Assembly Try doing everything with as many registers sum=0; for(i=0;i<10;i++) { sum+=i; } Assume Map: $s0 = sum $s1 = i

Problem 5: Convert the following to Assembly Try doing everything with as many registers sum=0; for(i=0;i<10;i++) { j=i; while(j<2*i) { sum=sum+j; j++; } } Assume Map: $s0 = sum $s1 = i $s2 = j

In- Class ParOcipaOon: 10 minutes Try doing everything with as many registers while(1) { sum=sum+i; i--; if(i<=0) break; else continue; } Assume Map: $s0 = sum $s1 =i

You are prepared for Lab 10 Parts 1, 2, and 3

Assembly Stub to use # 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

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