Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

1. A. a.

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,

CPU time: the cpu time for recur is (287)/2x10^9 = 1.43x10^-7

C. the register that stores the return value is a0, the register that stores the function parameter
n is also a0

D. iter: -O0: Insc:150, CYcC: 287 CPI: 1.91

-O1: Insc:36, CycC:69 CPI: 1.9

Recur: -O0: Insc: 242, CycC: 411 CPI: 1.69

-O1: Insc: 145, CycC: 222 CPI: 1.53

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

- Risc is faster than cisc because it takes simpler instructions

-risc uses less memory than cisc

-risc uses less power to execute instructions than cisc

-risc is cheaper to manufacture than cisc because it takes simpler instructions

ii. RISC: IC: more, CPI: less, cycle time: less

cisc: IC: less, CPI: more, cycle time: more

F. old cpi: 123.3 clock cycle/96.8 IC = 1.27

New cpi: 226 clock cycle/12=18.8


(96.8x1.27)/(18.8 x 12) = 122.93/225.6 so the answer is no.

You might also like