ARCHITECTURE AND INSTRUCTIONS
First, intrasegment jump and call instructions require only the offset
Second,
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 |
|