1.
a. Write a MIPS assembly program that reads an integer n (2 < = n < = 30) . The i'th Fibonacci number is defined as Fib(i) = Fib(i-1) + Fib(i-2) for i=2, 3, ... n. Assume Fib(0) = 0 and Fib(1) = 1. The program must use recursion and may not explicitly store Fib(i) in memory. It should only print the final value of Fib(n). (p.s. please use system call to read in integer n and output the answer to the console window.)
b. Run your program using the SPIM simulator to verify that it works correctly. Use the trace option of SPIM to record the instructions that are executed by your program. List the top ten instructions that are executed the most, together with their percentages of occurrence.
c.
Suppose the CPI of the instructions in the MIPS processor is as follows:
注意事項 1. 繳交日期 : 11 / 02 星期二 上午10點前 2. 繳交方式及內容 : 請上傳至140.114.75.163 cs4100/cs4100 port:21 金老師的班級請進入CTking資料夾, 黃老師的班級請進入TTHuang資料夾,進入後請以學號(ex :
924317)建立自己的資料夾, 然後將檔案上傳至此資料夾 . 須繳交兩個檔案 , 一個為a小題的assembly code(請以"Fib.asm"命名) ,
Instruction
Average CPI (clock cycles)
Arithmetic/logic
1.0
Data transfer
1.4
Conditional branch
1.7
Jump
1.2