RPGHacker / asar

(Now) official repository of the SNES assembler Asar, originally created by Alcaro
Other
195 stars 42 forks source link

arch superfx is haunted #282

Open Alcaro opened 1 year ago

Alcaro commented 1 year ago

bug 1: [23:18:18] \ !rb as3 arch superfx : move ($00fe),r0 [23:18:18] \ 3E A0 FE [23:18:20] \ !rb as3 arch superfx : move ($01fe),r0 [23:18:21] \ 3E A0 FE needs a >>1 on the operand. same for move r0,($00fe) https://github.com/RPGHacker/asar/blob/asar_2_beta/src/asar/arch-superfx.cpp#L276 https://github.com/RPGHacker/asar/blob/asar_2_beta/src/asar/arch-superfx.cpp#L322

bug 2: [23:18:58] \ !rb as3 arch superfx : move r0,#$1234 : label: [23:18:58] \ Errors occurred while assembling. \:2: error: (Elabel_moving): Internal error: A label is moving around. Please create an issue on the official GitHub repository and attach a patch which reproduces the error. in block: [label:] [23:39:45] \ !rb as3 arch superfx : move r0,($0200) : label: [23:39:45] \ Errors occurred while assembling. \:2: error: (Elabel_moving): Internal error: A label is moving around. Please create an issue on the official GitHub repository and attach a patch which reproduces the error. in block: [label:] due to the 'don't do math on pass!=2' thing, it's 0 on pass==0 and pass==1, so it chooses ibt. but on pass==2, it's 0x1234, so it picks iwt, which is one byte bigger and moves the label. better undo that math optimization, at least for these instructions on pass==1 https://github.com/RPGHacker/asar/blob/asar_2_beta/src/asar/arch-superfx.cpp#L229 https://github.com/RPGHacker/asar/blob/asar_2_beta/src/asar/arch-superfx.cpp#L259 https://github.com/RPGHacker/asar/blob/asar_2_beta/src/asar/arch-superfx.cpp#L304

bug 3: [23:19:54] \ !rb as3 arch superfx : lms r4,($1234) [23:19:54] \ Errors occurred while assembling. : error: (Ephantom_error): A phantom error occurred. This is an Asar bug, please report it: https://github.com/RPGHacker/asar/issues move https://github.com/RPGHacker/asar/blob/asar_2_beta/src/asar/arch-superfx.cpp#L59 to pass==2

bug 4: [23:32:05] \ !rb as3 arch superfx : or #0 [23:32:05] \ Errors occurred while assembling. :2: error: (Esuperfx_invalid_register): Invalid register for opcode; valid range is 1-15. in block: [or #0] I can buy that not being a valid value for that instruction, but I don't think that's a register https://github.com/RPGHacker/asar/blob/asar_2_beta/src/asar/arch-superfx.cpp#L159-L170

bug 5: why do phantom errors print the github link but moving label does not

bug 6: how did none of this show up in the test suite, this ain't even tricky stuff

randomdude999 commented 1 year ago

okay but how do you even solve this

org $01fa arch superfx move r0,(label) ; uses short form on pass 0, long on pass 1, short again on pass 2 label: ; switches between $01fe, $01ff, $01fe

is banning labels here ok?

MarioFanGamer commented 5 months ago

okay but how do you even solve this

org $01fa arch superfx move r0,(label) ; uses short form on pass 0, long on pass 1, short again on pass 2 label: ; switches between $01fe, $01ff, $01fe

is banning labels here ok?

As someone who likes to use labels over raw addresses and defines in favour of Assembler optimisation, I very much like to see them supported. Not that I use macro opcodes myself but I see that viable if one were like to use both labels and macro opcodes.