Intel 210200-002 Baby Furniture User Manual


 
ARCHITECTURE AND
INSTRUCTIONS
The first time the INC instruction
is
exe-
cuted,
DS
will
contain OLD_DATA and the
indicated assumption on
DS
will
be correct.
But then
DS will
be
changed to NEW
_DATA,
and the same INC instruction
will
be executed a second time. Therefore, it
would be wrong for the assembler to make
assumptions about the contents
of
DS when
the INC instruction
is
executed. The assem-
bler must generate a segment-override prefix
- specifying the extra segment -
on
the
INC instruction, even though this prefix
would
be
unnecessary on the first execution
of INC.
In
order to tell the assembler not to make any
assumptions about
DS,
we
must place the
following assumption just before the INC
instruction:
CYCLE:
ASSUME
INC
DS:NOTHING
OLD~BYTE
Prior to, or at the very beginning of any seg-
ment containing code,
we
must tell the
assembler (via
an
ASSUME
statement) what
it should assume will be in the
CS register
when that segment
of
code
is
executed.
Instead
of
using
an
ASSUME
statement,
we
could tell the assembler which segment regis-
ter should be used for the execution of each
instruction.
For
example, the move of X to
ALPHA
in the previous example could be
written
as:
MOV BX, DS:X
MOV
ES:ALPHA,BX
This says
that
DS should be used when X
is
accessed, and ES should be used when
ALPHA
is
accessed. Since the processor
would normally use
DS when executing tbese
instructions, the assembler produces a segment-
overriding prefix when
. generating object
code for the second instruction, but not for
the first instruction.
Efficient Programming
N ow let's look at one of the shortcomings
of
memory segments to
see
how to get around it.
Memory segments
always start
on
16-byte
boundaries. Remember that the last 4 bits
of
segment starting addresses are zero. A seg-
ment can be up to
216 bytes long.
If
a
segment does not use all of its approximately
65,000 bytes, some other segment can start
just beyond the last byte used by the first
segment. But the second segment must also
start on a 16-byte boundary, and, therefore,
may not start immediately after the last byte
used by the first segment. This means there
could be up to
15
bytes wasted between
segments.
2-35
Suppose the first segment starts at address
10000
(hexadecimal)
and
uses
only
6D
(hexadecimal) bytes.
So the last byte used
is
at
address 1006C. The closest the second seg-
ment could start would be at address
10070,
thereby wasting the bytes at 1006D, 1006E,
and 1006F.
N ow, instead of starting the second segment
at
the lowest 16-byte boundary beyond the
last byte used by the first segment, start the
second segment
at
the highest 16-byte boun-
dary that does not cause any bytes to be
wasted: thus,
we
could start the second seg-
ment at address
10060.This results in the last
few
bytes -
13
to be exact - used by the
first segment to be also
in
the second
segment.
But the second segment would then simply
not use its first
few
bytes, which
is
efficient.
So, if the second segment starts at 10060, the
bytes in the second segment below offset
0000
are simply not used
by
the second seg-
ment. Therefore, no bytes are wasted.