#  PCSpim Help Index

Commands
	File menu
	Simulator menu
	Window menu
	Help menu

Notes
	Load failure
	Changes from SPIMSAL and the previous Windows version of SPIM
	Command line processing
	Error handling in PCSpim

#K $ File menu commands

The File menu offers the following commands:

Open	Opens an assembly file, loads, and assembles it.	
Save Log	Saves a text file containing status information for the simulator.	
Exit	Exits PCSpim.	

#K $ Simulator menu commands

The Simulator menu offers the following commands:

Clear Registers	Sets the values of all registers to zero (0x00000000).	
Reinitialize	Clears the registers and the memory, and restarts the simulation engine.	
Reload	Reinitializes the simulator, and reloads the current file.	
Go	Runs the current program.	
Break/Continue	If running, pauses execution.  If paused, continues execution.	
Single Step	Executes a single instruction.	
Multiple Step...	Executes a user-specified number of instructions.	
Breakpoints...	Displays the Breakpoint dialog box.	
Set Value...	Displays the Set Value dialog box.	
Display symbol table	Displays the simulator symbol table in the message window.	
Settings...	Displays the Settings dialog box.	

#Window menu commands

The Window menu offers the following commands, which enable you to arrange the windows in PCSpim.

Tile	Arranges windows in non-overlapped tiles.	
1 Messages	Displays the Messages window	
2 Text SegmentDisplays the Text Segment window	
3 Data SegmentDisplays the Data Segment window	
4 RegistersDisplays the Registers window	
5 ConsoleDisplays the Console window	
Clear ConsoleClears all text from the console window.	
ToolbarHides or shows the toolbar	
StatusbarHides or shows the statusbar	

#Help menu commands

The Help menu offers the following commands, which assist you with this application: 

Help Topics	Offers you an index to topics on which you can get help.	
About	Displays the version number of this application.	

#K K$ Open command (File menu)

Use this command to open an assembly file.  If simulator settings are not correct for the file, and it fails to load, PCSpim will provide you an opportunity to change settings and automatically reload the file.

Shortcuts
Toolbar:	{bmc FileOpen.bmp}
Keys:	CTRL+O

#File Open dialog box

The following options allow you to specify which file to open:
File Name
Type or select the filename you want to open.  This box lists files with the extension you select in the List Files of Type box. 
List Files of Type
Select the type of file you want to open:
Assembly files (*.s or *.asm)
All other files (*.*)
Drives
Select the drive in which PCSpim stores the file that you want to open. 
Directories
Select the directory in which PCSpim stores the file that you want to open.

#K $ Save Log File command (File menu)

Use this command to save a log file of the current simulator state.  Selecting this command will produce a dialog box allowing you to specify what should be included in the log file.  It will then display the File Save As dialog box to prompt you for a filename for the log file.

Shortcuts
Toolbar:	{bmc FileSaveLog.bmp}
Keys:	CTRL+S

#File Save As dialog box

The following options allow you to specify the name and location of the file you're about to save:

File Name
Type a new filename to save a document with a different name.
Drives
Select the drive in which you want to store the document.
Directories
Select the directory in which you want to store the document.

#K $ Exit command (File menu)

Use this command to end your PCSpim session.  You can also use the Close command on the application Control menu.  If running a program, PCSpim prompts you to inform you that a program is running, and to ask if you would like to terminate it before exiting.

Shortcuts
Mouse:	Double-click the application's Control menu button.
Keys:	ALT+F4

#KK$ Clear Registers command (Simulator menu)

Use this command to set the values in all registers to zero (0x00000000).

#K$ Reinitialize command (Simulator menu)

Use this command to clear the registers and the memory, and reinitialize the simulation engine.  Often, you will want to do a Reload instead.

#K$ Reload command (Simulator menu)

Use this command to reload the current file.  Reloading reinitializes the entire simulator, clears all memory and registers, and loads and assembles the current file.

This command can be useful after making changes to your assembly source, outside of PCSpim.

#K$ Go command (Simulator menu)

Use this command to run your program, after successfully loading a file, and setting any necessary breakpoints.  PCSpim will prompt you for a starting address.  The starting address will default to the address of the _start label, which is usually defined in the trap handler file.  Your programs need only define main, and do a simple jr $31 to return from main.

#KKK$ Break/Continue command (Simulator menu)

If the simulator is currently running a program, selecting this menu item will cause PCSpim to ask you if you’d like to pause execution at the current instruction.  If you choose yes, all status information will be updated, and execution will be halted.

Once in this Break mode, this menu item becomes Continue.  PCSpim will resume execution at the previous point.

This command can be useful for stopping run-away programs that are stuck in infinite loops.

#KK$ Single Step command (Simulator menu)

Use this command to execute a single instruction in your program.  This can be useful in debugging your code, especially after using the Break command, or setting a breakpoint in your code.  After executing the instruction, PCSpim will update all status information, and return to Break mode.

#KK$ Multiple Step command (Simulator menu)

