[英]MIPS Input floating point number
How do you take in an input of a floating number in MIPS?你如何在 MIPS 中输入一个浮点数? I have tried using:
我试过使用:
li.s $f0, 6
syscall
But I just keep getting that there is an error with the line.但我一直觉得这条线有错误。
li $v0, 6 li $v0, 6
syscall系统调用
//the float value that is read will be in $f0 register //读取的浮点值将在 $f0 寄存器中
you cannot load-immediate a number into float registers您不能将数字立即加载到浮点寄存器中
li $t0, 6 # load-immediate 6 into an int register
mtc1 $t0, $f0 # copies the bit pattern "...110". It is NOT 6.0!!
cvt.s.w. $f12, $f0 # convert word to (single) float. $f12 now contains 6.0
You can also place the float in the data segment:您还可以将浮点数放在数据段中:
.data
pi: .float 3.1415926535 # place value of pi in the data segment
.text
lwc1 $f12, pi # load pi from data segment into $f12
li $v0, 2
syscall # print $f12
Output will be:输出将是:
3.1415927
-- program is finished running
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.