1. Convert the following C code to appropriate MIPS assembly. Do not use any pse
ID: 3876323 • Letter: 1
Question
1. Convert the following C code to appropriate MIPS assembly. Do not use any pseudoinstructions (i.e., use slt and an appropriate branch instead of bge, blt, etc.) // Do not worry about initializing transactions // Assume register a0 contains the address of this array // at the start of your code. int transactions [10]; int ii int debits 0; int credits0; int transaction; for (i=0i | 0) t credits += transaction; else debits-= transaction ; // NOTE THE MINUS! REintL"Total Credits: %d ", credits); printf("Total Debits: %d ", debits);Explanation / Answer
Answer: C code:
#include "stdio.h"
int main()
{
int transactions[10];
int i;
int debits = 0;
int credits = 0;
int transaction;
for(i = 0; i < 10; i++)
{
transaction = transactions[i];
if(transaction > 0)
{
credits += transaction;
}
else
{
debits -= transaction;
}
}
printf("Total Credits: %d ", credits);
printf("Total Debits: %d ", debits);
}
MIPS code:
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.