Okay, so lately I've been working to make many of my old codes shorter and I've been trying to use the C0 code type as it seems to be the best option for me to use(I work better with ASM anyways) but so far I've noticed a large amount of quirks in the way the ASM acts when it's being used by that code type.
I've noticed it happen most while operating with floating point values, so I prepared an example to show what happens... The following is a simple code that takes the values in gr 0, 1, and 2, stores them in f14, 15, and 16, and performs some simple arithmetic on them.
gr 0 = 00000000
gr 1 = 3F800000
gr 2 = 3FC00000
stwu r1,-128(r1)
stmw r2,8(r1)
lis r3,-32768
lfs f14,0x1808(r3)
lfs f15,0x180C(r3)
lfs f16,0x1810(r3)
fmuls f14,f14,f15
fadds f14,f14,f16
_Break_
lmw r2,8(r1)
addi r1,r1,128
blr
Now, ordinarily the arithmetic should go something like
00000000 x 3F800000 = 00000000
00000000 + 3FC00000 = 3FC00000
with 3FC00000 being the final result in float register 14 at the point I've labeled with _break_.
Here's a single run through (While watching the float register 14, 15, and 16) using the C2 code type:
stwu r1,-128(r1)
stmw r2,8(r1)
lis r3,-32768
lfs f14,0x1808(r3) f14 = 00000000, f15 = 00000000, f16 = 00000000
lfs f15,0x180C(r3) f14 = 00000000, f15 = 3F800000, f16 = 00000000
lfs f16,0x1810(r3) f14 = 00000000, f15 = 3F800000, f16 = 3FC00000
fmuls f14,f14,f15 f14 = 00000000, f15 = 3F800000, f16 = 3FC00000
fadds f14,f14,f16 f14 = 3FC00000, f15 = 3F800000, f16 = 3FC00000
_Break_
lmw r2,8(r1)
addi r1,r1,128
blr
The final result is how it should be, 3FC00000... Here it is again but this time using the C0 code type...
stwu r1,-128(r1)
stmw r2,8(r1)
lis r3,-32768
lfs f14,0x1808(r3) f14 = 00000000, f15 = 00000000, f16 = 00000000
lfs f15,0x180C(r3) f14 = 3FC00000, f15 = 3F800000, f16 = 00000000
lfs f16,0x1810(r3) f14 = 3FC00000, f15 = 3F800000, f16 = 3FC00000
fmuls f14,f14,f15 f14 = 3FC00000, f15 = 3F800000, f16 = 3FC00000
fadds f14,f14,f16 f14 = 40400000, f15 = 3F800000, f16 = 3FC00000
_Break_
lmw r2,8(r1)
addi r1,r1,128
blr
Instead the final result is 40400000. :confused:
This may not seem like much, but it gets very irritating if you're working with something like the velocity of an object. There have been other cases like this as I get into more complex codes... it's very irritating, so if anyone would mind telling me if I've forgotten or missed something, I'd be very grateful.
Thanks for any assistance offered.
Which game? I tried to reproduce your results using that ASM code but always ended up with the correct result. It's not that I don't believe you though; I have noticed floating pointer registers changing seemingly at random when stepping through ASM that isn't supposed to affect them. Most likely it is caused by an interrupt which changes floating point registers and doesn't restore them back. You may want to try disabling interrupts before the floating point instructions and enabling interrupts after them. Also make sure you save and restore the floating point registers in your code since otherwise it could cause problems in the game.
Thanks for the reply, I do most of my hacking on SSBB so that's where I first noticed it. I'll see about checking up on those things that you mentioned... It's kinda' weird though that the float registers get changed without the assistance of the ASM.