Question: Write a main program for the MIPS machine that implements a simple five-function calculator and prompts the user to enter a pair of decimal integers

Write a main program for the MIPS machine that implements a simple five-function calculator and prompts the user to enter a pair of decimal integers (A and B) followed by a character that specifies one of the operators:

+ for addition to compute A+B

- for subtraction to compute A-B

* for multiplication to produce the 32-bit product A*B

/ for division to produce the 32-bit integer quotient A/B.

% for the modulo function (i.e. the remainder produced when A is divided by B)

Your program should display the result produced by performing the indicated operation on the two input operands A and B. Only the five operators listed above should be allowed and an attempt to divide by zero should be prohibited.

A sample execution of the program is shown below:

Write a main program for the MIPS machine that implements a simple

Your main program should prompt the user for input operands and the operator. Use the READ_CHAR syscall to obtain the operator and use READ_INT syscalls to obtain the operands.

Define a separate function for each of the allowed operators and use the function names ADD, SUB, MUL, DIV and MOD. Each function should accept the two operands in $a0 and $a1, and accept the character representing the operator in $a3. Each function should return the appropriate result (the sum, the difference, the product, the quotient, etc.) in register $v0. You need not be concerned with overflow, just use the 32-bit result in each case.

Upon return from the function, the main program should display the result on the console as shown in the sample output above

Console Enter the first decinal integer operand5 Enter the second decinal integer operand: 90 Enter the operator (+.or) The result 450 Continue? ('y' or "I'): y Enter the first decinal integer operand 26 Enter the second decinal integer operand: 30 Enter the operator or- he resul4 Continue? ('y' or 'Y' ); Enter the irst decinal integer operand 15 Enter the second decinal integer operand 6 Enter the operator (+.--or The result2 Continue? 'y or Y: n Terminating

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!