Docsity

PCSpim Simulator Settings: Customizing the MIPS Machine Environment, Assignments of Electrical and Electronics Engineering

Toggle sidebar
bg1
When selected, PCSpim for Windows will record the position of its windows when you exit, and restore
them to the same location the next time you run PCSpim.
•Bare machine
When selected, you can simulate a bare MIPS machine without pseudoinstructions or the additional
addressing modes provided by the assembler.
•Allow pseudo instructions
If this setting is selected, pseudoinstructions are allowed in your program; otherwise, if the setting is not
selected, they are not allowed.
•Load trap file
If this setting is selected, the standard exception handler and start-up code is loaded. When an exception
occurs, SPIM jumps to location 80000080hex, which must contain code to service the exception. In
addition, the trap handler contains start-up code that invokes the routine main. Without the start-up rou-
tine, SPIM begins execution at the instruction labeled __start. The default trap file comes with PCSpim,
but you can choose another using Browse button.
•Mapped I/O
If this setting is selected, the memory-mapped I/O facility is enabled. Programs that use SPIM syscalls to
read from the terminal cannot also use memory-mapped I/O.
•Quiet
When this setting is enabled, PCSpim does not print a message at exceptions; otherwise, a message is
printed when an exception occurs.
pf3
pf4
pf5

Partial preview of the text

Download PCSpim Simulator Settings: Customizing the MIPS Machine Environment and more Assignments Electrical and Electronics Engineering in PDF only on Docsity!

When selected, PCSpim for Windows will record the position of its windows when you exit, and restore them to the same location the next time you run PCSpim.

• Bare machine

When selected, you can simulate a bare MIPS machine without pseudoinstructions or the additional addressing modes provided by the assembler.

• Allow pseudo instructions

If this setting is selected, pseudoinstructions are allowed in your program; otherwise, if the setting is not selected, they are not allowed.

• Load trap file

If this setting is selected, the standard exception handler and start-up code is loaded. When an exception occurs, SPIM jumps to location 80000080hex, which must contain code to service the exception. In addition, the trap handler contains start-up code that invokes the routine main. Without the start-up rou- tine, SPIM begins execution at the instruction labeled __start. The default trap file comes with PCSpim, but you can choose another using Browse button.

• Mapped I/O

If this setting is selected, the memory-mapped I/O facility is enabled. Programs that use SPIM syscalls to read from the terminal cannot also use memory-mapped I/O.

• Quiet

When this setting is enabled, PCSpim does not print a message at exceptions; otherwise, a message is printed when an exception occurs.

PCSpim performs other functions that are occasionally useful. When you are more comfortable with PCSpim, you should look at the description in the online help to see what they do and how they can save you time and effort. You can view the online help available with the simulator by selecting Help->Help_topics from the menu bar.

Simulator Setting

PCSpim has a graphical interface to view the current setting of the simulator (see FigureA.2). When you start PCSpim, you do not have to enter with any command line parameters. However, you should check your simulator settings either on PCSpim’s status bar or the simulator setting dialog box before you load your program. To view or change PCSpim settings in the simulator setting dialog box, select _Simulator-

Settings_ from the menu bar.

It is very important to set the simulator in the correct setting for your program. PCSpim determines how to load and how your program executes from these settings, so an incorrect setting may cause errors when you run your program. If the simulator setting is incorrect and the program is unable to load correctly, PCSpim allows you to change the simulator settings and reload your program. If you want to change PCSpim settings after you load your program, you should reload your program by selecting _Simulator-

Reload_ from the menu bar.

The following paragraphs describes the operation of each of the settings in the simulator setting dialog box shown in Figure A.2. Most of the functions are similar to SPIM, its counterparts in the terminal interface version without the graphical interface.

• Display

You can select to view the register contents in decimal or hexidecimal notation. If the check boxes for general registers or floating point registers are selected, a check mark will appear and the register con- tents will be displayed in hexidecimal notation.

• Save window positions

Figure A.2. PCSpim simulator setting dialog box

-asm Simulate the virtual MIPS machine provided by the assembler. This is the default.

-pseudo Allow the input assembly code to contain pseudoinstructions. This is the default.

-nopseudo Do not allow pseudoinstructions in the input assembly code.

-notrap Do not load the standard exception handler and start-up code. This exception handler handles exceptions. When an exception occurs, SPIM jumps to location 80000080hex, which must contain code to service the exception. In addition, this file contains start- up code that invokes the routine main. Without the start-up routine, SPIM begins exe- cution at the instruction labeled __start.

-trap Load the standard exception handler and start-up code. This is the default.

-noquiet Print a message when an exception occurs. This is the default.

-quiet Do not print a message at exceptions.

-nomapped_io Disable the memory-mapped I/O facility. This is the default.

-mapped_io Enable the memory-mapped I/O facility. Programs that use SPIM syscalls to read from the terminal cannot also use memory-mapped I/O.

-file Load and execute the assembly code in the file.

-execute Load and execute the code in the MIPS executable file a.out. This command is only available when SPIM runs on a system containing a MIPS processor.

-s size Sets the initial size of memory segment seg to be size bytes. The memory segments are named:text, data, stack, ktext, and kdata. The text segment contains instructions from a program. The data segment holds the program’s data. The stack segment holds its runtime stack. In addition to running a program, SPIM also executes system code that handles interrupts and exceptions. This code resides in a separate part of the address space called the kernel. The ktext segment holds this code’s instructions, and kdata holds its data. There is no kstack segment since the system code uses the same stack as the program. For example, the pair of arguments -sdata 2000000 starts the user data segment at 2,000,000 bytes.

-l size Sets the limit on how large memory segment seg can grow to be size bytes. The mem- ory segments that can grow are data, stack, and kdata.

Loading and Running a Program

Let’s see how to load and run a program. The first thing to do is to select the open file icon from the toolbar. Alternatively, you can select from the menu bar: File->Open. A file open dialog box will appear for you to select the appropriate assembly file. Select the appropriate assembly file and click on the button labeled Open in the dialog box. If simulator settings are not correct for the file, and it fails to load, PCSpim will provide you an opportunity to change simulator settings and automatically reload the file.

If you change your mind, click on the button labeled Cancel , and PCSpim removes the dialog box. When you load an assembly file, PCSpim removes dialog box, then loads your program and redraws the screen to display its instructions and data. If you have not done so, change the view of the four display win- dows to a tiled format by selecting from the menu bar: Windows->Tile. You should be able to see the pro- gram in the Text segment window display.

Each instruction in the Text segment window display is shown on a line that looks like

• The Status bar section is at the bottom of the application window. The status bar provides information

and the current settings of the simulator.

SPIM Command-Line Options

The Windows version of SPIM accepts the following command-line options:

-bare Simulate a bare MIPS machine without pseudoinstructions or the additional address- ing modes provided by the assembler. Implies quiet.

Figure A.1. PCSpim’s window interface