RPGHacker / asar

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

[Asar2] Three letter variable names are not accepted anymore #294

Closed hellow554 closed 6 months ago

hellow554 commented 7 months ago

The following code won't get accepted anymore:

A = $23
AB = $23
ABC = $23
ABCD = $23
a.asm:3: error: (Einvalid_number): Invalid number.
    in block: [ABC = $23]

Commit that introduces this bug: baac3ffc0f8c511238c67e04a25b0d784a527c0b Ping @p4plus2 : Can you take a look at it, please?

It was originally detected because of this code:

common/labels.asm:28: error: (Einvalid_number): Invalid number.
    in block: [M7A = $00211B]
common/labels.asm:29: error: (Einvalid_number): Invalid number.
    in block: [M7B = $00211C]
common/labels.asm:30: error: (Einvalid_number): Invalid number.
    in block: [M7C = $00211D]
common/labels.asm:31: error: (Einvalid_number): Invalid number.
    in block: [M7D = $00211E]
common/labels.asm:32: error: (Einvalid_number): Invalid number.
    in block: [M7X = $00211F]
common/labels.asm:33: error: (Einvalid_number): Invalid number.
    in block: [M7Y = $002120]
common/labels.asm:39: error: (Einvalid_number): Invalid number.
    in block: [WH0 = $002126]
common/labels.asm:40: error: (Einvalid_number): Invalid number.
    in block: [WH1 = $002127]
common/labels.asm:41: error: (Einvalid_number): Invalid number.
    in block: [WH2 = $002128]
common/labels.asm:42: error: (Einvalid_number): Invalid number.
    in block: [WH3 = $002129]
common/labels.asm:47: error: (Einvalid_number): Invalid number.
    in block: [TMW = $00212E]
common/labels.asm:48: error: (Einvalid_number): Invalid number.
    in block: [TSW = $00212F]
p4plus2 commented 7 months ago

Screenshot_20240101-023514.png

randomdude999 commented 6 months ago

fixed an asar_2_beta now (for any 3-letter labels that are not valid instructions). however, lda = 123 still gives an invalid number error (this used to work in 1.9). i'm not sure whether this should be allowed, given that this creates somewhat nasty ambiguities, especially if we want to make asar even less whitespace-sensitive in the future. and well, this might look somewhat misleading anyways. so i'm currently leaning towards keeping this banned.

hellow554 commented 6 months ago

Yes, that would be a good idea. Maybe reporting an error like: "can't redefine opcode lda" or similar.

randomdude999 commented 6 months ago

well it's not redefining an opcode, it's creating a label called "lda". you can still do that like this:

lda:
lda lda

which is still valid. whether you should do that is a different question, but i don't think banning label names from coinciding with any instruction names is a good idea either, especially since the set of valid mnemonics depends on the current architecture, and spc700 and superfx include instructions like "stop", "sleep", or "loop", which i could totally see as being valid label names.

randomdude999 commented 6 months ago

none of the other devs seemed to object to lda = 123 being an error, so closing this as completed.