开发者

MIPS floating point add example

I am trying to write a MIPS program that w开发者_开发知识库ill add two floating point integers togerther, the first floating point integer is the two's complement of -8.0

the second is the floating pointinteger 2.0

so first I changed -8 to two's compliment which is 1000 then I converted that to hex so my hex would be 0x00000008

my MIPS program so far looks like this

l.s $f1, 0x00000008
l.s $f2, 15.0
add.s $f0, $f1, $f2

I get an error on this obviously any help?

Also I am confused when loading in floating integers in the commant l.s $f2, 15.0 I know this is not right. how can I load 15 into the registry as a floating point? and again my ultimate question how can I add the two together using MIPS. thanks,


To start with, the floating point number 8 is not represented as 0x00000008. Remember that floating point numbers are represented using the IEEE 754 standard.

If you want to add 0x8 and 0xF, then you should:

  1. Load each of them into a fp register (using l.s)
  2. Use the cvt.s.w instruction (convert single from word) to convert them into floating point registers.
  3. add
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