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

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:

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 (?)

;this is the stack

TOP

EQU

THIS WORD

 

MY_STACK

ENDS

 

 

MY_CODE

SEGMENT

 

 

 

ASSUME

CS:MY_CODE,DS:MY_DATA

 

 

ASSUME

ES:MY_EXTRA,SS:MY_STACK

 

START:

MOV

AX,MY_DATA

;initializes DS

 

MOV

DS,AX

 

 

MOV

AX,MY_EXTRA

;initializes ES

 

MOV

ES,AX

 

 

MOV

AX,MY_STACK

;initializes SS

 

MOV

SS,AX

 

 

MOV

SP,OFFSET TOP

;initializes SP

 

ENDS

 

 

 

END

START

 

2-33

Page 68
Image 68
Intel 210200-002 manual Mydata Segment Ends Myextra Alpha Beta Gamma Mystack