To escape the current scope, use @ to reference the root scope. In the following code '@myLabel' access the myLabel label in the root scope:
.label myLabel = 1 { .label myLabel = 2 .print "scoped myLabel="+ myLabel //<-- Returns 2 .print "root myLabel="+ @myLabel //<-- Returns 1 }
The same can be done for functions, macros and pseudo commands. So the following example will print 'root' not 'mySpace':
.function myFunction() { .return "root"} .namespace mySpace { .function myFunction() { .return "mySpace" } .print @myFunction() }
You can also put new entities in the root scope when defining them from within another scope:
jsr outside_label rts { @outside_label: lda #0 sta $d020 sta $d020 rts }
or:
{ .label @x = 1234 .var @y= "Hello world" .const @z= true } .print "x="+x .print "y="+y .print "z="+z
Or for functions, macros or pseudo commands, here shown in a library file:
#import "mylib.lib" .print myFunction() MyMacro() MyPseudoCommand
/* File mylib.lib */ #importonce .filenamespace MyLibrary .function @myFunction() { .return 1 } .macro @MyMacro() { .print "Macro Called" } .macro @MyPseudoCommand { .print "PseudoCommand Called" }