Professional Documents
Culture Documents
HW1 Comparch
HW1 Comparch
Iterative:
i. Insc: 652
ii. CysC: 1388
b. Recursive:
i. Insc: 744
ii. Cysc: 1515
Recursion uses more instruction counts and cycle counts to do the same task as iterative.
The big difference between the two is only between the iter function and recur function.
B. recur: CPI: the Cycle count of recur is 411 and Instruction count is 242, so the CPI is 411/242 =
1.69.
CPU time: the cpu time for recur is (411)/2x10^9 = 2.05x10^-7 seconds
Iter: CPI: the Cycle count of iter is 287 and the instruction count is 150, so the cpi is 287/150=
1.91,
C. the register that stores the return value is a0, the register that stores the function parameter
n is also a0
Difference: O1 takes less Instruction Count, cycle count and have less cycles per instruction. O1
also takes less CPU time than O0
E. i. Difference:
- Risc is reduced instruction set computing while cisc is complex instruction set
computing