One thing to remember, is that # and () have very specific meanings in 6502, tied to the addressing mode, so you can't just put them at any random place:
- 6502 only support one expression, so no matter what you enters it has to make sense as something that can be evaluate to something that matches an existing addressing mode for this specific instruction
- # is ALWAYS used to denote an immediate value, and when used for that it's always the first character of the expression, you can't put it in the middle.
- Parenthesis are most of the time used with ,x and ,y addressing mode, if you try to use parenthesis in an expression which has ,x or ,y in it, you are basically making the whole line ambiguous to the assembler
If you look on the documentation
, you can see the following:
Valid expressions are, e.g.:
For Addressing modes that do not start with a bracket, you can even use a bracket at the beginning of an expression. Otherwise try this:
LDX (1+2)*2,y ; Wrong!
LDX 2*(1+2),y ; Right!
In your case, it means that this one is fine: lda ScreenAddressLow-VPYMAX_INV,y
but that one is not: lda (ScreenAddressLow-VPYMAX_INV,)y
The reason is that the assembler assumes that if it starts by a parenthesis, then it is a zero page address containing a pointer which is indexed through the Y register.
But, you can cheat by removing the ambiguity, which makes that one valid: lda 0+(ScreenAddressLow-VPYMAX_INV),y