Could you help with this problem : After you learnt MIPS assembly language, you
ID: 3635257 • Letter: C
Question
Could you help with this problem :
After you learnt MIPS assembly language, you could understand most codes in other assembly languages. Explain each line of the following assembly language code segment. Write the corresponding C language code and indicate the content of each register with the corresponding variable in C-code.Explanation / Answer
Renaming the registers as variables we get, R1 - r1 R2 - r2 F0 - x F4 - y F2 - z -----------------------code starts here------------ x = r1[0] y = r2[0] x = x*y z = x+z r1 = r1-8 r2 = r2-8 while(r1 != 0){ x = mem(r1+0) y = mem(r2+0) x = x*y z = x+z r1 = r1-8 r2 = r2-8 } ---------------- Tricky part of the question : --> We can't avoid the part of the code outside the while loop because if u observe when the assembly program enters the loop for the first time, even though r1 is zero it will execute the assembly commands. We have to write the same code above the while loop too. That's the tricky part. Check it urself. Reply if you've got any doubts or further clarification. :))
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.