home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
World_Of_Computer_Software-02-386-Vol-2of3.iso
/
b
/
batdoor.zip
/
ECHO_R2.ZIP
/
ECHO_R.ASM
next >
Wrap
Assembly Source File
|
1986-12-19
|
7KB
|
147 lines
; ==================================================== ;
; ;
; ECHO_R: A remote ECHO for DOORS users. ;
; ;
; Courtesy of: The BBS of Excellence (312)398-2872 ;
; ;
; Version 2.0 ;
; ==================================================== ;
cseg segment byte public 'CODE'
assume cs:cseg,ds:cseg,es:cseg
org 100h
ECHO_R proc near
jmp MainCode ; Skip over constant
;
ComInd db 0 ; Indicator for COM2 request
DataReg dw ? ; Output COM port
LineReg dw ? ; Input COM port
OffSet dw 0 ; Offset from 0000:0040 for the com port addr
;
ErrMsg db 7,13,'COM'
PortNum db ? ; Part of the message
db ': serial port not installed!',13,10,'$'
;
MainCode:
Call CheckForCom2 ; Put value in OFFSET
Mov BX,Offset ; COM1=0, COM2=2
Mov AX,40h ; Set up segment location
Mov DS,AX ; Port addresses are at segment 40h
Mov AX,DS:[BX] ; Get COM port address
Push CS ; Point to data area for .COM program
Pop DS ; Restore Data register
Add BX,48 ; Turn into ASCII
Mov PortNum,BL ; Get the byte for error message
Or AX,AX ; Is the serial port installed?
Jz NoPort ; No...Abort
Mov DataReg,AX ; Save the output port address
Add AX,5 ; Increment to the next port
Mov LineReg,AX ; Save the input port address
Mov SI,80h ; point to the command buffer
Xor CX,CX ; Init the loop counter
Mov CL,[SI] ; Get the input length
Or CL,CL ; Was there no input ?
JZ ExitWrite ; True...then exit
Mov DL,13 ; Start with a carriage return
Mov [SI],DL ; For local AND remote
Call Writeit ; And display it
Inc SI ; Point past the length
WriteLoop:
Inc SI ; Point to next character
Mov DL,[SI] ; Get the character
Cmp DL,'/' ; Is this a slash ?
Jnz CheckEsc ; No..bypass COM check
Mov DH,ComInd ; Get the indicator
Or DH,DH ; Have we passed this point ?
Jnz CheckEsc ; Yes..skip it
Mov DH,[SI+2] ; Check the format
Cmp DH,' ' ; is it blank ?
Jz SetCom ; Yes..go check
Cmp DH,13 ; Null entry ?
Jnz CheckEsc ; No..skip it
SetCom:
Mov DH,[SI+1] ; Get port number
Cmp DH,'1' ; Is it the default ?
Jz SetDefault ; yes..bypass it
Cmp DH,'2' ; For COM2?
Jnz CheckEsc ; No, skip it
SetDefault:
Add SI,2 ; Skip to next entry
Sub CX,2 ; Skip this stuff
Jmp NextEntry ; NextEntry
CheckEsc:
Cmp DL,'@' ; Is this an Esc character ?
Jne WriteScreen ; No...continue
Mov DH,[SI+1] ; Check the next character
Cmp DH,'[' ; Is it for ANSI?
Jnz WriteScreen ; No...don't change it
Mov DL,27 ; Change to a REAL Esc character
Mov [SI],DL ; And save it for later
WriteScreen:
Call Writeit ; Display the character
NextEntry:
Loop WriteLoop ; Get another
ExitWrite:
Mov DL,13 ; Get a carriage return
Mov [SI],DL ; For local and comx
Call Writeit ; Display it
Mov DL,10 ; Get a line feed
Mov [SI],DL ; For local and comx
Call Writeit ; And display it
Int 20h ; Terminate program
NoPort:
Mov AH,9 ; Prepare to write
Lea DX,ErrMsg ; Point to error message
Int 21h ; Display it
Int 20h ; Terminate program
Echo_r Endp
CheckForCom2 Proc Near
Mov SI,80h ; Point to command line
Xor CH,CH ; Init work register
Mov CL,[SI] ; Get size
Or CL,CL ; Is it zero ?
Jz CommandExit ; Yes..skip it
Inc SI ; Go past the length
Com2Loop: Mov AL,[SI] ; Get the preceding blank
Cmp AL,' ' ; Is it REALLY blank ?
Jnz NotIt ; Nah...keep on looking
Mov AL,[SI+1] ; Get a character
Cmp AL,'/' ; Is it part of the indicator ?
Jnz NotIt ; No..skip it
Mov AL,[SI+2] ; Is the second byte there ?
Cmp AL,'2' ; Check it out
Jnz NotIt ; If not...skip it
Mov AL,[SI+3] ; A space must delimit
Cmp AL,' ' ; Does it?
Jz ThatsIt ; Yes..go play
Cmp AL,13 ; Or is it a carriage return ?
Jnz NotIt ; If not..skip it
ThatsIt: Mov AX,2 ; Get the offset
Mov Offset,AX ; And save it
Jmp CommandExit ; Then exit the routine
NotIt: Inc SI ; Point to the next byte
Loop Com2Loop ; Keep checking
CommandExit:
Ret
CheckForCom2 Endp
Writeit Proc Near
Mov AH,2 ; Code for screen write
Int 21h ; Write character to the screen
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
Mov DX,DataReg ; Point to output port
Mov AL,[SI] ; Get the character
Out DX,AL ; Output the character
Ret ; Return to main routine
WriteIt Endp
CSEG Ends
End ECHO_R