home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
batch
/
library
/
batutl2
/
input.asm
< prev
next >
Wrap
Assembly Source File
|
1988-04-20
|
2KB
|
84 lines
TITLE INPUT 1-1-80 [4-16-88]
;Toad Hall Disassembly, tweak (almost a rewrite!)
LF EQU 0AH
CR EQU 0DH
;
;INITIAL VALUES : CS:IP 0000:0100
; SS:SP 0000:FFFF
CodeSeg SEGMENT
ASSUME DS:CodeSeg,SS:CodeSeg,CS:CodeSeg,ES:CodeSeg
ORG 100H
Input proc near
MOV DL,7 ;beep to console
MOV AH,2 ;display output
INT 21H
;Get the user kbd input
MOV AX,0C01H ;Clear kbd, do function 1 (kbd input w/echo)
INT 21H
CMP AL,1BH ;user entered escape?
JNZ NotEsc ; nope, continue
MOV CL,0FFH ;return Errorlevel = 0FFH
JMP SHORT Exit
NotEsc:
cmp al,'Z' ; upper case?
jle L0123 ; yep
AND al,5FH ; lowercase the char
L0123: mov ah,al ;save this char in AH
;Get the .BAT file's INPUT string from the PSP cmd line
MOV SI,80H ;point to PSP cmd line
MOV CX,20H ;loop counter 32 chars max
cld ;insure fwd
Lup129:
lodsb ;snarf a cmd line char
CMP AL,22H ;'"' quote char?
JZ GotQuote ; yep, continue
LOOP Lup129 ;and keep testing
;never hit closing quote
MOV CL,0FFH ;return Errorlevel = 0FFH
JMP SHORT Exit
GotQuote:
MOV CX,1 ;assume Errorlevel=1
Lup13C:
lodsb ;snarf next cmd line char
cmp al,22H ;'"' ;hit closing quote?
jz BadKey ; yep, delete it, reloop
cmp al,'Z' ;upper case?
jle L014C ; yep
and al,5FH ; make lower upper
L014C: cmp al,ah ; batch options char same as user input?
JZ Exit ; yep, done
INC CX ;bump Errorlevel
CMP CX,28H ;High as we go
JLE Lup13C ; still ok, reloop
MOV CL,0FFH ;illegal, return Errorlevel=0FFH
JMP SHORT Exit
BadKey:
MOV DX,OFFSET ClrInpt ;beep, delete offending char
MOV AH,9 ;display string
INT 21H
JMP SHORT Input ;go back and get new user input
Exit:
mov dx,offset CrLf ;print Cr/Lf to make things neat
mov ah,9 ;display string
int 21H
MOV AL,CL ;return Errorlevel in CL
MOV AH,4CH ;terminate process
INT 21H
ClrInpt DB 7,8,20H,8,'$' ;beep, overwrite user input
CrLf db CR,LF,'$' ;TH
; DB 'Copyright (c) Joe Dorner 1984'
Input endp
CodeSeg ENDS
END Input