home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Simtel MSDOS 1992 September
/
Simtel20_Sept92.cdr
/
msdos
/
batutl
/
batutl2.arc
/
GETDIGIT.ASM
< prev
next >
Wrap
Assembly Source File
|
1988-04-20
|
2KB
|
71 lines
TITLE GETDIGIT 12-13-83 [4-16-88]
;Toad Hall Disassembly, tweak
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
GetDigit proc near
MOV AH,30H ;get DOS version
INT 21H
or al,al ;2.0 or above?
jz WrongDos ; yep
;L010B:
XOR CX,CX
MOV SI,80H ;DOS's PSP cmd line
MOV CL,[SI]
or cl,cl ;anything there (length byte)
JZ Lup127 ; nope, go check for kbd input
DEC CL ;adjust cmd line length
MOV SI,82H ;snarf first char
Lup11E: MOV DL,[SI] ;snarf cmd line char
MOV AH,2 ;display output
INT 21H
INC SI ;next cmd line char
LOOP Lup11E
Lup127: MOV AX,0C07H ;Clear kbd, do function 7 (kbd input w/o echo)
INT 21H
or al,al ;zero? (nonzero means ASCII char)
JNZ GotChar ; nonzero, check for digit
;probably special char, snarf next char
MOV AH,7 ;direct kbd input w/o echo
INT 21H
JMP SHORT Lup127 ;and go back for more
GotChar:CMP AL,'0'
JB Lup127 ;below 0, discard, reloop
CMP AL,'9'
JA Lup127 ;above 9, discard, reloop
PUSH AX ;save the digit
MOV DL,AL ;display it
MOV AH,2 ;display output
INT 21H
POP AX ;restore digit
SUB AL,30H ;de-ascify
MOV AH,4CH ;Terminate process
INT 21H
WrongDos:
mov dx,offset Dos2Msg
MOV AH,9 ;display string
INT 21H
XOR AX,AX ;return Errorlevel=0
INT 21H ;terminate
Dos2Msg DB 'GETDIGIT requires DOS 2.0 or greater.',CR,LF
DB '$'
; DB 'GETDIGIT -- Copyright (C) 1983 Tony Alan Rhea'
GetDigit endp
CodeSeg ENDS
END GetDigit