If you declare a scope after a label you can access the labels inside the scope as fields on the declared label. This is handy if you use scoping to make the labels of your functions local:
lda #’ ‘
sta clearScreen.fillbyte+1
jsr clearScreen
rts
clearScreen: {
fillbyte: lda #0
ldx #0
loop:
sta $0400,x
sta $0500,x
sta $0600,x
sta $0700,x
inx
bne loop
rts
}
The above code fills the screen with black spaces. The code that calls the clearScreen subroutine use clearScreen.fillbyte to access the fillbyte label. If you use the label directive to define the fillbyte label, the code can be done a little nicer:
lda #’a’
sta clearScreen2.fillbyte
jsr clearScreen2
rts
ClearScreen2: {
.label fillbyte = *+1
lda #0
ldx #0
loop:
sta $0400,x
sta $0500,x
sta $0600,x
sta $0700,x
inx
bne loop
rts
}
Now you don't have to remember to add one to the address before storing the fill byte.
Label scopes also works with the label directive, so its also possible to write programs like this:
.label mylabel1= $1000 {
.label mylabel2 = $1234
}
.print “mylable2=”+mylabel1.mylabel2





