loopy wrote:(edit) Here, "nameless" is a misnomer, maybe "reusable" is more appropriate..
"Reusable" is a good word for discussing the underlying concept here. I don't use CA65's nameless labels much in my own code now that I've discovered its two other useful layers of local labels. Here, I explain @ labels and scoped ordinary labels.
CA65's
cheap local labels (also called @ labels), of the form '@here' and '@there', roughly correspond to x816's labels '+here' and '-there'. An @ label is visible only between one ordinary label and the next. Here, the two labels '@inner' are distinct because the ordinary label 'clearRAM' separates them:
Code: Select all
clearNametable:
lda #0
tay
ldx #4
@inner:
sta $2007
sta $2007
sta $2007
sta $2007
iny
bne @inner
rts
clearRAM:
lda #0
tax
@inner:
sta $00,x
sta $300,x
sta $400,x
sta $500,x
sta $600,x
inx
bne @inner
rts
An ordinary label can be made visible only inside the scope of a single procedure by wrapping the procedure in a .proc block. Here, the two labels 'inner' are distinct, called 'clearNametable::inner' and 'clearRAM::inner':
Code: Select all
.proc clearNametable
lda #0
tay
inner:
sta $2007
sta $2007
sta $2007
sta $2007
iny
bne inner
rts
.endproc
.proc clearRAM
lda #0
tax
inner:
sta $00,x
sta $300,x
sta $400,x
sta $500,x
sta $600,x
inx
bne inner
rts
.endproc
Disch wrote:Another thing that was a minor beef with nesasm for me was it's use of brackets for indirection instead of traditional parenthesis. Instead it used parenthesis for expresson evaluation. I can see how this would become an issue if you used parenthesis for both:
[...]
I thought about having a set of rules to dictate whether or not the parenthesis were in fact part of an expression or whether they were used to indicate indirection
I can't find anything in the CA65 manual that explains the algorithm that CA65 uses to distinguish these. But as far as I can tell, if the entire operand in a CA65 expression is one single parenthesized expression, CA65 treats it as indirection. Otherwise, CA65 treats it as absolute. Yes, this breaks C-style preprocessor macros, which employ parentheses to separate arguments and results from the precedence system, but CA65 has a
richer macro syntax than C.
Celius wrote:Parenthesis are good for real 6502 instructions, and brackets are good for expressions.
I thought parentheses vs. brackets were for distinguishing a 16-bit "near" address from a 24-bit "far" address on the 65C816. Because CA65 assembles both 6502 and 65C816 code, it has more need of such an algorithm.
Celius wrote:And it's also best to describe by the definition of the nameless lable why the code will jump to that point
Based on the elaborate comments you give with these labels, it might be better to summarize the comment into a cheap local label, such as '@notWithinX' in CA65 or '+notWithinX' in x816.