138/317
6 - STMicroelectronics Programming Tools
The assembler automatically recognizes the addressing mode after the syntax of the operand,
as in the following examples:
LD A,#2; immediate
LD A,VALUE; direct short
LD A,VALUE2; direct long
LD A,VALUE,(X); indexed with short displacement
LD A,VALUE2,(X); indexed with long displacement
LD A,(X); indexed
LD A,[VALUE]; indirect short
LD A,[VALUE2]; indirect long
LD A,[VALUE,(X)]; indirect indexed with short displacement
LD A,[VALUE2,(X)]; indirect indexed with long displacement
assuming that the address of
VALUE
is less than
100h
and the address of
VALUE2
is above that
address.
The assembler translates each statement in turn, and assigns them to successive locations in
program memory. Provided the address of the first instruction is specified, all the following in-
structions have a defined place in memory.
6.1.3 Declaring variables
A variable, in the programming sense, is a piece of memory allocated to hold a particular data
object. This piece can range in size anywhere from a bit to the whole memory space; the most
common data types are bytes, words (double bytes), double words and arrays of these basic
data types. W hatever its type, a variable is given a symbolic name to be used in a program.
Another feature of a variable is that it may be changed during the execution of the program, in
which case it must reside in read-write memory or RAM.
We have already introduced the notion of symbolic data. The term
VALUE
given in the exam-
ples above is the symbolic name that the programmer may assign to a data object somewhere
in the addressable space. Since these names can be freely chosen, they can be meaningful
words that help the reader locate and recognize the various data. This is absolutely necessary
since numeric addresses immediately lead to confusion.
The second task the assembler performs is to assign addresses in memory. This is obvious as
far as the progra m is concerne d: the successive in structions are put at consecutive ad-
dresses, and the programmer only needs to supply the start address of the program for the
whole code to be determined. However, when data are involved, things are not so clear. A var-
iable is assigned a place in memory, by giving an address for its first byte. Some variables are
only one byte long; others are one word long, or two bytes; others are more complex data like
double words, structures, arrays, etc. To avoid one variable to overlapping another, it is nec-
essary to space them properly, according to their length. It is very cumbersome to calculate
Содержание 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 ...