Chapter
4.
Assembler
Directives
If the optional label
is
present, it
is
assigned the current value
of
the location counter, and thus references the
first byte
of
the reserved memory block.
If the value
of
the operand expression
is
zero, no memory
is
reserved. However, if the optional label
is
present,
it
is
assigned the current value
of
the location counter.
The
OS
directive reserves memory
by
incrementing the location counter
by
the value
of
the operand expression.
Example:
TIVBUF:
OS
72 ;RESERVE 72 BVTES FOR
;A
TERMINAL OUTPUT BUFFER
Programming Tips: Data Description and Access
4-6
I?andom Access Versus Read Only Memory
When coding data descriptions, keep
in
mind the mix
of
ROM
and
RAM
in
your application.
Generally, the
DB
and
OW
directives define constants, items that can
be
assigned
to
ROM. Vou can
use
the~e
items
in
your program,
but
you cannot modify them. If these items are assigned
to
RAM, they have
an
initial
value
that
your
program can ,modify during execution. Notice, however,
that
the,e initial values must be reloaded
into memory prior
to
each execution
of
the program.
Variable data
in
memory must
be
assigned to
RAM.
Data Description
Before coding your program, you must have a thorough understanding
of
its input and
output
data. But you'll
probably find
it
more convenient to postpone coding the data descriptions until the remainder of the program
is
fairly well developed. This way you
will
have a better idea
of
the constants and workareas needed
in
your program.
Also, the organization
of
a typical program places instructions
in
lower memory, followed
by
the data, followed
by
the stack.
Data
Access
Accessing data from memory
i, typically a two-step process: First you tell the processor where
to
find the data,
then the processor fetches the data from memory and loads it into a register, usually the accumulator. Therefore,
the following code sequences have the identical effect of loading the
ASCII character A into the accumulator.
AAA:
DB
'A'
LXI
B,AAA
LDAX B
ALPHA:
DB
LXI
LDAX
'ABC'
B,ALPHA
B