Question
Change code below so it is in this order: a - b, a * b, a + b, a / b, a + b in
Change code below so it is in this order: a - b, a * b, a + b, a / b, a + b in range or not. check output after to see if it works
MIPS CODE
.data msgA: .asciiz "Enter number a: " msgB: .asciiz "Enter number b: " msgPlus: .asciiz " a+b = " msgMinus: .asciiz " a-b = " msgMult: .asciiz " a*b = " msgDiv: .asciiz " a/b = " msgInRange: .asciiz " a+b is in the range 10-20" msgNotInRange: .asciiz " a+b is NOT in the range 10-20" .text #print string li $v0, 4 la $a0, msgA syscall
#read int li $v0, 5 syscall move $t0, $v0 #print string li $v0, 4 la $a0, msgB syscall
#read int li $v0, 5 syscall move $t1, $v0 #calculate a+b and display add $t2, $t0, $t1 #print string li $v0, 4 la $a0, msgPlus syscall
#print int move $a0, $t2 li $v0, 1 syscall #check if a+b is in range 10-20 blt $t2, 10, notInRange bgt $t2, 20, notInRange #print in range li $v0, 4 la $a0, msgInRange syscall b next notInRange: #print NOT in range li $v0, 4 la $a0, msgNotInRange syscall next: #calculate a-b and display sub $t2, $t0, $t1 #print string li $v0, 4 la $a0, msgMinus syscall
#print int move $a0, $t2 li $v0, 1 syscall #calculate a*b and display mul $t2, $t0, $t1 #print string li $v0, 4 la $a0, msgMult syscall
#print int move $a0, $t2 li $v0, 1 syscall beqz $t1, exit #calculate a/b and display div $t2, $t0, $t1 #print string li $v0, 4 la $a0, msgDiv syscall
#print int move $a0, $t2 li $v0, 1 syscall exit: #exit li $v0, 10 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