Write a complete MIPS program that implements the same algorithm shown below (in
ID: 3734311 • Letter: W
Question
Write a complete MIPS program that implements the same algorithm shown below (in C): int main() { // Note: I should be able to change // the values of A, B, and C when testing // your code, and get correct output each time! // (i.e. don't just hardwire your output) int A=10; int B=15; int C=6; int Z=0; if(A > B || C < 5) Z = 1; else if( !((A > B) && ((C+1) == 7))) Z = 2; else Z = 3; switch(Z) { case 1: Z = -1; case 2: Z -=-2; case 3: Z -= -3; break; default: Z = 0; break; } } A-C and Z must be integer words in memory, both when the program begins and when the program ends. In between, they can be stored in registers.
- Loops Write a complete MIPS program that implements the algorithm shown below (in C): int main() { int Z=2; int i; i=0; while(1){ if(i>20) break; Z++; i+=2; } do { Z++; } while (Z<100); while(i > 0) { Z--; i--; } I and Z must be integer words in memory.
Explanation / Answer
1.
2.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.