Compare float to non-float register

Started by live2play, April 30, 2010, 05:13:17 AM

Previous topic - Next topic

live2play

I know a float's value is always 3F800000 at a certain point, but I don't know from where the float value comes.  Is there a way to compare the value in the float register to 3F800000 without using another float?  I would like to be able to set a register to 3F800000 and then compare it against the float if possible.

dcx2

Make some room on the stack, push the float register onto the stack, and then pop it off into a regular register.  Then you can compare against it.

live2play

#2
Like this?

stwu r1,-24(r1)
stw r3,8(r1)
stw r4,12(r1)
stfs f0,16(r1)
lwz r3,16(r1)
lis r4,0x3F80
ori r4,r4,0x0000
cmpw r3,r4
bne- +0x10
<3 lines of code>
lwz r3,8(r1)
lwz r4,12(r1)
addi r1,r1,24

dcx2

That looks exactly right.  Only small change...you don't need to ori r4,r4, 0.  lis should 0 out the bottom of r4.