140/317
6 - STMicroelectronics Programming Tools
Thus the assembler relieves the programmer from any calculation. Any change in the program
will be automatically accounted for when the source text is re-assembled.
6.1.4 Declaring constants
A constant, in assembler, may be of one of two kinds: the constant data, and the symbol def-
inition. In both cases, they are numeric (or string) values that are defined in the source text,
and remain unchanged for the whole life of the program.
6.1.4.1 Constant data
Constant data are similar to variables, in that they take up some bytes in memory to hold data.
The difference is that the data are defined in the source text, and cannot be changed while the
program is executing. For so, they are located in read-only memory (ROM). They are ac-
cessed in exactly the same way as variables. The value of these memory locations are de-
fined in the source text. Thus, a special pseudo-op is available that both reserves memory and
sets it to a user-defined value.
Syntax: The constant data are define using one of the pseudo-ops
DC.B
,
DC.W
,
DC.L
,
BYTE
,
WORD
,
LONG
and
STRING
. The DC pseudo-ops work like the DS pseudo-ops above, but in addi-
tion, they set the memory to the value of the operand field. Example:
.PowerOf2
DC.B 1,2,4,8,16,32,64,128
; powers of 2
The following instruction reads one byte from the table according to the value of the index
X
.
The input value being loaded first into
X
, the value in
A
after the execution is 2 raised to the
power
X
(1 for X=0, 2 for X=1, 4 for X=2, etc.):
LD A, PowerOf2,(X)
The pseudo-ops
BYTE
,
WORD
and
LONG
are similar to
DC.B
,
DC.W
and
DC.L
, respectively, but
with an important difference. When word and long data are stored in memory, it is important to
take care of the order of the bytes that make up a word or a long value. For example, the hex-
adecim al number
1234h
can be stored in bytes of increasing addresses either as the se-
quence
12h
,
34h
, or as the sequence
34h
,
12h
. The same applies to long values that are
stored in four bytes. Either method has its advantages and drawbacks, and in fact the market
is divided into the proponents of one method or the other. The Motorola style is to put the most
significant byte first, that is
34h
,
12h
. The Intel style is the opposite, i.e.
12h
,
34h
. The ST7 fol-
lows the Motorola style in its instruction syntax: when extended addressing mode is used, the
first byte of the address is the most significant one. The
JP
instruction, using the long indexed
mode, reads the destination address in memory starting with the most significant byte. If you
Содержание ST7 Series
Страница 1: ...ST7 8 BIT MCU FAMILY USER GUIDE JANUARY 1999 1 ...
Страница 238: ...238 317 8 C Language and the C Compiler 08 Burn bmp Then use the EPROMer programmer software as described in Chapter 7 ...
Страница 289: ...289 317 10 Second Application a Sailing Computer 10 befor Bs Rw Vw VMG AlphaR AlphaV Before the wind ...