|
.globl
For the sake of sdcc: Declare the named Pseudo instructions: Label definition Numeric expressions: Labels 8080 Assembler: Labelslabel to be global.
The Pseudo instructions: Label definition Numeric expressions: Labels 8080 Assembler: Labelslabel is either defined in the current Assembler directives: #local, #endlocal, .local and .endlocal Pseudo instructions: #local, #endlocal, .local and .endlocal Including C Source Files: #local, #endlocal, .local and .endlocallocal scope after this declaration or it is referenced there.
Undefined global labels can be picked up later by the '#include: #include library #include: #include library#include library' assembler directive.
Assembler directives: #local, #endlocal, .local and .endlocal Pseudo instructions: #local, #endlocal, .local and .endlocal Including C Source Files: #local, #endlocal, .local and .endlocal#local
.globl foo
...
foo: nop
...
Assembler directives: #local, #endlocal, .local and .endlocal Pseudo instructions: #local, #endlocal, .local and .endlocal Including C Source Files: #local, #endlocal, .local and .endlocal#endlocal
The same effect can be achieved by putting two colons after the label definition:
Assembler directives: #local, #endlocal, .local and .endlocal Pseudo instructions: #local, #endlocal, .local and .endlocal Including C Source Files: #local, #endlocal, .local and .endlocal#local
...
foo:: nop
...
Assembler directives: #local, #endlocal, .local and .endlocal Pseudo instructions: #local, #endlocal, .local and .endlocal Including C Source Files: #local, #endlocal, .local and .endlocal#endlocal
Assembler directives: #local, #endlocal, .local and .endlocal Pseudo instructions: #local, #endlocal, .local and .endlocal Including C Source Files: #local, #endlocal, .local and .endlocal#local
.globl foo
...
jp foo
...
Assembler directives: #local, #endlocal, .local and .endlocal Pseudo instructions: #local, #endlocal, .local and .endlocal Including C Source Files: #local, #endlocal, .local and .endlocal#endlocal
Unless you have a nested Assembler directives: #local, #endlocal, .local and .endlocal Pseudo instructions: #local, #endlocal, .local and .endlocal Including C Source Files: #local, #endlocal, .local and .endlocallocal context, this is identically to:
Assembler directives: #local, #endlocal, .local and .endlocal Pseudo instructions: #local, #endlocal, .local and .endlocal Including C Source Files: #local, #endlocal, .local and .endlocal#local
...
jp foo
...
Assembler directives: #local, #endlocal, .local and .endlocal Pseudo instructions: #local, #endlocal, .local and .endlocal Including C Source Files: #local, #endlocal, .local and .endlocal#endlocal
In almost all cases the .globl declaration is superfluous. zasm automatically adds the Pseudo instructions: Label definition Numeric expressions: Labels 8080 Assembler: Labelslabel to the list of undefined Assembler directives: #local, #endlocal, .local and .endlocal Pseudo instructions: #local, #endlocal, .local and .endlocal Including C Source Files: #local, #endlocal, .local and .endlocallocal Pseudo instructions: Label definition Numeric expressions: Labels 8080 Assembler: Labelslabels and pushes it at each Assembler directives: #local, #endlocal, .local and .endlocal Pseudo instructions: #local, #endlocal, .local and .endlocal Including C Source Files: #local, #endlocal, .local and .endlocal#endlocal to the outer context until it finds a context where it is defined – finally the global context where it can be picked up by the '#include: #include library #include: #include library#include library' assembler directive Assembler directives: #if, #elif, #else, #endif Pseudo instructions: if, endifif it is still undefined then.
Actually all references to symbols in system libraries as included by the c compiler are handled this way, without the need to define them all ahead.
.globl is useful in nested Assembler directives: #local, #endlocal, .local and .endlocal Pseudo instructions: #local, #endlocal, .local and .endlocal Including C Source Files: #local, #endlocal, .local and .endlocallocal contexts where the same name might be defined in an outer but not the global context.
.globl may also be useful Assembler directives: #if, #elif, #else, #endif Pseudo instructions: if, endifif you want to redefine a redefinable Pseudo instructions: Label definition Numeric expressions: Labels 8080 Assembler: Labelslabel. Inside a Assembler directives: #local, #endlocal, .local and .endlocal Pseudo instructions: #local, #endlocal, .local and .endlocal Including C Source Files: #local, #endlocal, .local and .endlocallocal context it is impossible to redefine a Pseudo instructions: Label definition Numeric expressions: Labels 8080 Assembler: Labelslabel, because this would define a new Assembler directives: #local, #endlocal, .local and .endlocal Pseudo instructions: #local, #endlocal, .local and .endlocal Including C Source Files: #local, #endlocal, .local and .endlocallocal Pseudo instructions: Label definition Numeric expressions: Labels 8080 Assembler: Labelslabel instead, except Assembler directives: #if, #elif, #else, #endif Pseudo instructions: if, endifif you define it .globl.
foo defl 0
...
Assembler directives: #local, #endlocal, .local and .endlocal Pseudo instructions: #local, #endlocal, .local and .endlocal Including C Source Files: #local, #endlocal, .local and .endlocal#local
...
.globl foo
foo defl 1
...
Assembler directives: #local, #endlocal, .local and .endlocal Pseudo instructions: #local, #endlocal, .local and .endlocal Including C Source Files: #local, #endlocal, .local and .endlocal#endlocal
| |