Practice 3: Let’s compile following C sequence for MIPS and run on the emulator: int divide(int N, int M) { // map q and i to $s2 and $s3 int q = 0; int i = N; while(i > 0) { q += 1; i = i - M; } return q; } 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, c, k, and j to $s0, $s1, $s2, $s3, and $s4 int a = 4; int b = 5; int c = 120; int k = multiply(a, b); int j = divide(c, k); } Make sure multiply procedure properly gets backup of $s0 to $s4. Verify that after running this sequence: • value of S0 is (4)10 • value of S1 is (5)10 • value of S2 is (120)10 • value of S3 is (20)10 • value of S4 is (6)10 When ready, copy your MIPS assembly code from emulator and save as a text file.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

Practice 3: Let’s compile following C sequence for MIPS and run on the emulator:

int divide(int N, int M)

{

// map q and i to $s2 and $s3

int q = 0;

int i = N;

while(i > 0)

{

q += 1;

i = i - M;

}

return q;

}

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, c, k, and j to $s0, $s1, $s2, $s3, and $s4

int a = 4;

int b = 5;

int c = 120;

int k = multiply(a, b);

int j = divide(c, k);

}

Make sure multiply procedure properly gets backup of $s0 to $s4. Verify that after running this sequence:

• value of S0 is (4)10

• value of S1 is (5)10

• value of S2 is (120)10

• value of S3 is (20)10

• value of S4 is (6)10

When ready, copy your MIPS assembly code from emulator and save as a text file.

Expert Solution
steps

Step by step

Solved in 5 steps with 2 images

Blurred answer
Knowledge Booster
Assembly Language
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education