Page 116 - Introduction to Microcontrollers Architecture, Programming, and Interfacing of The Motorola 68HC12
P. 116
4,2 Assembler Directives 93
Table 43. Assembler Directives
In all of our examples, we have set aside memory locations for variables. In the last
example, we set aside bytes for N, RESULT, and Z. The way we tell the assembler to do
this is with the DS (define space) directive. An optional postfix . B indicates bytes are
allocated. Here DS appears in the operation field and the number n in the operand field
tells the assembler that n bytes are being allocated. If no postfix is used, . B is assumed
by default. Alternatively, a postfix of .W indicates that words are allocated so the number
of bytes is 2«, and a postfix of .L indicates that long words are allocated so the number
of bytes is 4«. The label in the DS directive is the variable name that the allocated space
is given. The label is given the value of the address of its first, and perhaps only, byte,
In the program of Figure 4.3, RESULT is given the value $868, and Z is given the value
$86A.
The symbolic address N, which was introduced in §4.1, appears to have a split
personality, especially for data. The symbol N is being used in two different ways here,
as an address and as the value of a variable. The way to understand this is by analogy to a
glass of water. When you say "drink this glass," the glass is the container, but you mean
to drink the contents of the container. You do not expect the listener to be confused
because he or she would never think of drinking the container. So too, the symbolic
address N stands for the container, variable N's location, whereas the contents of the
container, the word at the address, is variable N's value. If you think hard enough, it is
generally clear which is meant. In the instructions LDX #L or LEAK L,PCR, the
symbolic address L is the address of the variable, which is the container. In the
instruction LDAA L, the symbolic address represents the contents, in that it is the
contents of location L that goes into A. But if you are confused about what is meant,
look to see if the symbolic address is being used to represent the container or Its
contents.
The DS assembler directive assigns a number to the symbolic address or container.
In the preceding example, N's container has the value $868 because $868 is the address of