MIPS BMI计算器打印问题
MIPS BMI calculator print issue
.data
wpr:.asciiz "Weight (whole pounds): "
hpr:.asciiz "Height (whole inches): "
bpr:.asciiz "\nCalculated BMI: "
weight: .word
height: .word
bmi: .float
.text
main:
li $v0 33
li $a0 52
li $a1 20
li $a2 22
li $a3 127
syscall
# Prompt weight
la $a0 wpr
li $v0 4
syscall
# Load input into saved register $s0
li $v0 5
syscall
move $s0 $v0
# Prompt height
la $a0 hpr
li $v0 4
syscall
# Load input into saved register $s1
li $v0 5
syscall
move $s1 $v0
# Calculations
mul $s0 $s0 703
mul $s1 $s1 $s1
mtc1 $s0 $f20
cvt.s.w $f20 $f20
mtc1 $s1 $f21
cvt.s.w $f21 $f21
div.s $f12 $f20 $f21
# Output BMI
li $v0 4
syscall
la $a0 bpr
syscall
li $v0 2
syscall
当我 运行 这段代码一切正常,但我得到两次打印高度提示。我不知道是什么问题。这是输出的示例
体重(整磅):150
身高(整英寸):71
身高(整英寸):
计算的 BMI:20.918468
将最后一段代码(使用“# Output BMI”)更改为
# Output BMI
la $a0 bpr
li $v0 4
syscall
li $v0 2
syscall
目前你让系统先输出到提示,里面还是有你之前的身高提示。
.data
wpr:.asciiz "Weight (whole pounds): "
hpr:.asciiz "Height (whole inches): "
bpr:.asciiz "\nCalculated BMI: "
weight: .word
height: .word
bmi: .float
.text
main:
li $v0 33
li $a0 52
li $a1 20
li $a2 22
li $a3 127
syscall
# Prompt weight
la $a0 wpr
li $v0 4
syscall
# Load input into saved register $s0
li $v0 5
syscall
move $s0 $v0
# Prompt height
la $a0 hpr
li $v0 4
syscall
# Load input into saved register $s1
li $v0 5
syscall
move $s1 $v0
# Calculations
mul $s0 $s0 703
mul $s1 $s1 $s1
mtc1 $s0 $f20
cvt.s.w $f20 $f20
mtc1 $s1 $f21
cvt.s.w $f21 $f21
div.s $f12 $f20 $f21
# Output BMI
li $v0 4
syscall
la $a0 bpr
syscall
li $v0 2
syscall
当我 运行 这段代码一切正常,但我得到两次打印高度提示。我不知道是什么问题。这是输出的示例
体重(整磅):150
身高(整英寸):71
身高(整英寸):
计算的 BMI:20.918468
将最后一段代码(使用“# Output BMI”)更改为
# Output BMI
la $a0 bpr
li $v0 4
syscall
li $v0 2
syscall
目前你让系统先输出到提示,里面还是有你之前的身高提示。