Page 1 of 1

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

Posted: Mon Jun 06, 2022 1:47 pm
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 28 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() {