Answered step by step
Verified Expert Solution
Question
1 Approved Answer
. this code is a simple calculator written in mips but there is a problem the code dose not loop i want to alter it
this code is a simple calculator written in mips but there is a problem the code dose not loop i want to alter it so that it loop.
data
number : asciiz "Enter number:
number : asciiz "Enter number:
addChoice: asciiz to add numbers
subChoice: asciiz to subtract numbers
mulChoice: asciiz to multiply numbers
divChoice: asciiz to divide numbers
quitChoice: asciiz Quit
enterChoice: asciiz "Enter Choice:"
Result: asciiz "Result:"
endl : asciiz
text
main:
addi $s$zero, #number
addi $s$zero, #number
li $v #print String to input number
la $anumber
syscall
li $v #get input from user
syscall
move $s$v #move user input to $s
li $v #print String to input number
la $anumber
syscall
li $v #get second user input
syscall
move $s$v #move user input to $s
#print menu system
li $v #addition
la $aaddChoice
syscall
#subtraction
li $v
la $asubChoice
syscall
#multipication
li $v
la $amulChoice
syscall
#divide
li $v
la $adivChoice
syscall
#quit
li $v
la $aquitChoice
syscall
#enter choice
li $v
la $aenterChoice
syscall
#get choice from user
li $v
syscall
#move $v to $t
addi $t$v
beq $tADD #if choice go to ADD
beq $tSUB #if choice go to SUB
beq $tMUL #if choice go to MUL
beq $tDIV #if choice go to DIVIDE
beq $tExit # to quit enter
j Exit #jump to Quit anything else entered
DIV:
#divide $s with $s
div $s$s
#move divide quotient into $t
mflo $t
#print result string
li $v
la $aResult
syscall
#print divide quotient
move $a$t
li $v
syscall
#print new line
li $v
la $aendl
syscall
j Exit
MUL :
#multiply $s and $s
mult $s$s
#move low order bit in $t
mflo $t
#print result string
li $v
la $aResult
syscall
#print multiplication
move $a$t
li $v
syscall
#print new line
li $v
la $aendl
syscall
j Exit
SUB :
#sub tract $s$s
#result save to $t
sub $t$s$s
li $v
la $aResult
syscall
#print t
move $a$t
li $v
syscall
li $v
la $aendl
syscall
j Exit
ADD:
#add $s$s
add $t$s$s
li $v
la $aResult
syscall
#print t
move $a$t
li $v
syscall
li $v
la $aendl
syscall
j Exit
Exit:
#terminate the program
li $v
syscall
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started