Question

Convert the following C fragment to equivalent MIPS assembly language Write mini calculator that take two...

Convert the following C fragment to equivalent MIPS assembly language

Write mini calculator that take two integer numbers as input and ask the user if he need to
compute addition, subtraction, remainder, division, or multiplication then print the result.
Hint: you can give each operation a special number. For example, the addition (1), subtraction (2), ….
And so on.
The output must be something like:
Enter the first integer number: 5
Enter the second integer number: 3
Which operation? 1
The result = 8

0 0
Add a comment Improve this question Transcribed image text
Answer #1

# include <stdio.h>
int main(){
   int a,b,result,num;
   printf("Enter a:-");
   scanf("%d",&a);
   printf("Enter b:-");
   scanf("%d",&b);
   printf("Enter option:-");
   scanf("%d",&num);
   switch(num){
  
   case 1:
           result=a+b;
           printf("addition of %d and %d is %d",a,b,result);
           break;
   case 2:
           result=a-b;
           printf("subtraction of %d and %d is %d",a,b,result);
           break;
   case 3:
           result=a*b;
           printf("multiplication of %d and %d is %d",a,b,result);
           break;
   case 4:
            result=a/b;
           printf("division of %d and %d is %d",a,b,result);
           break;
   default:
        printf(" invalid input");
   }      
          
  
}

Add a comment
Know the answer?
Add Answer to:
Convert the following C fragment to equivalent MIPS assembly language Write mini calculator that take two...
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 following C/C++ fragment into equivalent MIPS assembly language. Assume that the variables a, b,...

    Convert the following C/C++ fragment into equivalent MIPS assembly language. Assume that the variables a, b, c, d, i and x are assigned to registers $t1, $t2, $t3, $t4, $s0 and $s1 respectively. if ((a<b && (c == 0) d = 1;

  • Using Assembly Language (MIPS), design a program calculator that can perform the following: Addition, Subtraction, Multiplication,...

    Using Assembly Language (MIPS), design a program calculator that can perform the following: Addition, Subtraction, Multiplication, Division, Power and Square Root Functions. Code must be able to accept floating point as well.

  • Convert the following C fragment to equivalent MIPS assembly language. Assume that the variables a, b,...

    Convert the following C fragment to equivalent MIPS assembly language. Assume that the variables a, b, c, d, i and x are assigened to registers $t1, $t2, $t3, $t4, $s0 and $s1 respectively. Assume that the base address of the array A and B is in register $a0 and $a1 respectively. if (a > 0)            b = a + 10;            else                b = a - 10;

  • Problem 3 (35) Design a calculator that performs four operations: addition, multiplication, division and subtraction with...

    Problem 3 (35) Design a calculator that performs four operations: addition, multiplication, division and subtraction with 2 integer type numbers a) Ask user what type of operation to perform (+, , * or/) a. If the user inputs 'none' then the program terminates. Otherwise it will keep continuing the calculation. (hint: use while) b) Ask user to provide 2 integer number inputs c) Perform operation (whatever operation they mentioned in a) d) Print result e) In division operation, perform a...

  • Implement a simple four function calculator in the LC3 assembly language that will run on the...

    Implement a simple four function calculator in the LC3 assembly language that will run on the LC-3 simulator. The LC-3 computer only reads a character at a time but is capable of displaying a string of characters. This calculator program will use multiple subroutines that perform purposes such as reading multi-digit numbers, converting them to integers, performing addition, subtraction, multiplication, or division on these numbers, and displaying the result. The inputs to the calculator will not exceed 4 digits. The...

  • Write an assembler program that asks the user (as shown below) for two integers and a...

    Write an assembler program that asks the user (as shown below) for two integers and a single character representing the arithmetic operations: addition, subtraction, multiplication and integer division (displays both quotient and remainder). Perform the requested operation on the operands and display the result as specified below. Assume SIGNED NUMBERS. The program should not divide by 0! If the user attempts to divide by 0, display the error message: "Cannot divide by zero." If this error occurs, the program should...

  • Creating a Calculator Program

    Design a calculator program that will add, subtract, multiply, or divide two numbers input by a user.Your program should contain the following:-The main menu of your program is to continue to prompt the user for an arithmetic choice until the user enters a sentinel value to quit the calculatorprogram.-When the user chooses an arithmetic operation (i.e. addition) the operation is to continue to be performed (i.e. prompting the user for each number, displayingthe result, prompting the user to add two...

  • Write a C++ Program that simulates a basic calculator using functions which performs the operations of...

    Write a C++ Program that simulates a basic calculator using functions which performs the operations of Addition, Subtraction, multiplication, and Division. ( make sure you cover the case to avoid division by a zero) Display a menu for list of operations that can be calculated and get the input from user about his choice of calculation. Based on user choice of operation, take the input of number/numbers from user. Assume all input values are of type double. Calculations must be...

  • Write a C++ Program that simulates a basic calculator using functions which performs the operations of...

    Write a C++ Program that simulates a basic calculator using functions which performs the operations of Addition, Subtraction, multiplication, and Division. ( make sure you cover the case to avoid division by a zero) Display a menu for the list of operations that can be calculated and get the input from the user about his choice of calculation. Based on user choice of operation, take the input of number/numbers from user. Assume all input values are of type double. Calculations...

  • This is a quick little assignment I have to do, but I missed alot of class...

    This is a quick little assignment I have to do, but I missed alot of class due to the Hurricane and no one here knows what theyre doing. please help! this is Java with intelli-J Overview In this project students will build a four-function one-run calculator on the command line. The program will first prompt the user for two numbers, then display a menu with five operations. It will allow the user to select an option by reading input using...

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
ADVERTISEMENT