Question: Please Convert the Following C code to MIPS Assembly(SPIM) Please Convert the following C code to MIPS Assembly (SPIM). PLEASE MAKE SURE IT IS ACCEPTABLE

Please Convert the Following C code to MIPS Assembly(SPIM)

Please Convert the Following C code to MIPS Assembly(SPIM) Please Convert the

following C code to MIPS Assembly (SPIM). PLEASE MAKE SURE IT ISACCEPTABLE BY SPIM, IF IT IS NOT ACCEPTABLE BY SPIM I WILL

Please Convert the following C code to MIPS Assembly (SPIM). PLEASE MAKE SURE IT IS ACCEPTABLE BY SPIM, IF IT IS NOT ACCEPTABLE BY SPIM I WILL NOT UPVOTE THE ANSWER. Also, please post screenshots of your code and don't paste the text in your answer. #include #include // leaf function - convert decimal to binary in string void toBinary (int num, char strNum[]) int i; for (i7: i-0 i--)t / index 7 is the LSB (bit-0) int remnum&0x01: // retrieve remainder num -num >> 1; // shift right by 1 bit (divide by 2) strNumi-'0' + rem; // ascii '0' is decimal 48, '1' is 49 // non-leaf function - convert decimal (negative) to 2's complement in string void twosComplement (int num, char strNum[]) int i, absolute, carry; absolute - abs (num) toBinary (absolute, strNum)// call toBinary for absolute value (positive) printf("absolute value- %s ", strNum); // flip, complement for (1-7; >-0 ; i--){ if(strNum [1] '0') - strNumi]'1'; else strNum [i]'0' printf("1's complement- %s ", strNum); for (i7, carryl; i -0 &&carry: i--)t l/ if carry is 0, stop!! int sum(strNum[i] -48) carry: // ascii '0' is decimal 48, '1' is 49 strNum[i]-'0'+(sum & 0x01); // logical and carry-(sum >>1) & 0x01; // shift right by 1 bit (divide by 2) & logical and printf("2's complement %s ", strNum); int main () char Binary [10]-""; int num; printf ("Enter a number:"); scanf("%d", &num); if (num > 127 11 num -0) // positive or 0 toBinary (num, Binary); else // negative to two's complement twosComplement (num, Binary) printf("%d's 8-bit Binary Representation return 0; is %s ",num Binary); , Please Convert the following C code to MIPS Assembly (SPIM). PLEASE MAKE SURE IT IS ACCEPTABLE BY SPIM, IF IT IS NOT ACCEPTABLE BY SPIM I WILL NOT UPVOTE THE ANSWER. Also, please post screenshots of your code and don't paste the text in your answer. #include #include // leaf function - convert decimal to binary in string void toBinary (int num, char strNum[]) int i; for (i7: i-0 i--)t / index 7 is the LSB (bit-0) int remnum&0x01: // retrieve remainder num -num >> 1; // shift right by 1 bit (divide by 2) strNumi-'0' + rem; // ascii '0' is decimal 48, '1' is 49 // non-leaf function - convert decimal (negative) to 2's complement in string void twosComplement (int num, char strNum[]) int i, absolute, carry; absolute - abs (num) toBinary (absolute, strNum)// call toBinary for absolute value (positive) printf("absolute value- %s ", strNum); // flip, complement for (1-7; >-0 ; i--){ if(strNum [1] '0') - strNumi]'1'; else strNum [i]'0' printf("1's complement- %s ", strNum); for (i7, carryl; i -0 &&carry: i--)t l/ if carry is 0, stop!! int sum(strNum[i] -48) carry: // ascii '0' is decimal 48, '1' is 49 strNum[i]-'0'+(sum & 0x01); // logical and carry-(sum >>1) & 0x01; // shift right by 1 bit (divide by 2) & logical and printf("2's complement %s ", strNum); int main () char Binary [10]-""; int num; printf ("Enter a number:"); scanf("%d", &num); if (num > 127 11 num -0) // positive or 0 toBinary (num, Binary); else // negative to two's complement twosComplement (num, Binary) printf("%d's 8-bit Binary Representation return 0; is %s ",num Binary)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!