Question: So I've been assigned to create a calculator that accepts a single arithmetic expression (+,-,*) from the command line, evaluates the chosen expression, and then

So I've been assigned to create a calculator that accepts a single arithmetic expression (+,-,*) from the command line, evaluates the chosen expression, and then displays the result. Afterwards, it should tell if the result is even or odd.

This is to be done in MIPS Assembly Language and use correct syntax.

My question is: "Would you be willing to help me create the (" - , * ) "Subtraction and Multiplication" operations as well as user input arithmetic expression so the code will preform like a calculator?

Here's what I have already for addition:

-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_

.text .globl read .globl main .ent main

main: jal read li $v0,10 # 10 is exit system call syscall .end main

read: # prompt for first integer li $v0 4 # 4 is print string la $a0, iprompt # load address of prompt into $a0 to print syscall # display the prompt

# read the first integer li $v0 5 # setup syscall 5 (read_int) syscall # integer returned in $v0 move $t0, $v0 # move first integer to $t0

# prompt for second integer li $v0 4 # 4 is print string la $a0, iprompt # load address of prompt into $a0 to print syscall # display the prompt

# read the second integer li $v0 5 # setup syscall 5 (read_int) syscall # integer returned in $v0 move $t1, $v0 # move second integer to $t1

# sum the two integers add $t2, $t0, $t1

move $a0,$t2 # move the result into register $a0 li $v0, 1 # setup syscall 1 (print_int) syscall # make the call to display the integer

li $v0, 4 # print a newline la $a0, newline syscall

jr $ra

.data iprompt: .asciiz "Enter a whole number: " newline: .asciiz " "

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!