WiiRd forum

Wii & Gamecube Hacking => Wii Game hacking help => Topic started by: live2play on April 30, 2010, 05:13:17 AM

Title: Compare float to non-float register
Post by: live2play on April 30, 2010, 05:13:17 AM
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.
Title: Re: Compare float to non-float register
Post by: dcx2 on April 30, 2010, 05:33:31 AM
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.
Title: Re: Compare float to non-float register
Post by: live2play on April 30, 2010, 06:07:32 AM
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
Title: Re: Compare float to non-float register
Post by: dcx2 on April 30, 2010, 01:19:37 PM
That looks exactly right.  Only small change...you don't need to ori r4,r4, 0.  lis should 0 out the bottom of r4.