Use this command to execute multiple instructions at a time.  Selecting this command will prompt you to input the number of instructions to execute.  After executing the specified number of instructions, PCSpim will update all status information, and place the program in Break mode.

#K$ Breakpoints command (Simulator menu)

Use this command to display the Breakpoints dialog box, which will allow you to set breakpoints in your code.

#KKKKK$ Set Value command (Simulator menu)

Use this command to display the Set Value dialog box, which will allow you to modify the contents of registers and memory locations.

#KKK$ Display Symbol Table command (Simulator menu)

This command will cause PCSpim to display the contents of the simulator’s internal symbol table (symbols such as main: and _start:) in the Messages window.

#K$ Settings command (Simulator menu)

Use this command to display the Settings dialog box, which will allow you to modify the simulator configuration, as well as user interface options.

#K $ Next command (Window menu)

Use this command to bring the next window in window stack to the top.

#K $ Previous command (Window menu)

Use this command to bring the previous window in the window stack to the top.

#K $ Toolbar command (Window menu)

Use this command to display and hide the Toolbar, which includes buttons for some of the most common commands in PCSpim, such as File Open.  A check mark appears next to the menu item when the Toolbar is displayed.

See Toolbar for help on using the toolbar.

#K $ Toolbar
{bml Toolbar.bmp}

The toolbar is displayed across the top of the application window, below the menu bar.  The toolbar provides quick mouse access to many tools used in PCSpim,

To hide or display the Toolbar, choose Toolbar from the Window menu (ALT, W, B).

Click	To
{bmc FileOpen.bmp}	Open an existing document.  PCSpim displays the Open dialog box, in which you can locate and open the desired file.

{bmc FileSaveLog.bmp}	Use this command to save a log file of the current simulator state.

{bmc FilePrint.bmp}	Print the current state of the simulator.  This contains the same information as in the log file.

{bmc FilePrintPreview.bmp}	Print preview.  See what the printed simulator state will look like.

{bmc SimulatorGo.bmp}	Run the loaded program.  It prompts for a starting address.

{bmc SimulatorBreakpoint.bmp}	Open the Breakpoints dialog box.  Allows stopping on a specified instruction in memory.

{bmc HelpAbout.bmp}	View the version information for PCSpim.

{bmc HelpContext.bmp}	Context-sensitive help.  Click this, then click on anything in PCSpim to get help on that item.

#K $Status Bar command (Window menu)

Use this command to display and hide the Status Bar, which describes the action to be executed by the selected menu item or depressed toolbar button, and keyboard latch state.  A check mark appears next to the menu item when the Status Bar is displayed.

See Status Bar for help on using the status bar.

#K $Status Bar
{bml StatusBar.bmp}

The status bar is displayed at the bottom of the PCSpim window.  To display or hide the status bar, use the Status Bar command in the Window menu.

The left area of the status bar describes actions of menu items as you use the arrow keys to navigate through menus.  This area similarly shows messages that describe the actions of toolbar buttons as you depress them, before releasing them.  If after viewing the description of the toolbar button command you wish not to execute the command, then release the mouse button while the pointer is off the toolbar button.

The middle area of the status bar indicates current simulator settings.  Each of the displayed values corresponds to one of the settings in the Settings dialog box

The right areas of the status bar indicate which of the following keys are latched down:

Indicator	Description
CAP	The Caps Lock key is latched down.
NUM	The Num Lock key is latched down.
SCRL	The Scroll Lock key is latched down.

#Cascade command (Window menu)

Use this command to arrange multiple opened windows in an overlapped fashion. 

#Tile command (Window menu)

Use this command to arrange multiple opened windows in an non-overlapped fashion.

#Arrange Icons command (Window menu)

Use this command to arrange the icons for the minimized windows.

#KK$ Clear Console command (Window menu)

Use this command to clear the text from the console window.

This can be useful when running a program multiple times.

#Help Topics command (Help menu)

Use this command to display the opening screen of Help.  From the opening screen, you can jump to step-by-step instructions for using PCSpim and various types of reference information.  

Once you open Help, you can click the Contents button whenever you want to return to the opening screen.

#About command (Help menu)

Use this command to display the copyright notice and version number of your copy of PCSpim.

#$Context Help command 
{bml HelpContext.bmp}

Use the Context Help command to obtain help on some portion of PCSpim.  When you choose the Toolbar's Context Help button, the mouse pointer will change to an arrow and question mark.  Then click somewhere in the PCSpim window, such as another Toolbar button.  The Help topic will be shown for the item you clicked.

Shortcut
Keys:	SHIFT+F1

#No Help Available

No help is available for this area of the window.

# No Help Available

No help is available for this topic.

# Breakpoints dialog box

This dialog box allows you to set breakpoints in your code.

Any valid label or address can be entered here.  Addresses can be entered in any number base (decimal, hexadecimal, and octal).

To set a breakpoint, find the label or address you would like to break at, enter it into the address field, and click Add.

# Settings dialog box

