Scope modifiers: Difference between revisions

m
Line 58:
ldx count
ldy #0
\@: ;this is a local label
\@:
 
lda ($00),y ;load a byte from the source address
sta ($02),y ;store in destination address
Line 65 ⟶ 66:
bne \@ ;repeat until x=0
endm</lang>
 
The assembler calculates the necessary byte offset for the branch to work, by counting the bytes each instruction takes between the label and the branch to that label. That value becomes the operand of the <code>BNE</code> instruction in the macro. Since there is no label associated with any particular instance of \@ you cannot for example use <code>JMP \@</code> outside the macro to go there. (Of course, if you know the exact memory location an instruction is located at, you can jump there by specifying a numeric address, no matter what scope rules the assembler imposes.)
 
=={{header|Ada}}==
1,489

edits