Need the output to work, don\'t need user to enter a name, use floating point ov
ID: 3592969 • Letter: N
Question
Need the output to work, don't need user to enter a name, use floating point over double
Write a MIPS program that calculates bmi. Use the following C++ code as pseudocode. The variable bmi can be single or double precision. #include #include 3 using namespace std; 5 int main ) int height = 0, weight = 0; double bmi string name; 10 // Prompt user for their data cout name 12 13 14 15 16 17 18 cout height: cout weight: 20 21 /I Calculate the bmi weight 703 height *= height ; bmi - static_cast (weight) / height; 23 24 25 26 27 28 29 30 31 32 // Output the results coutExplanation / Answer
The program for calculating BMI using MIPS is as follows:
.data
npr:.asciiz "Player Name: "
wpr:.asciiz "Player Weight (whole pounds): "
hpr:.asciiz "Player Height (whole inches): "
bpr:.asciiz " Calculated BMI of Player: "
playerName: .space 20
weighs: .word
heit: .word
bodymassindex: .float
bmiValue:.float 18.5, 25, 30
errinBmi: .asciiz " This is considered "
bmiRes: .asciiz "underweight. ", "normal weighs. ", "overweight. ", "obese. "
.text
main:
li $x 33
li $y 52
li $z 20
li $a 22
li $b 127
syscall
la $y npr
li $x 4
syscall
li $x 8
la $y playerName
syscall
li $m -1
index: addi $m $m 1
lb $n playerName($m)
bne $n 0xA index
sb $r playerName($m)
la $y wpr
li $x 4
syscall
li $x 5
syscall
move $d $x
la $y hpr
li $x 4
syscall
li $x 5
syscall
move $e $x
mul $d $d 703
mul $e $e $e
mtc1 $d $ak1
cvt.s.w $ak1 $ak1
mtc1 $e $ak2
cvt.s.w $ak2 $ak2
div.s $f12 $ak1 $ak2
la $y playerName
li $x 4
syscall
la $y bpr
syscall
li $x 2
syscall
li $m -4
la $n bmiValue
status: addi $m $m 4
add $b1 $n $m
l.s $ak3 ($b1)
c.le.s $f12 $ak3
bc1f status
li $x 4
la $y errinBmi
syscall
la $n bmiRes
sll $m $m 2
add $b1 $n $m
la $y ($b1)
syscall
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.