Starting from:

$30

MIPS HW1- MIPS Programming Solved

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: 

A.   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 

 

B.   Steps for running a MIPS code on MARS: 

1.File ->New  

2.Write MIPS code 

3.Run -> Assemble (F3) 

4.Run -> Go (F5) 

 

 

 

 

 

 

3. 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 (40%)
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. 

 

 

More products