User manual

ST assembler ST Assembler-Linker
20/89 Doc ID 11392 Rev 4
The suffix is not used when the label is referred to. Using of any suffixes other than .b, .w
and .l results in an error upon assembly.
For example:
lab equ 0 ; word-size label (default)
label1.b equ 5 ; byte-size label
label2.l equ 123 ; long label
segment byte at: 80 ‘ram’
bytes ; force the size of the label to bytes
count ds.b ; byte-size label
pointer ds.w ; byte-size label with a word-size
; space reserved at this address
4.3.3 Label relativity
There are two sorts of labels: absolute labels and relative labels.
Absolute labels are usually assigned to constants, such as IO port addresses, or
common values used within the program.
Relative labels are defined as (or derived from) an external label or a label derived from
the position of some program code. They are exclusively used for labels defined within
pieces of program or data.
For example:
lab equ 0 ; absolute label ‘count’
ioport equ $8000 ; absolute word label ‘ioport’
segment ‘eprom’
start ld X,#count
ld A,#’*’
loop ld ioport,A
dec X
jrne loop
stop jp stop ; then loop for ever
Only the linker can sort out the actual address of the code, as the assembler has no idea
how many segments precede this one in the class. At assembly time, labels such as 'start'
or 'loop' are actually allocated 'blank' values ($0000). These values will be filled later by the
linker. Labels such as 'count' or 'ioport', which were defined absolutely will be filled by the
assembler.
Source code lines that have arguments containing relative labels are marked with an 'R' on
the listing, showing that they are 'linker relative'. Segments are discussed in Section 4.4 on
page 26.