SPIM : A MIPS Simulator Archi & Net Lab 이용석

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

Introduction to SPIM Simulator
SPIM Tutorial CSE 410 Computer Systems. Introduction SPIM: MIPS simulator –Reads/executes assembly source programs Does not execute binaries Download.
MIPS Assembly Language CPSC 321 Computer Architecture Andreas Klappenecker.
5Z032 Processor Design SPIM, a MIPS simulator Henk Corporaal
1 Procedure Calls, Linking & Launching Applications Lecture 15 Digital Design and Computer Architecture Harris & Harris Morgan Kaufmann / Elsevier, 2007.
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.
Some Samples of MIPS Assembly Language Lecture for CPSC 5155 Edward Bosworth, Ph.D. Computer Science Department Columbus State University.
Syscall in MIPS Xinhui Hu Yuan Wang.
MIPS Function Continued
MIPS Assembly Language Programming
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.
 Procedures (subroutines) allow the programmer to structure programs making them : › easier to understand and debug and › allowing code to be reused.
ECE 232 L7.Simul.1 Adapted from Patterson 97 ©UCBCopyright 1998 Morgan Kaufmann Publishers ECE 232 Hardware Organization and Design Lecture 7 MIPS Assembly.
MIPS Assembly Language I Computer Architecture CPSC 321 Andreas Klappenecker.
Lab #1 PCSpim SPIM is a software simulator that loads and executes assembly language programs for the MIPS RISC computers. Download and install PCSpim.
On Textbook CD: SPIM Jen-Chang Liu, Simulation of a virtual machine Virtual machine (simulator) Differences between SPIM and real MIPS? No delayed.
Computer Organization - Syscalls David Monismith Jan. 28, 2015 Based on notes from Patterson and Hennessy Text and from Dr. Bill Siever.
1 MIPS Assembly Language Programming CDA 3101 Discussion Section 03.
Computer Organization and Architecture (AT70.01) Comp. Sc. and Inf. Mgmt. Asian Institute of Technology Instructor: Dr. Sumanta Guha Slide Sources: Freely.
19/02/2009CA&O Lecture 05 by Engr. Umbreen Sabir Computer Architecture & Organization Instructions: PCSpim Tutorial Engr. Umbreen Sabir Computer Engineering.
First Programming Assignment For MIPS R3000 Processor Department of Computer Science Southern Illinois University Edwardsville Fall, 2015 Dr. Hiroshi Fujinoki.
Spim part II Chun-Cheng Lin ( 林春成 ) & Jiunn-Jye Lee ( 李俊頡 ) CS, EE, NTU.
Comp Sci vars & expns 1 Ch. 4 Variables and Expressions.
1 Compilers Modern Compiler Design Supplementary Note 2 SPIM Overview NCYU C. H. Wang.
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.
R3000/001 Assembly Programming using MIPS R3000 CPU R3000 CPU Chip Manufactured by IDT What is MIPS R3000 Processor? A 32-bit RISC CPU developed by MIPS.
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.
Lecture 10: MIPS Simulator Today’s topic –SPIM Simulator Readings –Appendix B 1.
MIPS coding. Review Shifting – Shift Left Logical (sll) – Shift Right Logical (srl) – Moves all of the bits to the left/right and fills in gap with 0’s.
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.
CMPUT Computer Organization and Architecture I1 CMPUT229 - Fall 2003 Topic5: Linking José Nelson Amaral.
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.
Intro to SPIM Justin Fiore Nathan Parish. Installing SPIM on Windows Download pcspim.zip from the SPIM website:
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patternson and Hennessy Text.
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.
Exceptions and Interrupts ◆ Breakpoints, arithmetic overflow, traps, and interrupts are all classified as exceptions. ◆ An exception is an event that requires.
CS 312 Computer Architecture & Organization
MIPS Assembly Language Programming
MIPS Assembly Language Programming
Computer Architecture & Operations I
MIPS Assembly Language Programming
MIPS Instruction Set Advantages
Introduction to Lab #1 José Nelson Amaral.
CS 286 Computer Organization and Architecture
ACOE301: Computer Architecture II Labs
MIPS assembly syntax Comments
Assembly Programming using MIPS R3000 CPU
MIPS coding.
Week 5 Computers are like Old Testament gods; lots of rules and no mercy. Joseph Campbell.
Assembler Directives Example program: .data # DATA segment city: .asciiz “Seattle” .align 2 num: .word 2210, 2341, 26, 0x022ec,
MIPS coding.
MIPS function continued
COMS 361 Computer Organization
CS 286 Computer Organization and Architecture
Assembly Programming using MIPS R3000 CPU
MIPS coding.
MIPS Assembly Language Programming Computer Architecture
CS 286 Computer Architecture & Organization
Week 5 Computers are like Old Testament gods; lots of rules and no mercy. Joseph Campbell.
Introduction to SPIM Simulator
PROF. JOHN ABRAHAM UTRGV
Presentation transcript:

