This is my code in MIPS. Please go over and let me know what is wrong with it. P
ID: 3591483 • Letter: T
Question
This is my code in MIPS. Please go over and let me know what is wrong with it. Please run it in the actual program. Thank you.
.data
a: .word 703
height: .word 0
weight: .word 0
bmi: .float 0
number1: .float 18.5
number2: .float 25
number3: .float 30
name: .asciiz "What is your name? "
inputBuffer: .space 20
heightInfo: .asciiz "Please enter your height in inches: "
weightInfo: .asciiz "Please enter your weight in pounds (round to a whole number): "
output1: .asciiz "This is considered underweight. "
output2: .asciiz "This is a normal weight. "
output3: .asciiz "This is considered overweight. "
output4: .asciiz "This is considered obese. "
.text
lw $t1, height
lw $t2, weight
#display message to ask for user's name
li $v0, 4
la $a0, name
syscall
#take user name
li $v0, 8
la $a0, inputBuffer
li $a1, 20
syscall
#ask user for height
li $v0, 4
la $a0, heightInfo
syscall
#take user height
li $v0, 5
syscall
move $t1, $v0
la $t3, ($t1)
#ask user for weight
li $v0, 4
la $a0, weightInfo
syscall
move $t2, $v0
la $t4, ($t2)
#take user weight
li $v0, 5
syscall
move $t2, $v0
lwc1 $f0, a #f1 = 703
lwc1 $f2, ($t1) #f2 = height
lwc1 $f4, ($t2) #f3 = weight
lwc1 $f12, bmi #f12 = bmi
lwc1 $f14, number1
lwc1 $f16, number2
lwc1 $f18,number3
cvt.s.w $f6, $f0
cvt.s.w $f8, $f2
cvt.s.w $f10,$f4
mul.s $f10, $f6, $f10 #weight = weight * 703
div.s $f12, $f10, $f2 #bmi = weight/height
c.lt.s $f12, $f14
bc1t exit1
c.lt.s $f12, $f16
bc1t exit2
c.lt.s $f12, $f18
bc1t exit3
li $v0, 4
la $a0, output4
syscall
#exit
li $v0, 10
syscall
exit1:
li $v0, 4
la $a0, output1
syscall
exit2:
li $v0, 4
la $a0, output2
syscall
exit3:
li $v0, 4
la $a0, output3
syscall
hm4 comparbiity Mode] Word X Cu Find Write a MIPS program that calculates bmi. Use the following C++ code as pseudocode. The variable bmi can be single or double precision. 1 include include using namespace std: int main) int height 0, weight = 0; double hmi: string name 10 rompt user tor their data 12 13 14 15 1 6 17 19 19 20 21 cout nama: cout "Please enter your height in inches: rin >> height; cout (weight) / height; 24 output the results coutExplanation / Answer
Fixed the code. Also displaying the bmi which is calculated. Hope it helps. Please do rate the answer if it helped. Thank you.
.data
a: .word 703
height: .word 0
weight: .word 0
bmi: .float 0
number1: .float 18.5
number2: .float 25
number3: .float 30
name: .asciiz "What is your name? "
inputBuffer: .space 20
heightInfo: .asciiz "Please enter your height in inches: "
weightInfo: .asciiz "Please enter your weight in pounds (round to a whole number): "
output1: .asciiz " This is considered underweight. "
output2: .asciiz " This is a normal weight. "
output3: .asciiz " This is considered overweight. "
output4: .asciiz " This is considered obese. "
.text
#display message to ask for user's name
li $v0, 4
la $a0, name
syscall
#take user name
li $v0, 8
la $a0, inputBuffer
li $a1, 20
syscall
#ask user for height
li $v0, 4
la $a0, heightInfo
syscall
#take user height
li $v0, 5
syscall
sw $v0, height #store it in height variable
#ask user for weight
li $v0, 4
la $a0, weightInfo
syscall
#take user weight
li $v0, 5
syscall
sw $v0, weight
lwc1 $f0, a #f0 = 703
lwc1 $f2, height #f2 = height
lwc1 $f4, weight #f3 = weight
lwc1 $f14, number1
lwc1 $f16, number2
lwc1 $f18,number3
cvt.s.w $f6, $f0
cvt.s.w $f8, $f2
cvt.s.w $f10,$f4
mul.s $f10, $f6, $f10 #weight = weight * 703
mul.s $f8, $f8, $f8 #height = height * height
div.s $f12, $f10, $f8 #bmi = weight/height
li $v0, 2 #display the floating point number bmi , since its already in $f12, we don't need to move
syscall
c.lt.s $f12, $f14
bc1t exit1
c.lt.s $f12, $f16
bc1t exit2
c.lt.s $f12, $f18
bc1t exit3
li $v0, 4
la $a0, output4
syscall
b exit
exit1:
li $v0, 4
la $a0, output1
syscall
b exit
exit2:
li $v0, 4
la $a0, output2
syscall
b exit
exit3:
li $v0, 4
la $a0, output3
syscall
exit:
#exit
li $v0, 10
syscall
output
What is your name?
jessy
Please enter your height in inches: 64
Please enter your weight in pounds (round to a whole number): 140
24.02832 This is a normal weight.
-- program is finished running --
What is your name?
john
Please enter your height in inches: 72
Please enter your weight in pounds (round to a whole number): 220
29.834105 This is considered overweight
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.