Practice 1: Now assume the following code that is slightly different: int PROC1 (int a, int b) { // map k to $s0 int k =

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Practice 1: Now assume the following code that is slightly different: int PROC1 (int a, int b) { // map k to $s0 int k =

Post by answerhappygod »

Practice 1 Now Assume The Following Code That Is Slightly Different Int Proc1 Int A Int B Map K To S0 Int K 1
Practice 1 Now Assume The Following Code That Is Slightly Different Int Proc1 Int A Int B Map K To S0 Int K 1 (114.9 KiB) Viewed 19 times
Practice 1: Now assume the following code that is slightly different: int PROC1 (int a, int b) { // map k to $s0 int k = a + b; return k; // map m to $s0 // map n to $sl // map j to $s2 int m 10; int n 15; int j = PROC1 (n, m); } Implement backup and restore code in PROC1 so that $s0 value is maintained for the caller. Compile and run this sequence and verify: ● The value of $s0 is (10) 10 = (0x000A)hex ● The value of $s1 is (15) 10 = (0x000F)hex The value of $s2 is (25) 10 = (0x0019)hex When ready, copy your MIPS assembly code from emulator and save as a text file. Submit this file on Moodle. Practice 2: Let's compile following C sequence for MIPS and run on the emulator: int multiply (int N, int M) { // map sum and i to $s0 and $s1 int sum = 0; for (int i = 0; i < N; ++i) { sum += M; } return sum; } int main () { // map a, b, and k to $s0, $s1 and $s2. int a = 4; int b = 5; int k = multiply (a, b); } Make sure multiply procedure properly gets backup of $s0 and $s1. Verify that after running this sequence, value c (20) 10 = (0x0014) hex When ready, copy your MIPS assembly code from emulator and save as a text file. Submit this file on Moodle. } int main() {
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply