Anda di halaman 1dari 27

By

Abhilash Oommen Thomas (08MCS003)


Elizabeth Isaac (08MCS010)
Liz Joy (08MCS025)
Prakhya K (08MCS036)
Sujesh P Lal (08MCS054)

1 SCS VIT University 10/04/2009


SPIM
 OBJECTIVE
To familiarize a new tool ‘SPIM’.

 OUTCOME
To understand the working of the Simulator and to code, load and execute
assembly language programs

2 SCS VIT University 10/04/2009


 A software simulator that runs programs written for MIPS R2000/R3000
processors.
 SPIM’s name is just MIPS spelled backwards
 A self-contained system for running MIPS programs

 It is free and wide availability


 simulators can provide a better environment for programming
 Can detect more errors and provide more features than an actual computer
 The MIPS architecture may be an example for a simple, clean RISC machine

3 SCS VIT University 10/04/2009


The MIPS Features
 MIPS -Microprocessor without Interlocked Pipeline Stages

 A RISC instruction set architecture (ISA) developed by MIPS Computer


Systems.

 The early MIPS architectures were 32-bit (generally 32-bit wide registers and
data paths), while later versions were 64-bit.

 One of the more interesting applications of the MIPS architecture is its use in
massive processor count supercomputers.

4 SCS VIT University 10/04/2009


The MIPS Features

 The first commercial MIPS CPU model, the R2000, was announced in 1985

 The R3000 succeeded the R2000 in 1988, adding 32 KB (soon increased to 64


KB) caches for instructions and data, along with cache coherency support for
multiprocessor use

 The R3000A was the processor used in the extremely successful Sony
PlayStation

5 SCS VIT University 10/04/2009


SPIM Installation
 A freely-distributable program that simulates the operation
of the MIPS R2000/R3000 architecture
 Unix
 Linux
 Macintosh OS
 MS Windows

 Installation
 System requirements
 Free Download
 http://www.cs.wisc.edu/larus/pcspim.zip
 http://www.cs.wisc.edu/larus/xspim.tar.gz

6 SCS VIT University 10/04/2009


User Interfaces
 Unix, Linux, Mac OS
 On Unix, Linux, Mac OS the SPIM program provides a simple terminal
interface and a Windowing interface.
 Microsoft Windows
 On Microsoft Windows the SPIM program provides a console interface
and a windows interface

Version
Current version of SPIM is 7.4 (January 2009)

7 SCS VIT University 10/04/2009


Invoking PCSPIM for Windows

 After you have saved the source code, invoke


PCSPIM for Windows with
 Start Menu->Programs->PCSpim forWindows
 PCSPIM for Windows will load and a window that
looks like this will appear:

10/04/2009 SCS VIT University 8


10/04/2009 SCS VIT University 9
To load 'tutorial.s' for the first time, select File->Open... from the
menu bar. A dialog will appear.

Find and select D:\PCSpim tutorial\tutorial.s

 After clicking Open, the window will be populated

10/04/2009 SCS VIT University 10


10/04/2009 SCS VIT University 11
SPIM simulator: registers
PC
HI LO

general-
general-purpose registers

10/04/2009 SCS VIT University 12


SPIM simulator: code
address of
instruction
bit pattern of
instruction

meaning of source
instruction’s code of
bit pattern program

10/04/2009 SCS VIT University 13


SPIM simulator: data
name of
segment

address of word-by
word- by-
-word
first byte of contents of memory
row (16 bytes per row)

10/04/2009 SCS VIT University 14


Any error in your source code

 Click "no".
 Go back and correct your source code using the text editor,
 Then reload the file.

10/04/2009 SCS VIT University 15


 To run the program for the first time, select 'Simulator->Go'.
 A pop-up window will appear asking for a starting address:

 Accept the default address

10/04/2009 SCS VIT University 16


 the entire program will have executed and terminated.
 The console window will pop up, displaying the results.
 The window looks like this:
Making changes and reloading
 In order to debug your program, open a text editor with the
source file and keep PCSPIM open as well.
 After making a change to the code, save the file, but keep
the text editor open.
 Then, select 'Simulator->Clear Registers' from the menu.
 Then select 'Simulator->Reinitialize' from the menu.
 Finally, select 'Simulator->Reload (your path)\tutorial.s'
from the menu.
 At this point test the program again.
Debugging Overview

 If the file does not 'Read' (or assemble) correctly, the


simulator will print some error message to help you find the
problem.
 Even if the file 'Reads', it will not necessarily work
properly in all cases.
 PCSPIM provides the following debugging capabilities
 Register display
 Breakpoints
 Tracing

10/04/2009 SCS VIT University 19


20 SCS VIT University 10/04/2009
21 SCS VIT University 10/04/2009
22 SCS VIT University 10/04/2009
Sample program
#Sum.s

.data
no: .asciiz "Enter the numbers to be added"
result: .asciiz "Result"
.text
main:
la $a0,no
li $v0,4
syscall
li $v0,5
syscall
move $s0,$v0
23 SCS VIT University 10/04/2009
li $v0,5
syscall

move $s1,$v0
add $s3,$s1,$s0

la $a0,result
li $v0,4

syscall
move $a0,$s3

li $v0,1
syscall

li $v0,10
syscall

24 SCS VIT University 10/04/2009


Video Presentation

 SPIM Demo

25 SCS VIT University 10/04/2009


References

 www.cs.wisc.edu
 www.google.com
 www.mips.org
 MIPS Programmers handbook by Erin Farquhar and Philip
Bunce
 MARS: An education oriented MIPS assembly language
simulator

26 SCS VIT University 10/04/2009


THANK YOU!!

27 SCS VIT University 10/04/2009

Anda mungkin juga menyukai