EE 4426 Written Assignment No. 1 Due: 2/05/2018 in Class Your Name: Bengal ID (l
ID: 2267662 • Letter: E
Question
EE 4426 Written Assignment No. 1 Due: 2/05/2018 in Class Your Name: Bengal ID (last S digits):- Note: You must show all your work in addition to your answers to receive full credit. The full score is 100 points. Submissions deemed identical by the course instructor will receive zero points. See the EE 4426 syllabus for late submission policy 0. Complete the following: a. [2 points] Print a copy of this Assignment as your submission cover page. b. [2 points Use letter-size paper (without holes) for each of your pages. c. [1 point] Write (or print) your name and Bengal ID clearly. 1. [15 points) Translate the following high-level statement into MIPS instructions: Variables x, y, z, q are in registers Ss1, Ss2, Ss3, $s4. Use StO and $t1 as temporary registers 2. 140 points) Translate the following statements using only these MIPS instructions: li, lw, sw, add, addi, bne. Use "loop" and "halt" as the instruction labels. You must use # to comment each MIPS instruction. int A[1001. B[1001; for (i1; ik100; i++) Ali] = A[i-1] + B[i]: Assume the base addresses of All is in $a0, and for BI1 it is Sal 3. Computer A has an overall CPI of 1.3, and runs at a clock rate of 600 MHz. Computer B has a CPl of 2.5 and runs at a clock rate of 750 Mhz. We have a particular program we wish to run. When compiled for computer A, this program has exactly 100,000 instructions. How many instructions would the program need to have when compiled for Computer B, in order for the two computers to have exactly the same execution time for this program we wish to run? Answer the following questions: a. [10 points] Find the CPU time for computer A for running the particular given program. b. 10 points] Find the CPU time for computer B for running the particular given program. c. [10 points] Find the number of instructions when this program is compiled for Computer B.Explanation / Answer
Answer :- 1) x = x + y + z - q, the MIPS equivalent code is-
add $t0, $s1, $s2 #add x and y and keep in $t0
sub $t1, $s3, $s4 #subtract z and q and keep in $t1
add $s1, $t0, $t1 #finally add $t0 and $t1 and keep result in $s1 i.e. in x.
Answer :- 2) The equivalent MIPS code is-
li $t0, 1 #load value 1 in $t0
li $t1, 0 #load zero in $t1
li $t6, 100 #load 100 in $t6
add $t1, $t1, $a1 #copy array A address to $t1
li $t2, 0 #load zero in $t2
add $t2, $t2, $a2 #copy array B address to $t2
loop : #label name
add $t3, $t1, 4 #$t3 = $t1 + 4 , same as A[i]
add $t2, $t2, 4 #$t2 = $t2 + 4, same as B[i]
lw $t4, ($t1) #get value of A[i-1]
lw $t5, ($t2) #get value of B[i]
add $t4, $t4, $t5 #$t4 = A[i-1] + B[i]
sw $t4, ($t3) #A[i] = A[i-1] + B[i]
add $t1, $t1, 4 #get address of next element of array A
add $t2, $t2, 4 #get address of next element of array B
add $t0, $t0, 1 #increase the counter by 1
bne $t0, $t6, LoopArray # if counter is not equal to 100, goto label loop
halt : #label name showing end of programme
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.