SPIM : A MIPS Simulator Archi & Net Lab 이용석

Contents zIntroduction zSPIM Interface zSimulator Usage zMIPS R2000 Assembler Language zProgram Example

Introduction (1/2) zWhat’s SPIM? yA simulator that runs programs for the MIPS R2000/R3000 RISC computers zWhat does SPIM do? yReads and executes MIPS assembly language file immediately yWorks as a debugger yProvides some OS like services

Introduction (2/2) zWhere can we get SPIM?  FTP: ftp.cs.wisc.edu x/pub/spim/spimwin.exe zInstalling SPIM  Just run spimwin.exe and follow the installation procedure

Windows Interface zRegisters window yshows the values of all registers in the MIPS CPU and FPU zText segment window yshows instructions zData segment window yshows the data loaded into the program’s memory and the data of the program’s stack zMessages window yshows PCSpim messages (include error messages)

Simulator Usage zOpening source file yUse File menu or toolbar button zSimulation  Go : Run loaded program  Break : Stop the execution of the program  Single / Multiple Step : Stepping for debugging  Breakpoint : Stop program before it executes a particular instruction  Reload : Reload source file after change it with editor program

MIPS Assembly Layout zProgram Layout. text#code section.globl main#starting point: must be global main: # user program code.data#data section label:.data_type list_of_data #data loc + data type + data.text#code section label: #function label #user functions

MIPS Assembler Directives (1/2) zData Types .word,.half - 32/16 bit integer .byte - 8 bit integer (similar to ‘char’ type in C) .ascii,.asciiz - string (asciiz is null terminated)  Strings are enclosed in double-quotas( ” ) xSpecial characters in strings follow the C convention newline (\n), tab (\t), quote (\”) .double,.float - floating point

MIPS Assembler Directives (2/2) zOther Directives .text - Indicates that following items are stored in the user text segment .data - Indicates that following data items are stored in the data segment .globl sym - Declare that symbol sym is global and can be referenced from other files

SPIM System Calls zSystem Calls (syscall) yOS-like services zMethod yLoad system call code into register $v0 yLoad arguments into registers $a0…$a3 yAfter call, return value is in register $v0 zFrequently used system calls

SPIM Program Example (1/3) zA Simple Program #sample example 'add two numbers’.text # text section.globl main# call main by SPIM main:la $t0, value# load address ‘value’ into $t0 lw $t1, 0($t0)# load word 0(value) into $t1 lw $t2, 4($t0)# load word 4(value) into $t2 add $t3, $t1, $t2# add two numbers into $t3 sw $t3, 8($t0)# store word $t3 into 8($t0).data# data section value:.word 10, 20, 0 # data for addition

SPIM Program Example (2/3) zA Program with System Call #sample example 'system call'.text.globl main main: la $t0, value li $v0, 5 syscall sw $v0, 0($t0) li $v0, 5 syscall sw $v0, 4($t0) lw $t1, 0($t0) lw $t2, 4($t0) add $t3, $t1, $t2 sw $t3, 8($t0) li $v0, 4 la $a0, msg1 syscall li $v0, 1 move $a0, $t3 syscall.data value:.word 0, 0, 0 msg1:.asciiz "Result = "

SPIM Program Example (3/3) zA Program with Procedure Call # sample example ‘swap two numbers’.text.globlmain main: la$a0, array addi$a1, $0, 0 addi$sp, $sp, -4 sw$ra, 0($sp) jalswap lw$ra, 0($sp) addi$sp, $sp, 4 jr$ra.data array:.word 5, 4, 3, 2, 1 #swap(int v[], int k) #{ #int temp; #temp = v[k]; #v[k] = v[k+1]; #v[k+1] = temp; #} swap:add$t1, $a1, $a1 add$t1, $t1, $t1 add$t1, $a0, $t1 lw$t0, 0($t1) lw$t2, 4($t1) sw$t2, 0($t1) sw$t0, 4($t1) jr$ra