I'm not sure if half of them are words or not, so I will put an "even" in front anyway. There's no harm in doing it and I won't have to worry it ever being unaligned.
Debugging misaligned read/write Or how to get your hack to work on Regen/Kega/real hardware
#47
Posted 23 February 2012 - 03:48 PM
You have to be very aware of how the code uses bytes... for example, here's a case where two byte variables MUST be aligned...
If var1 isn't evenly aligned, the above with blow up.
But now let's say I get crazy with the evens and do this
Oopsi! I just made the code fail in a hard to trace manner because the code is trying to load both vars at once, but that second even pushes var2 off a byte so that it won't load with that move.w. So you just can't stick evens EVERYWHERE or you may break the code. Such is the joy and fun of assembly!
move.w var1,d0 ; get both var1 and var2 at the same time
...
var1:
dc.b 10
var2:
dc.b 10
If var1 isn't evenly aligned, the above with blow up.
move.w var1,d0 ; get both var1 and var2 at the same time
...
even
var1:
dc.b 10
var2:
dc.b 10
But now let's say I get crazy with the evens and do this
move.w var1,d0 ; get both var1 and var2 at the same time
...
even
var1:
dc.b 10
even
var2:
dc.b 10
Oopsi! I just made the code fail in a hard to trace manner because the code is trying to load both vars at once, but that second even pushes var2 off a byte so that it won't load with that move.w. So you just can't stick evens EVERYWHERE or you may break the code. Such is the joy and fun of assembly!
#48
Posted 23 February 2012 - 07:02 PM
Chilly Willy, on 23 February 2012 - 03:48 PM, said:
You have to be very aware of how the code uses bytes... for example, here's a case where two byte variables MUST be aligned...
If var1 isn't evenly aligned, the above with blow up.
But now let's say I get crazy with the evens and do this
Oopsi! I just made the code fail in a hard to trace manner because the code is trying to load both vars at once, but that second even pushes var2 off a byte so that it won't load with that move.w. So you just can't stick evens EVERYWHERE or you may break the code. Such is the joy and fun of assembly!
move.w var1,d0 ; get both var1 and var2 at the same time
...
var1:
dc.b 10
var2:
dc.b 10
If var1 isn't evenly aligned, the above with blow up.
move.w var1,d0 ; get both var1 and var2 at the same time
...
even
var1:
dc.b 10
var2:
dc.b 10
But now let's say I get crazy with the evens and do this
move.w var1,d0 ; get both var1 and var2 at the same time
...
even
var1:
dc.b 10
even
var2:
dc.b 10
Oopsi! I just made the code fail in a hard to trace manner because the code is trying to load both vars at once, but that second even pushes var2 off a byte so that it won't load with that move.w. So you just can't stick evens EVERYWHERE or you may break the code. Such is the joy and fun of assembly!
So I found out earlier. The HUD screwed up and etc when I put an even before it. So if anything ever goes wrong, I will mess around with evens there.
#49
Posted 25 March 2013 - 04:41 PM
Okay, HUGE bump here, but it looks like flamewing's question never got answered. Does his error report work on real hardware? Yes.
A while ago, I asked ChillyWilly to try my Sonic 2 Recreation out on real hardware. Right at the beginning of the ROM, an error occurred, reported by flamewing's report (which the error never happens on emulators). I've fixed it now and my hack works 100% on real hardware. But in conclusion, yes, flamewing's report works on real hardware. Thanks to ChillyWilly for testing.
A while ago, I asked ChillyWilly to try my Sonic 2 Recreation out on real hardware. Right at the beginning of the ROM, an error occurred, reported by flamewing's report (which the error never happens on emulators). I've fixed it now and my hack works 100% on real hardware. But in conclusion, yes, flamewing's report works on real hardware. Thanks to ChillyWilly for testing.

00