Scope modifiers: Difference between revisions

(Scope modifiers en FreeBASIC)
Line 68:
 
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|68000 Assembly}}==
Like most assembly languages, 68000 Assembly has no concept of scope in the traditional sense, as it uses a linear memory model and allows free jumping to any memory address. However, the assembler can implement scope with local labels. Syntax varies depending on the assembler, but some use a period <code>.</code> before a label name to indicate a local label that is only visible between two non-local labels.
 
<lang 68000devpac>
foo:
MOVE.L #$DEADBEEF,D0
MOVE.L #$16-1,D1
.bar:
DBRA D1,.bar ;any code outside "foo" cannot JMP, Bxx, BRA, or JSR/BSR here by using the name ".bar"
RTS
</lang>
 
=={{header|Ada}}==
1,489

edits