UMBC CMSC 211 |
Offset | Meaning |
---|---|
0h | INT 20h (old-style return to DOS instruction |
2h | segment of first paragraph above this program's allocation |
2ch | segment containing environment variables for this program |
32h | maximum number or open files for this program |
80h | number of bytes in command line, excluding command and terminating carriage return |
80h-0ffh | the command tail |
0Ah | ' ' | 'P' | 'a' | 'r' | '1' | ' ' | 'P' | 'a' | 'r' | '2' | 13 |
INCLUDE | PCMAC.INC | ||
.MODEL | SMALL | ||
ASSUME | NOTHING | ; When using multiple data segments, ; this is keeps this correct. | |
.STACK | 100h | ||
PSP | SEGMENT | AT 0-256 | |
ORG | 80h | ||
CmdL | |||
CmdLen | DB | ? | |
Command | DB | 127 DUP (?) | |
PSP | ENDS | ||
.DATA | |||
Msg | DB | 'My command tail is |' | |
.CODE | |||
CmdTail | PROC | ||
mov | ax, @data | ||
mov | ds, ax | ||
ASSUME | es:PSP | ||
_PutStr | Msg | ||
mov | bl, CmdLen | ; bx holds command length | |
sub | bh, bh | ||
cmp | bx, 126 | ; if command lenght > 126 | |
jle | LengthOK | ; force it to fit | |
LengthOK: | |||
mov | [Command + bx], '$' | Mark the end of the tail | |
_PutStr | Command, es | ; Command not in .DATA segment | |
ASSUME | ds : PSP | ; For documentation purposes | |
_PutCh | '|', 13, 10 | ||
_Exit | 0 | ||
CmdTail | ENDP | ||
END | CmdTail |
One last requirement, EXTRN symbols must be declared in the same segment (name) in which the symbol is actually defined.