RPGHacker / asar

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

External labels are incorrectly processed when used in code in structs #218

Open breakmit-0 opened 3 years ago

breakmit-0 commented 3 years ago

when writing code in a struct, any label has its first character replaced by '.' and is then assumed to be part of the struct:

org $008000
struct test $008000
    .label1
    jmp ExternalLabel ;incorrect

    .label2
    jmp .label1  ;works fine

    .label3
    jmp Zlabel1  ;incorrect, should throw an error but refers to test.label1
endstruct

ExternalLabel:

test.asm:6: error: (E5060): Label 'test.xternalLabel' wasn't found. [jmp ExternalLabel]

RPGHacker commented 3 years ago

This is a funny one. Didn't know structs did weird stuff with label names.

Wonder what the correct behavior here should be. Just throw errors for most commands/opcodes when used inside structs? Seems like the most reasonable idea.

Alcaro commented 3 years ago

Okay but we fixed that one five months ago, we just didn't make a release since then.

(Or rather, we improved the error into "Invalid label name" x2. I don't know what code in a struct is supposed to mean.)

p4plus2 commented 2 years ago

This is indeed fixed in the repo but before I close it, is there any strong reason you want case number 1 (externallabel) to work? The current status it now produces an error. I'm not going to call code in structs useless (could be handy for generating code to be modified in WRAM or something?) But using specific labels doesn't seem all too useful since structs will be overwritten unless you use skip sizeof(mystruct) after defining the struct.