Question

Convert the below C code to basic MIPS. Leave comments for explanation please #include <stdio.h> int main(void) {...

Convert the below C code to basic MIPS. Leave comments for explanation please

#include <stdio.h>


int main(void)
{
printf("Insert two numbers\n");
int a,b,c;
scanf("%d",&a);
scanf("%d",&b);
c=a|b;
printf("%d|%d=%d\n",a,b,c);
return 0;
}

0 0
Add a comment Improve this question Transcribed image text
Answer #1
.data
   prompt:    .asciiz    "Insert two numbers\n"
   orsym: .asciiz    "|"
   eqsym: .asciiz    "="
   newline:.asciiz    "\n"

.text
   # display prompt
   la $a0, prompt
   li $v0, 4
   syscall

   # read a number
   li $v0, 5
   syscall
   
   # store input(a) in $t0
   move $t0, $v0

   # read another number  
   li $v0, 5
   syscall

   # store input(b) in $t1    
   move $t1, $v0  
   
   or $t2, $t0, $t1   # c = a | b

   # print a
   move $a0, $t0
   li $v0, 1
   syscall
   
   # print |
   la $a0, orsym
   li $v0, 4
   syscall

   # print b
   move $a0, $t1
   li $v0, 1
   syscall
   
   # print =
   la $a0, eqsym
   li $v0, 4
   syscall

   # print c
   move $a0, $t2
   li $v0, 1
   syscall

   # print \n 
   la $a0, newline
   li $v0, 4
   syscall
Add a comment
Know the answer?
Add Answer to:
Convert the below C code to basic MIPS. Leave comments for explanation please #include <stdio.h> int main(void) {...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Convert the below C code to basic MIPS. Please leave comments for explanation #include <stdio.h> int main(void) {...

    Convert the below C code to basic MIPS. Please leave comments for explanation #include <stdio.h> int main(void) { printf("Insert two numbers\n"); int a,b; scanf("%d",&a); scanf("%d",&b); a=a<<2; b=b<<2; printf("%d&%d\n",a,b); return 0; }

  • Convert the below C code to basic MIPS. The result of this code should be a^b...

    Convert the below C code to basic MIPS. The result of this code should be a^b of the two numbers that you input. For example if you input the numbers 3 and 5 you should get a result of 3^5=6 #include int main(void) { printf("Insert two numbers\n"); int a,b,c; scanf("%d",&a); scanf("%d",&b); c=a^b; printf("%d^%d=%d\n",a,b,c); return 0; }

  • Convert the below C code to basic MIPS. The result of this code should ask for...

    Convert the below C code to basic MIPS. The result of this code should ask for two numbers to be inputed and give the answer. For example if 3 and 5 are inputed then the final answer should be as follows: 3&5=1, 3|5=7, 3^5=6, << = 12&20, >> = 0&1, and finally ~ = -4&-6. Please run the code yourself before you upload it to make sure it works. Start the code with .data. Thank you so much. #include <stdio.h>...

  • Fix the errors in C code #include <stdio.h> #include <stdlib.h> void insertAt(int *, int); void Delete(int...

    Fix the errors in C code #include <stdio.h> #include <stdlib.h> void insertAt(int *, int); void Delete(int *); void replaceAt(int *, int, int); int isEmpty(int *, int); int isFull(int *, int); void removeAt(int *, int); void printList(int *, int); int main() { int *a; int arraySize=0,l=0,loc=0; int choice; while(1) { printf("\n Main Menu"); printf("\n 1.Create list\n 2.Insert element at particular position\n 3.Delete list.\n4. Remove an element at given position \n 5.Replace an element at given position\n 6. Check the size of...

  • Solve using C programming 3. lf you are given this code. #include <stdio.h> int main() int...

    Solve using C programming 3. lf you are given this code. #include <stdio.h> int main() int var1, var2; int sum; printf("Enter number 1:\n "); scanf("%d",&var1); printf("Enter number 2:In ); scanf("%d",&var2); sum-var1+var2; printf ("Vnsum of two entered numbers : %d", //printf ("Output: %d", res); sum); return e; Modify this code by creating a function called "addition". Make the arguments of the functions numberl and number 2. Add the two values in the function. Return a value called "result". Print "result" in...

  • i need flowchart for the following c code #include <stdio.h> int main() {     int n,...

    i need flowchart for the following c code #include <stdio.h> int main() {     int n, i, sum = 0;     printf("Enter an integer: ");     scanf("%d",&n);     i = 1;     while ( i <=n )     {         sum += i;         ++i;     }     printf("Sum = %d",sum);     return 0; }

  • Convert this C program to Js (Java script) from Visual Studio Code #include<stdio.h> int main(){ char...

    Convert this C program to Js (Java script) from Visual Studio Code #include<stdio.h> int main(){ char firstName[100]; char lastName[100]; printf("Enter Your Full Name: \n"); scanf("%s %s", firstName, lastName); printf("First Name: %s\n", firstName); printf("Last Name: %s\n", lastName); return 0; }

  • PUT INTO PYTHON CODE #include <stdio.h> #include <float.h> int main(void) { float a = 1; float...

    PUT INTO PYTHON CODE #include <stdio.h> #include <float.h> int main(void) { float a = 1; float b = 0.5; float c = a + b; int bits = 0; while (c != a) { bits = bits + 1; b = b / 2; c = a + b; } printf("%d\n",bits); return 0; }

  • MIPS assembly language Covert this code to MIPS: #include <stdio.h> int function (int a) int main)i...

    MIPS assembly language Covert this code to MIPS: #include <stdio.h> int function (int a) int main)i int x=5 ; int y: y function(x); printf "yd",y); return 0; int function (int a) return 3*a+5; Assumptions: . Place arguments in $a0-$a3 . Place return values in $vO-$v1 Return address saved automatically in $ra . lgnore the stack for this example. (Thus, the function will destroy registers used by calling function

  • Complete this program in C #include<stdio.h> int main(void) { int sumA(__, __); int answer;   //the two...

    Complete this program in C #include<stdio.h> int main(void) { int sumA(__, __); int answer;   //the two parameters are start and end addresses of intA[] answer = sumA(......); printf("..........", intA); printf("The sum of integers in intA is %d.\n", answer); return 0; } //the two parameters of sumA(__, __) are start and end addresses of intA[] int sumA(..........) { ……………………. return ............. }

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT