Scope modifiers: Difference between revisions

Line 38:
scoped_notdefinedlocally scope gives x = From scope at outerfunc
</pre>
 
=={{header|6502 Assembly}}==
Like most assembly languages, 6502 has no concept of scope. Scope can be enforced by the assembler itself. While this may seem like a bad thing, since scope is by definition a limitation on variables the programmer can access, an assembler that implements scope can allow the programmer to reuse labels (which would otherwise have to be unique throughout the entire program).
 
Assemblers have different syntax for local labels, usually a period or an @ sign is used.
Example of a macro definition that uses a local label:
<lang 6502asm>macro LDIR,source,dest,count
;LoaD, Increment, Repeat
lda #<source
sta $00
lda #>source
sta $01
 
lda #<dest
sta $02
lda #>dest
sta $03
 
ldx count
ldy #0
\@:
lda ($00),y ;load a byte from the source address
sta ($02),y ;store in destination address
iny ;increment
dex
bne \@ ;repeat until x=0
endm</lang>
 
=={{header|Ada}}==
1,489

edits