* A Tutorial *
2007 CCSC: Central Plains Conference
Pete Sanderson, Otterbein College, PSanderson@otterbein.edu
Ken Vollmar, Missouri State University, KenVollmar@missouristate.edu
MARS is a software simulator for the MIPS assembly language intended for educational use. We will explore the capabilities of MARS release 3.2.1 inthis three part tutorial.
MARS may be downloaded from www.cs.missouristate.edu/MARS.
Part 1 : Basic MARS Use
The example program is Fibonacci.asm to compute everyone’s favorite number sequence.
1. Start MARS from the Start menu or desktop icon.
2. Use the menubar File…Open or the Open icon [pic] to open Fibonacci.asm in the default folder. (All icons have menubar equivalents; theremainder of these steps will use the icon whenever possible.)
3. The provided assembly program is complete. Assemble the program using the icon [pic]
4. Identify the location and values of the program’s initialized data. Use the checkbox to toggle the display format between decimal and hexadecimal [pic].
• The nineteen-element array fibs is initialized to zero, at addresses 0x10010000 …0x10010048.
• The data location size has value 19ten at 0x1001004c.
• The addresses 0x10010050 … 0x1001006c contain null-terminated ASCII strings.
Use the checkbox to toggle the display format between decimal and hexadecimal, [pic].
5. Use the Settings menu to configure the MARS displays. The settings will be retained for the next MARS session.
• The Labels display contains theaddresses of the assembly code statements with a label, but the default is to not show this display. Select the checkbox from the Settings menu. [pic]
• Select your preference for allowing pseudo-instructions (programmer-friendly instruction substitutions and shorthand).
• Select your preference for assembling only one file, or many files together (all the files in the current folder).This feature is useful for subroutines contained in separate files, etc.
• Select the startup display format of addresses and values (decimal or hexadecimal).
6. Locate the Registers display, which shows the 32 common MIPS registers. Other tabs in the Registers display show the floating-point registers (Coproc 1) and status codes (Coproc 0).
7. Use the slider bar to change the run speedto about 10 instructions per second. [pic] This allows us to “watch the action” instead of the assembly program finishing directly.
8. Choose how you will execute the program:
• The [pic] icon runs the program to completion. Using this icon, you should observe the yellow highlight showing the program’s progress and the values of the Fibonacci sequence appearing in the Data Segmentdisplay.
• The [pic] icon resets the program and simulator to initial values. Memory contents are those specified within the program, and register contents are generally zero.
• The [pic] icon is “single-step.” Its complement is [pic], “single-step backwards” (undoes each operation).
9. Observe the output of the program in the Run I/O display window:
The Fibonacci numbers are:1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181
-- program is finished running --
10. Modify the contents of memory. (Modifying a register value is exactly the same.)
• Set a breakpoint at the first instruction of the subroutine which prints results. Use the checkbox at the left of the instruction whose address is 0x00400060 = 4194400ten.
• Reset[pic] and re-run [pic] the program, which stops at the breakpoint.
• Double-click in one of the memory locations containing the computed Fibonacci numbers. The cell will be highlighted and will accept keyboard entry, similar to a spreadsheet. Enter some noticeably different value, and use the Enter key or click outside the cell to indicate that the change is complete. Example: Memory address...