Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Generative Artificial Intelligence For Project Management With Aws

Authors: Timothy Krimmel

1st Edition

B0CQV9KWB8, 979-8872627197

More Books

Students also viewed these Databases questions