• No results found

and Debugger

In document Guide to RISC Processors (Page 155-158)

SPIM is a simulator that runs MIPS 2000 programs. SPIM supports various platforms and can be downloaded from the Web. SPIM also contains a simple debugger. In this chapter, we give details on how you can download and use the SPIM simulator. We start with an introduction to the SPIM simulator. The following section gives details about SPIM settings. These settings determine how the simulator loads and runs your programs. We specify the settings you should use in order to run the example MIPS programs given in later chapters. Details about loading and running MIPS assembly language programs are discussed in the next section. This section also presents the debugging facilities provided by SPIM. We conclude the chapter with a summary.

Introduction

This chapter describes the SPIM simulator, which was developed by Professor James Larus when he was at the Computer Science Department of the University of Wisconsin, Madison. This simulator executes the programs written for the MIPS R2000/R3000 pro- cessors. This is a two-in-one product: it contains a simulator to run the MIPS programs as well as a debugger.

SPIM runs on a variety of platforms including UNIX, Linux, Windows, and DOS. In this chapter, we provide details on the Windows version of SPIM called PCSpim. The SPIM simulator can be downloaded from

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

This page also gives information on SPIM documentation. Although SPIM is available

Figure 9.1SPIM windows.

from this site at the time of this writing, use a good search engine to locate the URL if it is not available from this URL. Also, you can check this book’s homepage, which provides a link to the SPIM simulator that is updated periodically.

Figure 9.1 shows the PCSpim interface. As shown in this figure, PCSpim provides a menu bar and a toolbar at the top and a status bar at the bottom of the screen. The middle area displays four windows, as discussed next.

Menu Bar: The menu bar provides the following commands for the simulator op- eration.

File:TheFilemenu allows you select file operations. You can open a MIPS assembly language source file usingopen...or save a log file of the current simulator state. In addition, you can quit PCSpim by selecting the Exit command. Of course, you can also quit PCSpim by closing the window.

Chapter 9 SPIM Simulator and Debugger 151

Simulator: This menu provides several commands to run and debug a pro- gram. We discuss these commands later in this chapter. This menu also allows you to select the simulator settings. When theSettings... command is selected, it opens a setting window to set the simulator settings, which are discussed in the next section.

Windows: This menu allows you to control the presentation and navigation of windows. For example, in Figure 9.1, we have tiled windows to show the four windows: Text Segment, Data Segment, Register, and Messages. In addition, you can also elect to hide or display the toolbar and status bar. The console window pops up when your program needs to read/write data to the terminal. It disappears after the program has terminated. When you want to see your program’s input and output, you can activate this window by selecting the Console window command.

Help: This menu allows you to obtain online help on PCSpim.

Toolbar: The toolbar provides mouse buttons to open and close a MIPS assembly language source file, to run and insert breakpoints, and to get help.

Window Display Section: This section displays four windows: Data Segment, Text Segment, Messages, and Register.

Data Segment Window: This window shows the data and stack contents of your program. Each line consists of an address (in square brackets) and the corresponding contents in hexadecimal notation. If a block of memory con- tains the same constant, an address range is specified as shown on the first line of the Data Segment in Figure 9.1.

Text Segment Window: This window shows the instructions from your pro- gram as well as the system code loaded by PCSpim. The leftmost hex number in square brackets is the address of the instruction. The second hex number is the machine instruction encoding of the instruction. Next to it is the in- struction mnemonic, which is a processor instruction. What you see after the semicolon is the source code line including any comments you have placed. This display is useful to see how the pseudoinstructions of the assembler are translated into the processor instructions. For example, the last line in the Text Segment of Figure 9.1 shows that the pseudoinstruction

li $vi,10

is translated as

ori $2,$0,10

Registers: This window shows the contents of the general and floating-point registers. The contents are displayed in either decimal or hex notation, de- pending on the settings used (discussed in the next section).

Figure 9.2SPIM settings window.

Status Bar: The status bar at the bottom of the PCSpim window presents three pieces of information:

The left area is used to give information about the menu items and toolbar buttons. For example, when the mouse arrow is on the open file icon (first button) on the toolbar, this area displays the “Open an assembly file” message.

The middle area shows the current simulator settings. Simulator settings are described in the next section.

The right area is used to display if the Caps Lock key (CAP), Num Lock key (NUM), and Scroll Lock key (SCRL) are latched down.

In document Guide to RISC Processors (Page 155-158)