This dialog box allows you to modify the settings for PCSpim.

Display:
	General registers in hexadecimal
	Floating point registers in hexadecimal

Execution:
	Bare machine
	Allow pseudo instructions
Enable delayed branches
Enable delayed loads 
	Load trap file
	Trap file
	Mapped I/O
	Quiet

#KKKKK$ Set Value dialog box

This dialog box allows you to change the value of any WORD in memory or any register.

You can input addresses in any number base (decimal, hexadecimal, and octal).  PCSpim will set the WORD to the value you specify.

Registers can be specified in two different ways.  You can refer to the register number ($31, $1), or the register name ($t1, $sp).  You can also use the $ prefix, or the r prefix to specify that you are referring to a register.  Alternatively, if you are using the register name, you may omit the prefix entirely.

So, all of the below are valid register specifications:
	$1, $t1, r1, rt1, t1

Also, for your reference, here is a list of all valid register names
r0, at, v0, v1, a0, a1, a2, a3,
t0, t1, t2, t3, t4, t5, t6, t7, t8, t9
s0, s1, s2, s3, s4, s5, s6, s7,
k0, k1, gp, sp, s8, ra

#K$ Run dialog box

This dialog box allows you to enter a starting address before beginning execution of your program.  You can enter the starting address in any base you feel comfortable with, though hexadecimal is recommended.

PCSpim will provide a default starting address for you.  It uses the address of the _start symbol, which is usually defined by the trap handler file.  When using the default trap.handler that ships with PCSpim, you need only define the symbol main as a starting point for your program.  To end your program, call syscall(10), or simply jr $31 from your main.

#KK$ Multiple Step dialog box

This dialog box allows you to enter the number of instructions you would like to execute in step-wise fashion.  Upon choosing OK, PCSpim will execute the specified number of instructions, and return to Break mode.

#KK$ Load Failure

PCSpim will fail to load a file completely if the final line of the file does not end with a blank line.  The simulator will tell you that there was a syntax error in the file, and fail to load and assemble the file.

This is a known bug, and may be fixed in a future release of the simulator.  As a workaround for now, if you are getting unexplainable syntax error message, check that you have at least one blank line at the end of your source.

# Breakpoints

Breakpoints are markers that the simulator uses to know where you would like to pause the program.

Breakpoints can be very useful in debugging a program.  If you are having problems with a piece of code, set a breakpoint at the beginning, and step through the code, watching how the values in memory and the registers change.

# Changes from SPIMSAL and the previous Windows version of SPIM

The previous Windows version of SPIM was based on a SPIM spin-off called SPIMSAL.  SPIMSAL supports a slightly higher level version of MIPS assembly, called SAL.  SAL provides extra pseudo instructions that allow the user to print strings to the screen, read strings from the user, and a variety of other high-level operations.

PCSpim does not support the SAL extensions to the core SPIM functionality.  If you would like to use the old Windows version which does support SAL, please see ftp://ftp.cs.wisc.edu/pub/spim/OldVersions.

# General registers in hexadecimal

If selected, PCSpim will display the general-purpose registers in hexadecimal, rather than decimal.

# Floating point register in hexadecimal

If selected, PCSpim will display the floating-point registers in hexadecimal, rather than decimal.

# Bare machine

If selected, PCSpim will run the simulation engine in bare machine mode.  Many pseudo instructions are not available in bare machine mode.

# Allow pseudo instructions

If selected, PCSpim will allow pseudo instructions in the instruction stream.

# Load trap file

If selected, PCSpim will load the trap handler specified when the simulator is initialized.

# Mapped I/O

If selected, PCSpim will enable mapped I/O support in the simulator.  Without this, programs are unable to perform kernel-mode I/O.

# Quiet

If selected, PCSpim will avoid printing many diagnostic messages that can be helpful in certain debugging situations.

# Trap File

The trap file is an assembly file that provides some basic services, such as exception handling and reporting.  The standard trap file also provides a _start label for you, allowing you to define your program using a main, as in C programming.

The default trap file that ships with PCSpim is named trap.handler, or trap.han, depending on whether your system supports long filenames.

Most users will never have to modify this setting.

# Show Window

This command displays the specified window (Message, Text Segment, Data Segment, Registers, and Console), and brings it to the top for viewing.

#Command line processing

PCSpim supports a rich command line argument format.  You can control core simulator settings, and specify a file to be loaded automatically.  The command line options available are:
-bare/-asm
-trap/-notrap
-trap_file <file>
-delayed-loads
-delayed-branches
-quiet/-noquiet
-mapped_io/nomapped_io
-file <file> <args>

Note that the -file <file> argument, if specified, must come last.  Anything after the -file <file> option will be considered run-time arguments, and will be saved for the first time the program is executed.

#Error handling in PCSpim

If a fatal error occurs in the core simulator code while running one of your programs, PCSpim will prompt you with a message box, asking if you’d like to continue.  It is recommended that you choose “No,” which will exit PCSpim.  You choose “Yes” entirely at your own risk.