Different types of labels
RASM manages several types of labels according to different contexts
- Global labels, accessible with their name from all the sources
- Proximity labels, accessible quickly by their short name, or from any location in the sources by their full name
- Local labels, accessible only from the perimeter of a loop or a macro
- Modules, kind of super labels which encapsulate global labels (so, not so global, even if once again, they remain accessible from any place of the sources!)
Global labels
Simple as that, global labels always start with a letter or a
They are accessible from everywhere with the same name, they are the usual labels that every assembler knows
BANK 0
monlabel1 jp monlabel2
BANK 1
monlabel2 jp monlabel1
Proximity labels
Proximity labels begin with a dot (".")
Internally, a global label is created, concatenating the last global label with the proximity label
BANK 0
label_global ld b,5
.label_proximite djnz .label_proximite
BANK 1
label_global2 ld b,5
jp label_global1.label_proximite
Local labels
Inside a loop or a macro, a local label is only "seen" within the loop and only this loop. Thus, we can nest 3 loops and use the same local label name, it will be in fact 3 different labels internally, each belonging to its respective loop. Local labels start with the symbol @
repeat 10
@debut
repeat 10
ld b,5
@debut djnz @debut
rend
djnz @debut ; refer to first @debut
rend
Modules
With the MODULE directive, we declare a kind of super label that will prefix all global labels (and aliases!), and consequently, all proximity labels. The use of module makes the global label rule null and void ^_^
You can always call any label from anywhere, but respecting the module hierarchy
For those who are bothered by the _ separating the module name from the global label, it is possible to redefine this character with the command line option -msep
module soft1
label_global ; a global label, not so global because inside soft1 module!
djnz label_global
jp soft2_label_global
module soft2
label_global ; bis repetita
djnz label_global
jp soft1_label_global
It's possible to generate module names with variables
repeat 10,x
bank
module truc{x}
oneTwo nop
rend
Export labels
Since version 2.1, rasm is exporting chunks and special symbol files to work with the ACE emulator.
Exported labels are precisely positioned in the emulator (in RAM if declared in RAM, in ROM if declared in ROM).
However, you may need to relocate code (necessarily in RAM) from ROM.
It is therefore possible to declare labels as local (global by default) when they are relocated, in order to see them in the emulator
LABEL LOCAL ; all the following labels will be considered at their compilation location
LABEL GLOBAL; all following labels will be considered in the 64K addressable space
When assembling single files or from temporary spaces (using BANK without memory specificity), you can assign the current temporary space a precise location for the emulator
LOCALISATION RAM,4 ; all space labels will be assigned on page 4 of RAM
LOCALISATION ROM,LOWER ; all space labels will be assigned on Lower ROM
LOCALISATION ROM,14 ; all space labels will be assigned on ROM 14