Intel 210200-002 Baby Furniture User Manual


 
ARCHITECTURE AND INSTRUCTIONS
Observe that the code
at
the head of the
MY_CODE segment
will,
at program.execu-
tion, initialize the various segment registers to
point to the appropriate segments, and the
code
will
initialize .the stack pointer to point
to the end of the stack segment.
The
ASSUME statement makes the assem-
bler aware of segment register values when
the code
is
executed.
To illustrate the purpose of the
ASSUME
statement, let's consider code (within SEG-
MENT MY_CODE) that moves the contents
of byte X to byte ALPHA. To do this,
we
need an instruction that moves the contents
of X into a register, say BL, and
an instruction
that moves the contents of the register into
ALPHA. How about:
MOV
MOV
BL,X
ALPHA,BL
;from X to
BL
;from
BL
to ALPHA
During execution of such MOV instructions,
the
8088
processor would normally use the
DS register to find the starting address of the
OLD_DATA SEGMENT
OLD_BYTE DB ?
OLDJ)ATA
ENDS
NEW_DATA
SEGMENT
NEW_BYTE DB ?
NEW_DATA
ENDS
MORE-CODE
SEGMENT
segment where the specified item (X or
ALPHA)
is
located. This will work fine when
accessing X - the first instruction - because
DS will indeed contain the starting address of
segment
MY_DATA where X
is
located.
But, this
will
not work when accessing
ALPHA - the second instruction
~
because
the starting address of segment MY_EXTRA,
where
ALPHA
is
located, will not be con-
tained in
DS.
The ASSUME statement has made the
assembler aware that the first instruction will
execute properly. The assembler
is
also aware
(thanks to the
ASSUME statement) that the
starting address of MY_EXTRA, although
not in
DS, will
be
in one of the other segment
registers - namely
ES. The assembler, there-
fore, generates a segment-overriding prefix
for the second instruction so that it too, will
execute properly.
It's not always possible to know what
will
be
in the segment registers when a particular
instruction
will
be
executed. Consider:
ASSUME
CS:MORE_CODE
MOV
MOV
MOV
ASSUME
CYCLE:
INC
MOV
MOV
JMP
MORE_CODE
ENDS
AX,OU1-DATA
DS,AX
ES,AX
DS:OLD_DATA,ES:OLD_DATA
OLD_BYTE
AX,NEW_DATA
DS,AX
CYCLE
2-34
;put
OLD-DATA
into
;
..
.oS
and
;
...
ES
;what's in DS now?
;put NEW_DATA
;
..
.into
DS