简体   繁体   English

除整数并将结果打印为MIPS Assembly中的浮点数

[英]Divide integers and print out the result as a float in MIPS Assembly

I am working on an assignment that reads in integers and puts them into an array until a negative one is entered. 我正在做一个读取整数的赋值,并将其放入一个数组中,直到输入负数为止。 I have to find the mean of the integers but the results must be printed out as a float. 我必须找到整数的均值,但结果必须以浮点数形式打印出来。 I've tried several ways of doing this but so far when i run it on QTSpim, the result says 'nan'. 我已经尝试了几种方法来执行此操作,但是到目前为止,当我在QTSpim上运行它时,结果显示为“ nan”。

Here is the portion of my code 这是我的代码的一部分

mfc1 $t6, $f1 #t6 is the sum
cvt.s.w $f1, $f1 
mfc1 $t7, $f2 #t7 is the number of ints
cvt.s.w $f2, $f2  
div.s $f0, $f1, $f2
mov.s $f12, $f0
li $v0, 2
syscall 

mfc1 is Move Word From Floating Point ( rt = fs ). mfc1从浮点移字rt = fs )。 You presumably want mtc1 instead ( fs = rt ). 您大概需要mtc1来代替( fs = rt )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM