home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
World_Of_Computer_Software-02-386-Vol-2of3.iso
/
b
/
batdoor.zip
/
MORE_R.ZIP
/
MORE_R.ASM
next >
Wrap
Assembly Source File
|
1986-11-20
|
11KB
|
253 lines
;
; MORE_R: A remote MORE for DOORS users.
;
; Courtesy of: The BBS of Excellence (312)398-2872
;
; To make this program work under COM2: change DataReg to 2F8h
; and LineReg to 2FDh
;
cseg segment byte public 'CODE'
assume cs:cseg,ds:cseg,es:cseg
org 100h
MORE_R proc near
jmp MainCode ; Skip over constant
;
CInd db 0 ; Indicator for "Continuous".
CR_Counter dw 0 ; Carriage return counter
Handle dw ? ; Save area for file "handle"
ASCIIZ dw ? ; Addr of ASCIIZ
DataReg dw 3F8h ; for COM1: 2F8h = COM2:
LineReg dw 3FDh ; for COM1: 2fDh for COM2:
ErrorMsg db 'Unable to open ',0
MoreMsg db 10,'More? [Y]es, [N]o, [C]ontinuous, [C/R=Yes]',0
WaitMsg db 13,10,'==[Press any key to continue]==',13,10,0
DataArea db 257 dup(0)
BadForm db 13,7,10,'Format MUST be "TYPE_R drive:/subdir/filename"',13,10,0
;
MainCode:
Call ValidateEntry ; Validate the Command line entry format
Call OpenFile ; Go Open the file
Call ClearLine ; Clear out the data in the line
Call DisplayFile ; Display the file
Call CloseFile ; Close the file
Int 20h ; Terminate program
MORE_R endp
ValidateEntry Proc Near
mov SI,80h ; point to the command buffer
Xor CX,CX ; Init the loop counter
Mov CL,[SI] ; Get the input length
Cmp CL,0 ; Was there no input ?
JZ BadEntry ; True...then abort
SkipLoop:
Inc SI ; Point to the next byte
Mov DL,[SI] ; Get the character
Cmp DL,' ' ; Is it Blank ?
Jnz ByteFound ; No...continue
Loop SkipLoop ; Else, keep on looking
ByteFound:
Mov ASCIIZ,SI ; Save the pointer
Cmp DL,97 ; Is it in lower case ?
Jb UpperCase ; No..don't change it
Sub DL,32 ; Make it upper case
UpperCase:
Cmp DL,'A' ; Is it Alpha ?
Jb BadEntry ; No...Abort
Cmp DL,'E' ; Is it too high ?
Ja BadEntry ; Yes..Abort
Inc SI ; Point to the colon
Mov DL,[SI] ; Get the character
Cmp DL,':' ; Is it a Colon ?
Jnz BadEntry ; No..Abort
Inc SI ; Point to the Slash
Mov DL,[SI] ; Get the character
Cmp DL,'\' ; Is it a slash ?
Jnz BadEntry ; No...Abort
;
LoopToEnd:
Inc SI ; Skip to the next character
Mov DL,[SI] ; Get the character
Cmp DL,13 ; End of the line ?
Jnz LoopToEnd ; No...keep on scanning
Xor AL,AL ; Init the work area
Mov [SI],AL ; Add an end-of-ASCIIZ indicator
Jmp ExitValidation ; Exit this routine
BadEntry:
Lea SI,BadForm ; Point to the error message
Call SendMsg ; Send it
Int 20h ; Abort processing
ExitValidation:
Ret
ValidateEntry Endp
ClearLine Proc Near
Mov DX,DataReg ; Point to the data
IN AL,DX ; Read a byte
IN AL,DX ; And the next one
ClearLineLoop:
Mov DX,LineReg ; Get the Line Register address xFDh
In AL,DX ; Get the Line status
And AL,1Fh ; Isolate DR/OR/PE/FE/or BI active
OR AL,AL ; Are they there?
Jz ExitReset ; No...Exit to caller
Mov DX,DataReg ; Point to the data register
In AL,DX ; Reset data area
Jmp ClearLineLoop ; Keep clearing any data
ExitReset:
ClearLine Endp
OpenFile Proc Near
Mov DX,ASCIIZ ; Point to the ASCIIZ string
Xor AL,AL ; No file protection
Mov AH,61 ; Set up the command
Int 21h ; Do the Open
Jc CantOpen ; If unable to open, tell the user
Mov Handle,AX ; Save the "handle"
Jmp ExitOpen ; Exit this routine
CantOpen:
Lea SI,ErrorMsg ; Point to the error message
Call SendMsg ; Display the message
Int 20h ; Terminate processing
ExitOpen:
Ret ; Return to the caller
OpenFile Endp
CloseFile Proc Near
Mov DX,Handle ; Get the file handle
Xor AX,AX ; Init the work register
Mov AH,62 ; Set up the command
Int 21h ; Execute it
Ret ; Return to caller
CloseFile Endp
DisplayFile Proc Near
DisplayLoop:
Call ReadFile ; Read some data
Or AX,AX ; End of file ?
Jz ExitDisplay ; Yes...terminate
Lea SI,DataArea ; Point to the data
Call SendMsg ; Display the data
Jmp DisplayLoop ; Keep on displaying
ExitDisplay:
Lea SI,WaitMsg ; Pause after last line
Call SendMsg ; Display message
Call ReadByte ; Wait for any response
Ret ; Return to caller
DisplayFile Endp
ReadFile Proc Near
Mov BX,Handle ; Get the file handle name
Lea DX,DataArea ; Point to the file area
Mov CX,256 ; Read 256 bytes
Xor AX,AX ; Init the work register
Mov AH,63 ; Set up the command
Int 21h ; Execute it
Ret
ReadFile Endp
SendMsg Proc Near
LineLoop:
Mov AL,[SI] ; Get the Character
Cmp AL,0 ; End of the Line ?
Jz ExitLine ; Yes...exit
Cmp AL,1Ah ; End of file ?
Jz ExitLine ; Yes..exit
Call SendByte ; Else display the character
Inc SI ; Point to the next character
Jmp LineLoop ; And continue
ExitLine:
Ret
SendMsg Endp
SendByte Proc Near
Push AX ; Save the byte
WaitLineLoop:
Mov DX,LineReg ; Get the Line Register address xFDh
In AL,DX ; Get the Line status
And AL,20h ; Is the Xmit buffer empty ?
Cmp AL,20h ; Is it?
Jne WaitLineLoop ; No...Exit to caller
Pop AX ; Restore the byte
Mov DX,DataReg ; Point to output port
Out DX,AL ; Output the character
Mov DL,AL ; Get the character
Mov AH,2 ; Setup to output to video
Int 21h ; Do it....
Cmp AL,13 ; Is this a carriage return ?
Jnz ExitByte ; No...forget it
Mov AL,CInd ; Get the indicator
Or AL,AL ; Is it set ?
Jnz ExitByte ; Yes.. don't count
Mov AX,CR_Counter ; Get the number of C/R's
Inc AX ; Add 1 to the total
Mov CR_Counter,AX ; save the total
Cmp AX,24 ; Is this the 24th line ?
Jb ExitByte ; No...forget it
Xor AX,AX ; Init the counter
Mov CR_Counter,AX ; reset to zero
Push SI ; Save the pointer
Lea SI,MoreMsg ; Get the request msg
Call SendMsg ; Display it
Pop SI ; restore the pointer
WaitForReply:
Call ReadByte ; Get the response
Cmp AL,'Y' ; Continue?
Jz ExitCR ; Yes..exit with a C/R
Cmp AL,13 ; Carriage return ?
Jz ExitCR ; Yes...exit with a C/R
Cmp AL,'N' ; No?
Jz No_Response
Cmp AL,'C' ; Continuous ?
Jz Cont ; Yes..go set it up
Mov AL,7 ; Get the bell
Call Out ; Make a noise
Jmp WaitForReply ; Wait for good input
Cont:
Mov AL,1 ; Set up an indicator
Mov CIND,AL ; And save it
Jmp ExitCR ; Return to caller wit C/R
No_Response:
Lea SI,WaitMsg ; tell Wait for a key to be pressed
Call Sendmsg ; Send that message
Call ReadByte ; Wait for a key pressed
Call CloseFile ; Close the file
Int 20h ; Terminate processing
ExitCR:
Mov AL,13 ; C/R byte
Call Out ; Output it
ExitByte:
Ret
SendByte Endp
ReadByte Proc Near
Read_Byte_Wait:
Mov DX,LineReg ; Get the line register address
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..go read it
Mov AH,1 ; Set up the status command
Int 16h ; Check keyboard status
Jz Read_Byte_Wait ; If none pressed, wait
Xor AH,AH ; Init work reg for read
Int 16h ; read the key
Jmp WaitExit ; Exit this routine
Get_Remote_Byte:
Mov DX,DataReg ; Point to the data register
In AL,DX ; Get the byte
WaitExit:
Cmp AL,91 ; Is it upper case ?
Jb FinalExit ; Yes..don't translate
Sub AL,32 ; Make Upper case
FinalExit:
Ret
ReadByte Endp
Out Proc near
Mov DL,AL ; Get the "beep" to output
Mov AH,2 ; Set up routine
Int 21h ; Sound off
Mov DX,DataReg ; Get the modem register
Out DX,AL ; Output to the COMx: port
Ret ; Return to caller
Out Endp
CSEG Ends
End MORE_R