Question: code must be done in mips32 thank you You have been put into a team that is working on a MIPS program that has six

code must be done in mips32 thank you

You have been put into a team that is working on a MIPS program that has six functions: main, do_math, do_add, do_subtract, do_multiply, and do_divide. The main function does the following:

1. Print the following prompt message: Please enter an integer: 2. Read an integer from user. 3. Print the following prompt message: Please enter an operator (+, -, *, /): 4. Read a character from user. 5. Print the following prompt message: Please enter an integer: 6. Read an integer from user. 7. Call do_math. Pass the two integers and the operator using registers. 8. Return 0 from main using jr (do not use the 'exit' syscall).

The do_math function takes as argument three registers and does the following: 1. If the operator register contains '+', call do_add passing the two integers in registers and receiving the return values in two registers. 2. Otherwise, if the operator register contains '-', call do_subtract passing the two integers in registers and receiving the return values in two registers. 3. Otherwise, if the operator register contains '*', call do_multiply passing the two integers in registers and receiving the return values in two registers.

Otherwise, if the operator register contains '/', call do_divide passing the two integers in registers and receiving the return values in two registers. 5. Otherwise, print the following error message, replacing OP with the character stored in the operator register, and exit the program. Error: invalid arithmetic operation 'OP'. 6. Print the following message: X OP Y = Z. Where Z is the arithmetical result of the operation OP conducted on the two integers input from the user, X and Y.

The do_add function takes as argument two integers in registers and does the following: 1. Add the two integers without using the 'add*' or 'sub*' MIPS instruction. In particular, use the 'or', 'and', 'xor', 'sll', and 'srl' instructions. 2. Return the result in a register. If there is an arithmetic overflow, return an error condition identifying that an overflow occurred in another register.

The do_sub function takes as argument two integers in registers and does the following: 1. Subtract the second integer from the first without using the 'sub*' or 'add*' MIPS instructions. You may however use addi to adjust the stack pointer. You should take the 2's complement of the second integer, and then call do_add. Note: to take the 2's complement you should use 'nor', 'ori', and a call to do_add, thus there will be two calls to do_add! 2. Return the result in a register. If there is an arithmetic overflow, return an error condition identifying that an overflow occurred in another register.

The do_multiply function takes as argument two integers in registers and does the following: 1. Multiply the two integers without using the 'add*', 'sub*', or 'mul*' instructions. You may however use addi to adjust the stack pointer. You can make calls to the do_add or do_sub functions. 2. Return the result in two registers, one to hold the most significant 32 bits of the product, and one for the least significant 32 bits

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!