Getting Started with the MARS simulator
Directions for getting started with the MARS simulator for MIPS assembly:
Note: What follows is merely a brief overview on getting started with the MARS simulator. For detailed directions, refer to the MARS tutorial.
-
If you haven't already, download the MARS simulator. On the MARS download page, select the "Download MARS" button.
-
Start up the MARS simulator by running/opening (double-clicking) the file you downloaded, Mars_4_2.jar. It is a Java executable, so should run on any computer that supports Java (i.e. has the Java JRE or JDK).
-
When the MARS simulator starts up, you can either:
- Open an exiting MIPS assembly file by:
-
From the menu bar select File -> Open... and then select the desired assembly program (the desired .asm file) from the file chooser window.
Here are a few example MIPS assembly programs you may download and try: area_triangle.asm, arith_exmpl.asm, sum_1to100.asm.
- Begin creating a new MIPS assembly file by:
-
From the menu bar select File -> New.
Then you can begin typing in MIPS assembly instructions into the Edit window, as desired.
-
When ready, you may begin running/testing the assembly code by:
First assemble the code by selecting Run -> Assembly from the menu bar.
Then run the code using either the Run -> Go option, which will execute the program to completion, or the Run -> Step option, which will execute only one instruction at a time.
You may likewise use the corresponding buttons for Go or Step available under the menu bar (or use the F5 or F7 keys, which correspond to Go and Step. These buttons and key shortcuts are particularly useful for Step, since you need to push/execute Step each time you want to execute the next instruction in the program).
To see what's going on while the program is being executed, look at the registers in the 'Register' window, which is the right-most window in the display. Notice that this displays the current values of all the registers, including the $s and $t registers, and even the program counter (pc).
Note: By default, the register values are shown in hexadecimal. If you would prefer to see their decimal values, in the menu bar, de-select Settings -> Values displayed in hexadecimal.
If you create a new assembly program or make modifications to an existing assembly program, you can save the code to a .asm file using the File -> Save or File -> Save as... options from the menu bar.