Make your own free website on Tripod.com

This routine is to be assembled in Debug
Debug < amohawk.scr

The program can be used in batch files or at the command-prompt (pure dos or window box) to get user input and store it in an environment variable.

n amohawk.com
a 100
MOV SI,0080   ; point SI at command line (this is in the PSP)
LODSB         ; load users string length
AND AX,007F   ; mask high bits
JZ  0117      ; if no input jump
MOV DI,AX     ;
ADD DI,SI
MOV BYTE PTR [DI],24 ; terminate string with dollar sign (for Int21h 09h)
MOV DX,SI
INC DX
MOV AH,09
INT 21       ;print your user prompt: Dos Function Int21h 09h
MOV DX,01D3  ; location 0117
MOV AH,0A
INT 21       ; MSDOS - buffered keyboard input
CALL 01A0    ; proc to get env
MOV CX,BX    ; cx contains MCB size
MOV ES,AX    ;
XOR DI,DI    ;
XOR AL,AL    ;
CLD
REPNZ
SCASB ; compare string
JNZ 016C
ES:
CMP AL,[DI]
JZ  0171
MOV DX,DI
MOV BP,CX
MOV SI,0225
MOV CX,0008
REPZ
CMPSB ; compare strings
JZ  0147
MOV DI,DX
MOV CX,BP
JMP 012A
MOV CX,0051
REPNZ
SCASB
JNZ 016C
MOV SI,DI
MOV DI,DX
MOV CX,ES
MOV DS,CX
MOV CX,BX
SUB CX,SI
LODSB
AND AL,AL
JZ  0171
STOSB
LOOP 0164
JMP 016C
LODSB
AND AL,AL
JNZ 015F
STOSB
LOOP    015A
MOV AX,4C01   ;
INT 21        ; clean up: return to DOS
ES:
MOV BYTE PTR [DI],00
MOV AX,CS
MOV DS,AX
MOV AL,[01D4]
XOR AH,AH
ADD AX,0008
ADD AX,DI
CMP AX,BX
JNB 016C
MOV SI,0225
MOV CX,0008
REPZ
MOVSB
MOV SI,01D5
MOV CL,[01D4]
REPZ
MOVSB
XOR AX,AX
STOSW
MOV AX,4C00
INT 21
;__________________________________________
; procedure @01A0
; here we access the environment area of the PSP
PUSH    ES   ;save old ES
MOV AX,CS    ;code seg to ax
MOV ES,AX    ;and then to ES
ES:
MOV AX,[0014]
MOV ES,AX
ES:
MOV AX,[002C]  ; get environment block
               ; 2ch is a segment offset 
               ; to index the start of 
               ; the environment passed by the calling process ie command.com
AND AX,AX      ; environment block starts at 0
JNZ 01C0
MOV AX,ES      ; ax holds segment containing environment block
DEC AX         ; move back 1 segment to get MCB
MOV ES,AX
ES:            ; ES is now the MCB segment
ADD AX,[0003]  ; offset 3 contains size of MCB
ADD AX,0002    ; 
DEC AX         
MOV ES,AX      ; move back another segment
INC AX
ES:
MOV BX,[0003]
SHL BX,1       ; size turned is in paragraphs
SHL BX,1       ; so we shift left 4 times
SHL BX,1       ; i.e. multiply by 16
SHL BX,1       ; to get MCB size in bytes
POP ES
RET ;END OF PROC
;--------------D-A-T-A------------------------------
db 50,0
db 0,0,0,0,0,0,0,0,0,0
db 0,0,0,0,0,0,0,0,0,0
db 0,0,0,0,0,0,0,0,0,0
db 0,0,0,0,0,0,0,0,0,0
db 0,0,0,0,0,0,0,0,0,0
DB 0,0,0,0,0,0,0,0,0,0
DB 0,0,0,0,0,0,0,0,0,0
DB 0,0,0,0,0,0,0,0,0,0
db 'AMOHAWK=WOTEVER'
rcx
0134
w
q