1
所以我的MARS MIPS模擬器發生了一個奇怪的問題。MIPS字符串第一個字符沒有顯示
我的字符串採用用戶的名字看起來是刪除他們的名字的第一個字符。我無法弄清楚爲什麼我的生活。
.data
height: .asciiz "enter your height"
weight: .asciiz "enter your weight"
little: .float 18.5
medium: .float 25
large: .float 30
fpconstant: .float 703
bmi: .float
under: .asciiz "This is considered underweight"
health: .asciiz "This is considered healthy"
overweight: .asciiz "This is considered overweight"
obese: .asciiz "This is considered obese."
name: .asciiz ", here are your BMI results\n"
prompt: .asciiz "Please enter your name"
buffer: .space 20
.text
main: li $v0, 4
la $a0, prompt
syscall
li $v0, 8
syscall
la $a0, buffer # load byte space into address
li $a1, 20 # allot the byte space for string
move $t6, $a0 # save string to t6
syscall
li $v0, 4
la $a0, weight
syscall
li $v0, 6
syscall
movf.s $f1, $f0 #f1 now contains weight, will continue after this correction has been made.
l.s $f2, fpconstant
mul.s $f0, $f1, $f2
movf.s $f1, $f0
movf.s $f12, $f0
li $v0, 4
la $a0, height
syscall
li $v0, 6
syscall
movf.s $f2, $f0 #f2 now contains height, will continue after this correction has been made.
mul.s $f0, $f2, $f2
movf.s $f2, $f0
movf.s $f12, $f0
div.s $f3, $f1, $f2 #f3 is our BMI
movf.s $f12, $f3
la $a0, buffer # reload byte space to primary address
move $a0, $t6 # primary address = t6 address (load pointer)
li $v0, 4 # print string
syscall #Problem
la $a0, name
move $t0, $a0
syscall
li $v0, 2
syscall
l.s $f4, little
c.lt.s $f3,$f4
bc1t underweight #Branch if specified FP condition flag true (BC1T, not BCLT) : If Coprocessor 1 condition flag specified by immediate is true (one) then branch to statement at label's address # Compare less than single precision : If $f0 is less than $f1, set Coprocessor 1 condition flag 0 true else set it false
l.s $f4, medium
c.lt.s $f3,$f4
bc1t mid
l.s $f4, large
c.lt.s $f3,$f4
bc1t big
li $v0, 4
la $a0, obese
syscall
li $v0, 10
syscall
underweight:
li $v0, 4
la $a0, under
syscall
li $v0, 10
syscall
li $v0, 10
syscall
mid:
li $v0, 4
la $a0, health
syscall
li $v0, 10
syscall
big:
li $v0, 4
la $a0, overweight
syscall
li $v0, 10
syscall
我對壞格式表示歉意 - 這是我問過的第一個問題。謝謝!
非常感謝!第二次體重不足是我的疏忽 - 我甚至沒有注意到它。 –