On Textbook CD: SPIM Jen-Chang Liu, 2006. Simulation of a virtual machine Virtual machine (simulator) Differences between SPIM and real MIPS? No delayed.

Slides:



Advertisements
Similar presentations
Review of the MIPS Instruction Set Architecture. RISC Instruction Set Basics All operations on data apply to data in registers and typically change the.
Advertisements

SPIM Tutorial CSE 410 Computer Systems. Introduction SPIM: MIPS simulator –Reads/executes assembly source programs Does not execute binaries Download.
SPARC Architecture & Assembly Language
SPIM and MIPS programming
Fall EE 333 Lillevik 333f06-l4 University of Portland School of Engineering Computer Organization Lecture 4 Assembly language programming ALU and.
Syscall in MIPS Xinhui Hu Yuan Wang.
MIPS Assembly Language Programming
Wannabe Lecturer Alexandre Joly inst.eecs.berkeley.edu/~cs61c-te
Ch. 8 Functions.
1 Computer Architecture MIPS Simulator and Assembly language.
Assembly Language Working with the CPU.
1 COMS 361 Computer Organization Title: Instructions Date: 9/28/2004 Lecture Number: 10.
ECE 0142 Recitation #5.
CS61C L05 Introduction to MIPS Assembly Language : Arithmetic (1) Garcia, Fall 2011 © UCB Lecturer SOE Dan Garcia inst.eecs.berkeley.edu/~cs61c.
COMP3221 lec08-arith.1 Saeid Nooshabadi COMP 3221 Microprocessors and Embedded Systems Lecture 8: C/Assembler Data Processing
Chap.2: Instructions: Language of the computer Jen-Chang Liu, Spring 2006 Adapted from
CS 61C L06 MIPS Intro (1) A Carle, Summer 2005 © UCB inst.eecs.berkeley.edu/~cs61c/su05 CS61C : Machine Structures Lecture #6: Intro to MIPS
CS61C L08 Introduction to MIPS Assembly Language: Arithmetic (1) Garcia © UCB Lecturer PSOE Dan Garcia inst.eecs.berkeley.edu/~cs61c.
MIPS Assembly Language I Computer Architecture CPSC 321 Andreas Klappenecker.
Normal C Memory Management °A program’s address space contains 4 regions: stack: local variables, grows downward heap: space requested for pointers via.
ECE 15B Computer Organization Spring 2010 Dmitri Strukov Lecture 4: Arithmetic / Data Transfer Instructions Partially adapted from Computer Organization.
CIS 314: Introduction to MIPS Assembly Language: Arithmetic Fall 2005 I´ve been getting this a lot lately So, what are you teaching this term? Computer.
CS1104 Assembly Language: Part 1
CS 61C L08 Introduction to MIPS Assembly Language: Arithmetic (1) Garcia, Spring 2004 © UCB Lecturer PSOE Dan Garcia inst.eecs.berkeley.edu/~cs61c.
Appendix A: MIPS Assembly Language. Instruction Format R-type I-type J-type.
1 Lecture 6: Compilers, the SPIM Simulator Today’s topics:  SPIM simulator  The compilation process Additional TA hours: Liqun Cheng, legion at.
From C to Assembly Language Jen-Chang Liu, Spring 2006 Adapted from
Data Transfer & Decisions I (1) Fall 2005 Lecture 3: MIPS Assembly language Decisions I.
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
IT253: Computer Organization Lecture 4: Instruction Set Architecture Tonga Institute of Higher Education.
Reformatting a Machine 125 Million Miles Away! Mars rover “Opportunity” got its flash drive reformatted 9/8/14, reason: rover keeps rebooting. Happy news:
1 Compilers Modern Compiler Design Supplementary Note 2 SPIM Overview NCYU C. H. Wang.
Procedure Basics Computer Organization I 1 October 2009 © McQuain, Feng & Ribbens Procedure Support From previous study of high-level languages,
Chapter 2 Instructions: Language of the Computer Part I.
Lecture # 1 SPIM & MIPS Programming. SPIM SPIM is a MIPS32 simulator that reads and executes assembly language program written for SPIM. Platform -Unix,
Ch2b- 2 EE/CS/CPE Computer Organization  Seattle Pacific University Thanks for all the Memory! When 32 registers just won’t do. Many times (almost.
Orange Coast College Business Division Computer Science Department CS 116- Computer Architecture Instructions: Part the Last.
Lecture 10: MIPS Simulator Today’s topic –SPIM Simulator Readings –Appendix B 1.
More on MIPS programs n SPIM does not support everything supported by a general MIPS assembler. For example, –.end doesn’t work Use j $ra –.macro doesn’t.
Lecture 161 Lets examine a SPIM program in detail. io.asm This program is a simple routine which demonstrates input/output using assembly code. SPIM.
1 Lecture 7: MARS, Computer Arithmetic Today’s topics:  MARS intro  Numerical representations  Addition and subtraction.
Computer Architecture CSCE 350 Rabi Mahapatra Spring 2015.
MIPS coding. slt, slti slt $t3, $t1, $t2 – set $t3 to be 1 if $t1 < $t2 ; else clear $t3 to be 0. – “Set Less Than.” slti $t3, $t1, 100 – set $t3 to be.
8086/8088 Instruction Set, Machine Codes and Addressing Modes.
MIPS assembly syntax Home Assignment 3 Assigned. Deadline 2016 February 14, Sunday.
3-Apr-2006cse spim © 2006 DW Johnson and University of Washington1 SPIM simulator CSE 410, Spring 2006 Computer Systems
MIPS Architecture Topics –What resources MIPS assembly manipulates –CPU (Central Processing Unit) –ALU (Arithmetic & Logical Unit), Registers –Memory –I/O.
Lecture 2: Instruction Set Architecture part 1 (Introduction) Mehran Rezaei.
Lecture 16: 10/29/2002CS170 Fall CS170 Computer Organization and Architecture I Ayman Abdel-Hamid Department of Computer Science Old Dominion University.
Copyright 2006 by Timothy J. McGuire, Ph.D. 1 MIPS Programming Model CS 333 Sam Houston State University Dr. Tim McGuire.
CS61C L05 Introduction to MIPS Assembly Language : Arithmetic (1) Garcia, Spring 2014 © UCB TA/Guest Lecturer: Shreyas Chand inst.eecs.berkeley.edu/~cs61c.
Assembly Language Basic job of a CPU: execute lots of instructions. Instructions are the primitive operations that the CPU may execute. Different CPUs.
Instructor: Dr. Mike Turi Department of Computer Science and Computer Engineering Pacific Lutheran University Lecture slides adapted from Part 4, EE 334.
CS 312 Computer Architecture & Organization
Computers’ Basic Organization
IT 251 Computer Organization and Architecture
Introduction to Lab #1 José Nelson Amaral.
ACOE301: Computer Architecture II Labs
MIPS assembly syntax Comments
IT 251 Computer Organization and Architecture
Lecture 4: MIPS Instruction Set
The University of Adelaide, School of Computer Science
MIPS coding.
COMS 361 Computer Organization
COMS 361 Computer Organization
Instructions in Machine Language
COMS 361 Computer Organization
CPU Structure CPU must:
CS 286 Computer Architecture & Organization
Week 5 Computers are like Old Testament gods; lots of rules and no mercy. Joseph Campbell.
Presentation transcript:

On Textbook CD: SPIM Jen-Chang Liu, 2006

Simulation of a virtual machine Virtual machine (simulator) Differences between SPIM and real MIPS? No delayed branch SPIM simulates the richer virtual machine SPIM: MIPS simulator MIPS code Real machine: Window, Linux, … VMware: Window, Linux OS Real machine: Window, Linux, … user

Setup SPIM Extract files from (uninstall version) files: pcspim.exe, pcspim.ico, hello.s, exceptions.s You can get the full version from my homepage Setup environment Modify it to your current directory

MIPS CPU Floating point

Assembly Variables: Registers (1/4) Unlike HLL, assembly cannot use variables Why not? Keep Hardware Simple Assembly Operands are registers limited number of special locations built directly into the hardware operations can only be performed on these! Benefit: Since registers are directly in hardware, they are very fast

Assembly Variables: Registers (2/4) Drawback: Since registers are in hardware, there are a predetermined number of them Solution: MIPS code must be very carefully put together to efficiently use registers 32 registers in MIPS Why 32? Smaller is faster Each MIPS register is 32 bits wide Groups of 32 bits called a word in MIPS

Assembly Variables: Registers (3/4) Registers are numbered from 0 to 31 Each register can be referred to by number or name Number references: $0, $1, $2, … $30, $31

Assembly Variables: Registers (4/4) By convention, each register also has a name to make it easier to code For now: $16 - $22  $s0 - $s7 (correspond to C variables) $8 - $15  $t0 - $t7 (correspond to temporary variables) In general, use names to make your code more readable

Addition and Subtraction (1/2) Syntax of Instructions: 12,3,4 where: 1) operation by name 2) operand getting result ( “ destination ” ) 3) 1st operand for operation ( “ source1 ” ) 4) 2nd operand for operation ( “ source2 ” ) Syntax is rigid: 1 operator, 3 operands Why? Keep Hardware simple via regularity °Example: add$s0,$s1,$s2

