Mars Introduction

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

Mars introduction

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 in this 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 everyones favorite number sequence.
1. Start MARS from the Start menu or desktop icon.
2. Use the menubar FileOpen or the Open icon
to open Fibonacci.asm in the default
folder. (All icons have menubar equivalents; the remainder of these steps will use the icon
whenever possible.)
3. The provided assembly program is complete. Assemble the program using the icon
4. Identify the location and values of the programs initialized data. Use the checkbox to toggle
the display format between decimal and hexadecimal
.
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,
.
5. Use the Settings menu to configure the MARS displays. The settings will be retained for the
next MARS session.
The Labels display contains the addresses of the assembly code statements with a label,
but the default is to not show this display. Select the checkbox from the Settings menu.

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 speed to about 10 instructions per second.
This allows us to watch the action instead of the assembly
program finishing directly.

8. Choose how you will execute the program:

The
icon runs the program to completion. Using this icon, you should observe the
yellow highlight showing the programs progress and the values of the Fibonacci
sequence appearing in the Data Segment display.

The
icon resets the program and simulator to initial values. Memory contents are
those specified within the program, and register contents are generally zero.

The
icon is single-step. Its complement is
each operation).

, single-step backwards (undoes

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
and re-run
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 0x10010020 =
268501024 ten presently contains data 0x00000022 = 34 ten.

Click
to continue from the breakpoint. The program output includes your entered
value instead of the computed Fibonacci number.

You might also like