Using XSPIM





 

Installing and running


The version of SPIM that we will be using is xspim, which means, you will need to be running the X Window System before you can run xspim.

We shall be using Linux machines. To get the X Window System up and running on Linux machines, use your own .xinitrc file or copy the following .xinitrc file into your home directory. This is a basic no frills .xinitrc file. If you already have X Windows running on your system don't bother about this file.

Ok, now that we have the  X Window System running, we start the simulator, 'xspim'. To do this type in the following command in a terminal window.

            xspim

NOTE: xspim is located under /p/bin and should be in your PATH. The syntax for setting your path depends on the shell you are using. To find out which shell you are running, type the command finger "yourusername" such as "finger scott" and look at the argument for "Shell:"

For bash shell:
export PATH=$PATH:/p/bin

For tcsh or csh:
set PATH = ($PATH /p/bin)

These commands can either be typed at the terminal each time you login, or you can add it to your .bashrc for bash shell or .cshrc for csh or tcsh so that each time you login, the PATH is already set. The $PATH means to keep the existing PATH and then append it with the other directories listed.
 

SPIM starts up and you should see the following screen:
The SPIM window
 
 

for more info on XSPIM see the spim manual
 

The XSPIM GUI


Let us see what the different sections in the xspim display represent,

          [0x00400000]    0x8fa40000    lw $4, 0(29)        ;102: lw $a0, 0($sp)

        The first number on the line, in the square brackets, is the hexadecimal memory address of the instruction. The second number is the instruction's numerical encoding, again displayed as a hexadecimal number. The third item is the instruction's mnemonic description. Everything following the semicoln is the actual line from our assembly file that produced the instruction. The number 102 is the line number in that file. Sometimes there is nothing on the line after the semicolon. This means that the instruction was produced by SPIM as part of translating a pseudo-instruction.


 

Loading programs


Here are some small programs that you can try out in spim:
 

  1. Largest of n numbers    This program accepts numbers from the user using the spim console window and finds the largest of the given numbers. The largest number is then displayed on the console window. Entering a 0 signifies the end of the input list of numbers.


To load a program into spim, click on the load button.

In the popup window type in the name of the file you want to load.

Click on assembly file to load the file into spim.

Check the bottom messages panel to check if any errors occured during the load. Spim parses the assembly file and checks for error during load, so this is a good time to see if our program has no syntax and typo errors.
 

Running programs


To run the program click on the run button.

You will get a prompt window with

Leave the default values in the inputboxes for now and click on Ok
 

Program I/O - SPIM Console


A SPIM Console window is a different window from the spim simulator window. This is where user interaction with the program occurs.
For example if the program is written such that it requires some input from the user like,

Enter a number :

This message is displayed in the spim console window, to input a number, enter a number in the window and press <return>
 

The spim console is also the place where output messages are displayed, so if we use a syscall that prints out a message or some data it will appear in the spim console window.
 

Reloading programs


Before you reload the same program or load another program it is a good practise to clear the memory and registers.

Then click on  reload | assembly file to reload the program you had previously loaded. This is useful when you have made some changes to your program and want to re-run it.
 

Clearing memory / registers

To clear registers alone click on  clear | registers

To clear memory and registers click on clear | memory & registers
 
 


Last Modified: 18/01/2006
by Madhavi Krishnan, (madhavi@cs.utexas.edu)