Question: code must be done in mips 32 and can you include comments and could also comment how the addition and the subtraction worked in mips
code must be done in mips 32 and can you include comments and could also comment how the addition and the subtraction worked in mips and why the instructions you used helped add and subtracted the numbers and how the overflow worked thank you
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.
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.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
