home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
World_Of_Computer_Software-02-386-Vol-2of3.iso
/
b
/
batdoor.zip
/
GETKEY_R.ZIP
/
GETKEY_R.ASM
next >
Wrap
Assembly Source File
|
1986-11-16
|
4KB
|
91 lines
;
; GETKEY_R: A remote "get ASCII value of key pressed" for .BAT DOORS users.
;
; Courtesy of: The BBS of Excellence (312)398-2872
;
; To make this program work under COM2: change the constant(s) as
; indicated.
;
cseg segment byte public 'CODE'
assume cs:cseg,ds:cseg,es:cseg
org 100h
GETKEY_R proc near
jmp ReadByteWait ; Skip over constant
;
LineReg dw 3FDh ; for COM1: 2FDh = COM2:
DataReg dw 3F8h ; for COM1: 2F8h = COM2:
;
ReadByteWait:
Mov DX,LineReg ; Get the Line Register address xFDh
In AL,DX ; Get the Line status
And AL,01h ; Isolate data ready bit
Cmp AL,01h ; Is there data ready
Jz Get_Remote_Byte ; Yes...clear buffer and exit
Mov AH,1 ; Set up status command
Int 16h ; Has a local key been pressed ?
Jz ReadByteWait ; No...keep on waiting
Xor AH,AH ; Set up read command
Int 16h ; clear the buffer
Jmp Validate ; Validate the entry
Get_Remote_Byte:
Mov DX,DataReg ; Point to the data register
In AL,DX ; Get the data byte
;
; Make sure that the key pressed was 1-9 or A-Z (upper case
; translation is automatic).
;
Validate:
Cmp AL,'1' ; Is it less than 1?
Jb BadEntry ; Yes...ignore it
Cmp AL,':' ; Is it numeric ?
Jb Compare ; Yes..check for command line compare
Cmp AL,'A' ; Is it alpha ?
Jb BadEntry ; No...ignore it
Cmp AL,'[' ; Upper case ?
Jb Compare ; Yes..Check for command line compare
Sub AL,32 ; Convert to upper case
Cmp AL,'A' ; Is it Alpha ?
Jb BadEntry ; Yes...Exit
Cmp AL,'[' ; Is it Alpha
Jb Compare ; Yes...Check for command line compare
BadEntry:
Mov DX,DataReg ; Point to output port
Mov AL,7 ; Get the "bell"
Out DX,AL ; Output the character
Mov DL,7 ; Get the "bell"
Mov AH,2 ; Setup to output locally
Int 21h ; Do it....
Jmp ReadByteWait ; Get a goob byte
Compare:
Mov SI,80h ; point to the command buffer
Xor CX,CX ; Init the loop counter
Xor DX,DX ; Init the work register
Mov CL,[SI] ; Get the input length
Or CL,CL ; Was there no input ?
JZ ExitProgram ; True...then exit
CompareLoop:
Inc SI ; Point past the length
Mov DL,[SI] ; Get the character
Cmp DL,' ' ; Is it a blank ?
Jz Continue ; Yes..keep on scanning
Cmp DL,'a' ; Is it lower case ?
Jb DoTheCheck ; No...continue normally
Sub DL,32 ; Yes..make it upper
DoTheCheck:
Mov DH,1 ; Set up non-blank indicator
Cmp AL,DL ; Is there a match ?
Jz ExitProgram ; Yes..exit program
Continue:
Loop CompareLoop ; Keep on compareing
Or DH,DH ; Was it all blanks ?
Jz ExitProgram ; Yes...the same as no command line
Jmp BadEntry ; No match..ignore entry
ExitProgram:
Mov AH,4Ch ; Prepare for errorlevel
Int 21h ; Exit with the ASCII code
GETKEY_R Endp
CSEG Ends
End GETKEY_R