Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

must be done in mips 32 bit please add comments explaining what the code is doing thank you just do the do_math do_add and do_sub

must be done in mips 32 bit please add comments explaining what the code is doing thank you just do the do_math do_add and do_sub repeat cant use add or sub instrucrtions read below thak 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

What is DDL?

Answered: 1 week ago