RPGHacker / asar

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

Bugs that only troublemakers will find #268

Open Alcaro opened 1 year ago

Alcaro commented 1 year ago

\ !rb as3 A = 0 namespace B A = A+1 \ Errors occurred while assembling. \:4: 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: [A = A+1]

This should definitely be some kind of error, but probably not one that says report to github. And I'm sure you can create worse breakage than moving labels, like ifs that evaluate differently between passes.

e: Example of worse breakage: \ !rb as3 A = 0 namespace B if A == 0 walrus endif A = A|1 \ 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

(the phantom doesn't even have a filename)

Alcaro commented 1 year ago

I don't feel like filing a new issue for this one, so let's just repurpose this one to 'bugs that only troublemakers will find' and not bother fixing them.

\ !rb as3 arch spc700 tcall $8008-forward_label forward_label: \ 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

First pass - it guesses zero on forward_label, evaluates to tcall $8008, and errors out because max is $0F. Second pass - forward_label is $8000, so this is tcall $08 and is legal. Third pass - forward_label is now $8001, but tcall $07 is legal too. The 'invalid tcall' error is only reported in this pass, but it raised the 'there was an error' flag in first pass.

Alcaro commented 1 year ago

\ !rb as3 -l macro test(num) ?- bra ?neg_1_1 endmacro %test(1) \ 80 FE Labels: $008000 :macro_0_neg_1_1

Should be :macro0:neg_1_1 or :macroneg_0_1_1 or something. The point of the colons in label names is to make special labels unnameable other than by their intended name.

Alcaro commented 1 year ago

\ !rb as3 org $008000 lda label1,x label2: org $008000+($008004-label2)*65536 label1: \ Errors occurred while assembling. \:4: 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: [label2:]

I've never liked org Label, and here's why.

randomdude999 commented 5 months ago
function h(a) = $1a
db h(2)

writes out $12.

function h(x) = b
db h(0)

causes an out-of-bounds read (though i think it's mostly harmless?)