Answered step by step
Verified Expert Solution
Question
1 Approved Answer
3.3 Compile the following code snippet in MIPS assembly using instructions from Table 3.3, with the dynamic mix shown in Table 3.27: Table 3.27 Dynamic
3.3 Compile the following code snippet in MIPS assembly using instructions from Table 3.3, with the dynamic mix shown in Table 3.27: Table 3.27 Dynamic instruction mix Instructions Frequency Cycles Arithmetic/logic Loads Stores Branches (untaken) Branches (taken) Miscellancous 40% 25% 10% 8% 12% 3% S = 0; for (1-0; i 100: i++) S = S + A[i] ; Array Ali] is made of 1004-byte integers stored in increasing memory addresses and A is stored at memory address 1000. You can allocate registers as you wish except for the following restrictions. (a) First assume that no variable (including i) is allocated to register by the compiler across the loop, i.c., all variables are loaded (filled) from and stored (spilled) to memory whenever necessary. Write the code and estimate the execution time given the time taken by each class of instruction in Table 3.27 (b) Second, assume that both S and i are allocated to registers during the entirety of the loop. At first they are loaded in registers and initialized. Then, at the end of the loop the registers are spilled to memory. Other memory values are loaded in register as needed. Write the code and estimate the execution time given the time taken by each class of instruction in Table 3.27 3.3 Compile the following code snippet in MIPS assembly using instructions from Table 3.3, with the dynamic mix shown in Table 3.27: Table 3.27 Dynamic instruction mix Instructions Frequency Cycles Arithmetic/logic Loads Stores Branches (untaken) Branches (taken) Miscellancous 40% 25% 10% 8% 12% 3% S = 0; for (1-0; i 100: i++) S = S + A[i] ; Array Ali] is made of 1004-byte integers stored in increasing memory addresses and A is stored at memory address 1000. You can allocate registers as you wish except for the following restrictions. (a) First assume that no variable (including i) is allocated to register by the compiler across the loop, i.c., all variables are loaded (filled) from and stored (spilled) to memory whenever necessary. Write the code and estimate the execution time given the time taken by each class of instruction in Table 3.27 (b) Second, assume that both S and i are allocated to registers during the entirety of the loop. At first they are loaded in registers and initialized. Then, at the end of the loop the registers are spilled to memory. Other memory values are loaded in register as needed. Write the code and estimate the execution time given the time taken by each class of instruction in Table 3.27
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started