Getting PCSpim and a program to run

 

 


Downloading PCSpim

 

PCSpim is a MIPS R2000/R3000 Simulator, available from

http://www.cs.wisc.edu/~larus/spim.html

 

To run PCspim on a PC under Microsoft Windows (you don’t need to do this if you are in the lab):

download the file http://www.cs.wisc.edu/~larus/SPIM/pcspim.zip,

unzip it, and

run the setup program

 

Reference documentation with application and Appendix A from the text

 

 


Running PCSpim

 

Once installed

 

Start -> Programs -> PCSPIM

 

The first time you run PCSPIM you may have the warning box shown below appear (new versions will say “exception file” instead of “trap file).

 

 

 

Click “Yes”.  You’ll then see a screen like this:

 

 

At the bottom, under “Trap file:” or “Exception file:”, change the drive from “C” to “D”. 

Leave “Allow pseudocode instructions” option checked.  Hit OK.

 

You can return to settings at any time from the PCSpim window by selecting

 

Simulator->Settings

 

 

 

 

Four windows appear in the PCSpim frame: Registers, Text Segment, Data Segment, and Messages

  • Register window: the values of all registers in the MIPS CPU and FPU.
  • Text Segment window: instructions both from your program and the system code that is loaded automatically when PCSpim is running.
  • Data Segment: the data loaded into your program’s memory and the data of the program’s stack.
  • Messages window: for PCSpim messages. This is where error messages appear.

The console also opens. Your input and output to the program will be through the console.

 

 


Opening, Loading and Running a File

 

Download the file simple-spim.asm (right-click and use “Save Target As” to save it somewhere).

 


To open the first file:

File -> Open …

Open  simple-spim.asm” (from wherever you saved it above).

In the Message window, you should see a message “…simple-spim.asm has been successfully loaded”

First, try running the program:

Simulator -> Run        -OR-   (or you can use the  button)

 

You will be asked for the starting address of the program.

Use the address of the first instruction in the Text Segment window.

(this is most likely set already)

 

 

You will be prompted for input on the console window. Your output will be shown on the console window.

 

 

Next, try single-stepping through the program one step at a time.

  1. Simulation -> Reload <filename>
    (don’t use “Reinitialize”)
  2. Then,  F-10 to step through one statement at a time
    You’ll notice that SPIM first executes a few instructions at address 0x00400000 that don’t come from the input file – these set up the environment for the program.  After a few instructions, SPIM will execute “jal main” – this is where your program starts.
  3. Step through the program, trying to understand how it works. Watch how the registers change.  Note that the console will pop up whenever you print something, but you won’t be able to enter any input until the program executes the syscall for “read integer.”

 

 

Stopping Program Execution

 

To stop the execution at any time, you can use

 

Simulation -> Break

 

You will be prompted whether to continue or end execution. (Click on Yes to end)

 

 

When you make changes to the file you are running

 

Simulation -> Reload <filename>

 

to have the updated file loaded into PCSpim

 

 


Quitting PCSpim

 

File -> Exit

 

 


Videos of the loading of a program are available from:

http://users.ece.gatech.edu/~sudha/2030/temp/spim/spim-tutorial.html