Motorola HC12 사용자 설명서

다운로드
페이지 328
User’s Manual
MCUez HC12 Assembler
146
Assembler Syntax
MOTOROLA
Assembler Syntax
Symbols can be defined relocatable in the label field of an instruction or data
definition source line. In the next example,
labelx
 is used to represent a
symbol.
Sec: SECTION
label1: DC.B 2 ; label1 is assigned offset 0 within Section
label2: DC.B 5 ; label2 is assigned offset 2 within Section
label3: DC.B 1 ; label3 is assigned offset 7 within Section
Figure 7-1. Relocatable Symbols Program Example
It is also possible to define a label with either an absolute or previously defined
relocatable value, using a SET or EQU directive.
Symbols with absolute values must be defined with constant expressions.
Sec: SECTION
label1: DC.B 2
; label1 is assigned offset 0
; within Section
label2: EQU 5
; label2 is assigned value 5
label3: EQU label1
; label3 is assigned address of
; label1
Figure 7-2. Set or EQU Directive Program Example
7.5.2  External Symbols
A symbol can be made external using the XDEF directive. In another source
file, an XREF or XREFB directive may reference the symbol. Since its address
is unknown in the referencing file, it is considered to be relocatable.
XREF extLabel
; symbol defined in another module
; extLabel is imported in the current
; module
XDEF label
; symbol is made external for other
; modules
; label is exported from the current
; module
constSec: SECTION
label:    DC.W 1, extLabel
Figure 7-3. External Symbol Program Example