asar
asar copied to clipboard
Wrong address when cleaning freespace blocks multiple times
I came across this in GPS where for some reason two label in different freespace blocks had the same address. The simples test case I could find is creating a rom with
check bankcross off org $008000 : rep $80000 : db $00
and then patching
print "previous test1: $",hex(read3($008000+1)) print "previous test2: $",hex(read3($008004+1)) print "new test1: $",hex(test1) print "new test2: $",hex(test2) org $008000 autoclean JML test1 org $008004 autoclean JML test2 freecode test1: db 1 org $008008 autoclean JML test1 freecode test2: db 2
twice which prints the following:
first run: previous test1: $0 previous test2: $0 new test1: $908008 new test2: $908011 second run: previous test1: $908008 previous test2: $908011 new test1: $908008 new test2: $908008
on the second run, both test1 and test2 have the same address even though they're supposed to be in separate freespace blocks.
edit: I should probably specify that this only happens if you one autoclean is before the freespace command and one after and then another freespace is requested.
Playing around with this a bit more: If test1 is cleaned, then requested then another freespace block is requested and then test1 is cleaned again asar throws an error (E5136): Don't autoclean a label at the end of a freespace block, you'll remove some stuff you're not supposed to remove. [autoclean JML test1]