ARCHITECTURE AND INSTRUCTIONS
First, intrasegment jump and call instructions
require only the offset (16-bits) of the new
location. Intersegment jump and call instruc-
tions require the segment (another 16-bits)
in
addition
to
the offset.
Second, data-accessing instructions that use
the current data segment and current stack
segment in the manner most optimal for the
8088 architecture contain only the offset
(l6-bits) of the data location. Any other
instruction that accesses a
data
location
within one
of
the four currently-addressable
segments must contain a segment-overriding
prefix (another 8-bits) in addition to the
MY_DATA
SEGMENT
X DB ?
Y
OW
?
Z
DO
?
MY_DATA
ENDS
MY_EXTRA SEGMENT
ALPHA DB ?
BETA
OW
?
GAMMA
DO
?
MY_EXTRA
ENDS
MY_STACK
SEGMENT
OW
100 DUP (?)
TOP EQU
THIS WORD
MY_STACK
ENDS
MY_CODE
SEGMENT
offset. Here, current refers to when the
instruction
is
executed, not assembled.
Therefore, to assemble the correct object
code, the assembler must know the segment
structure of the program and which segments
will be addressable - pointed
at
by segment
registers - when various instructions are
executed. This information
is
supplied by the
ASSUME
directive.
The following example shows how the
SEGMENT, ENDS, and ASSUME direc-
tives can be used to define a code, data, extra,
and stack segment:
;this is the stack
ASSUME
CS:MY _CODE,DS:MY
_DATA
START:
ASSUME
MOV
MOV
MOV
MOV
MOV
MOV
MOV
ENDS
END
ES:MY_EXTRA,SS:MY_STACK
AX,MY_DATA ;initializes
DS
DS,AX
AX,MY_EXTRA ;initializes
ES
ES,AX
AX,MY_STACK
;initializes
SS
SS,AX
SP,OFFSET TOP
;initializes SP
START
2-33