The assignments of the segments to the segment registers are made with directives which are written
The statement
ASSUME CS:CODE_SEG,DS:SEG1,ES:SEG2
It is important to note that the ASSUME directive does not load the segment addresses into the corresponding segment registers.
Referring to the structure given in Fig. 3-63, the code segment might typically begin as follows:
CODE_SEG SEGMENT
ASSUME CS:CODE_SEG, DS:DATA_SEG1, ES:DATA_SEG2
START: MOV AX,DATA_SEG1
MOV DS,AX
MOV AX,DATA_SEG2
MOV ES,AX
.
.
.
CODE_SEG ENDS
|
Just as an END statement is needed to signal the end of a high-level language program, an END directive of the form
Figure 3-64 Complete program
DATA_SEG SEGMENT
OPER1 DW 12
OPER2 DW 230
RESULT DW ?
DATA_SEG ENDS
CODE_SEG SEGMENT
ASSUME CS:CODE_SEG, DS:DATA_SEG
START: MOV AX,DATA_SEG
MOV DS,AX
MOV AX,OPER1
ADD AX,OPER2
JGE STORE
NEG AX
STORE: MOV RESULT,AX
HLT
CODE_SEG ENDS
END START
|
This is page 49.