Addition and Subtraction (2/2) Addition in Assembly Example: add$s0,$s1,$s2 (in MIPS) Equivalent to: a = b + c (in C) where registers $s0,$s1,$s2 are associated with variables a, b, c Subtraction in Assembly Example: sub$s3,$s4,$s5 (in MIPS) Equivalent to: d = e - f (in C) where registers $s3,$s4,$s5 are associated with variables d, e, f

MIPS assembly syntax # hello.s.globl main main:.data str:.asciiz "Hello, World!".text li $v0, 4# system call code for print_str la $a0, str# address of string to print syscall# print the string comments labels ( ends with a colon : ) directives

MIPS directives 命令 (see p.A- 51,A-52).globl sym sym is global and can be referenced from other files.data Subsequent items are stored in the data segment.text Subsequent items (instructions or.word) are put in the user text segment.asciiz str Store the string str in memory and null-terminate it

MIPS memory (Textbook A.5) : holds program’s instructions Object whose size is known to the compiler Ex. C global variables Data is allocated by the program as it executes. Ex. malloc() in C Program dynamically push values on the stack

Register window Text window Data & Stack window 32 bits addressMachine code Bare machine instruction Assembly code Message window

Example: MIPS assembly data.asciiz "Hello, World!" Hello,Wordl ! \0 NOTE: one byte in an address

System calls syscall: SPIM provides a small set of operating-system-like services 3 steps: li $v0, 4 #system call code la $a0, str #set argument syscall

3/13 Lab#1