In this project, you will learn how to write and simulate MIPS code.
Download QtSpim from http://spimsimulator.sourceforge.net/ and install it to your computer.
There are several tutorials for QtSpim:
https://www.youtube.com/watch?v=r8WcV7AiLXs
https://www.lri.fr/~de/QtSpim-Tutorial.pdf
http://logos.cs.uic.edu/366/notes/MIPS%20Quick%20Tutorial.htm
Short explanation how to write and simulate your code:
- You should use a text editor such as notepad or wordpad and write your MIPS program first.
- Save your program with an extension .asm.
- Open QtSpim
- Load your program by selecting from the menu.
- Run your program.
- Your results will be either in registers or in memory based on your program output.
In this project, you will write and simulate two different programs. You should write commands to explain the purpose of the instruction in your program.
Write a MIPS code for the following C code fragment. In your code, you are not allowed to use multiplication instructions (mult or mul).
Your array size will be 4. Test your code for the test cases given below.
Test 1: A={2,4,6,8}
Test 2: A={8,6,4,2}
Test 3: A={2,2,6,4}
For each test, save the screenshot of the memory before running the code and screenshot of the registers after running the code.
You can define your array in your code as follows:
After la instruction, the address of the first element of array A will be stored in register t1. Then, you can write your code afterwards. You can also define array size in data segment as well.
Write a MIPS code for the following C code fragment. In your code, you are allowed to use multiplication instructions (mult or mul).
Test your programs for the following input values:
Test 1: a=3, b=3
Test 2: a=3, b=5
Test 3: a=5, b=3
For each test, save the screenshot of the registers before running the code and screenshot of the registers after running the code. You should clearly show how you use stack in your code.