The assignments of the segments to the segment registers are made with directives which are written

ASSUME      Assignment, . . . , Assignment
where each assignment is written
Segment register name:Segment name

The statement

ASSUME   CS:CODE_SEG,DS:SEG1,ES:SEG2
would inform the assembler that it is to assume that the segment address of CODE_SEG is in CS, of SEG1 is in DS, and of SEG2 is in ES. An assignment is not made for SS, presumably because either the stack is not used or the assignment for SS is in a separate ASSUME statement.

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

3-10-6 Program Termination

Just as an END statement is needed to signal the end of a high-level language program, an END directive of the form

END      Label
is needed to indicate the end of a set of assembler language code.

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

Table of Contents | Next page | Previous page

This is page 49.