Motorola HC12 User Manual

Page of 328
User’s Manual
MCUez HC12 Assembler
194
Assembler Directives
MOTOROLA
Assembler Directives
8.29  OFFSET — Create Absolute Symbols
Syntax:
OFFSET
 <expression>
Description:
The
OFFSET
directive declares an offset section and initializes
the location counter to the value specified in <expression>. The
<expression> must be absolute and may not contain references
to external, undefined, or forward defined labels.
The
OFFSET
 section is useful to simulate data structure or a
stack frame.
Example:
The following example shows how
OFFSET
 can be used to
access elements of a structure.
6    6
OFFSET 0
7    7
000000
ID:
DS.B
1
8    8
000001
COUNT:
DS.W
1
9    9
000003
VALUE:
DS.L
1
10   10 0000 0007
SIZE:
EQU *
11   11
12   12
DataSec: SECTION
13   13 000000
Struct: DS.B SIZE
14   14
15   15
CodeSec:SECTION
16   16
entry:
17   17 000003 CE xxxx
LDX  #Struct
18   18 000006 8600
LDAA #0
19   19 000008 6A00
STAA ID, X
20   20 00000A 6201
INC COUNT, X
21   21 00000C 42
INCA
22   22 00000D 6A03
STAA VALUE, X
As soon as a statement affecting the location counter (other
than
EVEN
,
LONGEVEN
,
ALIGN
, or
DS
) is encountered after
the
OFFSET
 directive, the offset section is ended. The
preceding section is activated again, and the location counter is
restored to the next available location in this section.