MIPS 32 examples and guides
In this repository you will find a beginner’s guide to MIPS programming
Every example used can be run so you can see what the output is.
A
ssembly files use the “.s” extension
The structure is the following:
tag , dest , rs1 , rs2
Where ‘tag’ is the desired instruction (add, li, move, etc.), ‘dest’ is the register where the result of the instruction (if it has one) goes and ‘rs1’ and ‘rs2’ are the two registers involving the operation
We recommend QtSpim:
From the top you can find in orange the reset and open option. It is very important that before every compilation you restore the registers and data.
In blue there are the play, pause and stop controls, used to run the program. Followed by the step by step control (in yellow) which will be very useful when debugging.
At the bottom in green are the registers of our processor, they will be filled with whatever you load them with.
And last but not least, in red, the instructions. This is a visual way to know the current instruction, it is very useful with the step by step control in case the program isn’t working or has a bug.
You can also use MARS. In order to execute it:
java Mars
In Mars you can write your code in de Edit Window, or load your ‘.s’ file, clicking on File>Open and looking for your file. For compiling it click on Run>Assemble or use the shortcut F3. Then you will enter on the Execute window, where you can run it completely or step by step, with the green play button placed in the top.