Â
1.Goal:
In hw1, students will learn how to write MIPS code, and know the difference between assembly and high-level languages. In order to test the correctness of program, students should use a MIPS simulator –MARS to simulate the programs.
Â
2.Download and Using MARS:
- Download and installation:
1.Download MARS from the page:Â http://courses.missouristate.edu/KenVollmar/MARS/
2.Download the version chosen by yourself, and install it
Â
- Steps for running a MIPS code on MARS:
1.File ->New
2.Write MIPS code
3.Run -> Assemble (F3)
4.Run -> Go (F5)
Â
- HW Description:
A. Factorial
The attached files factorial.c and factorial.s are modified from the example given in textbook for computing n!. In this part, please execute factorial.s on MIPS simulator MARSfor practice.
Â
B. Prime number
Read an number from standard input, and judge if it’s a prime number or not. If it is a prime number, then print ”It’s a
prime” on standard output. Otherwise, print “It’s not a prime”.
(Hint: DIV instruction calculates both quotient and remainder )
Â
C. Draw a diamond
Input a number n, draw a diamond with the length of its diagonal line equal to 2n-1. The following picture is an example.
Â
Â
Â
D. Fibonacci sequence
Read a number from standard input. Output the n-th item of Fibonacci sequence. Students are required to use recursive function to solve this task.
Â
Â
Â
- Notes
- For every task, the corresponding implement in C is provided.
Â
- There’s no strict regulation of input and output format string, but try to be as clear as you can. You can follow the format in reference .c files.
Â
- Late submission will have 20% penalty per day. The submission will no longer be accepted three days after deadline.
Â
- Here’s the document of MIPS instruction set. https://s3-eu-west-1.amazonaws.com/downloadsmips/documents/MD00565-2B-MIPS32-QRC-01.01.pdf
Â
- For all the tasks, test cases and results will not overflow 32-bit registers.
Â
- Any assignment work by fraud will get a zero point.
Â
- The files you should hand in include:
- s
- s
- s
Please compress these files into one zip file, and name your zip file as HW1_$studentID.zip (For example, HW1_309551092.zip).
Â
Â
Â




