home *** CD-ROM | disk | FTP | other *** search
- ;
- ; XC_TSR.ASM Mainline module of Terminate-Stay-Resident XCOMMS
- ;
- ; Copyright 1989, South Mountain Software Inc
- ; All Rights Reserved
- ;
- ; <Main> is called from THE_END module. It will setup the XCOMMS vector
- ; and will return to THE_END and make everything resident. If XCOMMS
- ; is already loaded, not enough memory for buffers, or no vectors
- ; are available an error message is returned.
- ;
- ; Invoke:
- ; XCOMMS Start XCOMMS TSR
- ; XCOMMS 8 Start XCOMMS TSR with 8K buffers
- ; XCOMMS 8 COMi Start and enable COMi interrupts
- ; XCOMMS 8 COMi Start and enable COMi interrupts
- ; XCOMMS 8 COMi COMj Start and enable COMi & COMj interrupts
- ; [Enable XON/XOFF with COMiX or COMjX]
- ;
- ; Return status (ERRORLEVEL):
- ;
- ; Successful:
- ; 0 Successfully installed
- ; Errors:
- ; 1 XCOMMS already installed
- ; 2 No vector available to install XCOMMS
- ; 3 Not enough space for buffers
- ; 4 Illegal argument (out of range or not working)
- ;
- ;
- ;
-
- ;
- ; ===============================================================
- ; References
- ; ===============================================================
- ;
-
- INCLUDE ECLMACRO.INC ; Default ECL assembler macros
- PUBLIC Main ; The TSR mainline routine
-
- ; The_end:
- EXTRN The_end : NEAR ; The end of the TSR program label
- EXTRN getarg : NEAR ; Get command argument routine
- EXTRN atoi : NEAR ; Convert ASCII string to integer
- ; XCOMMS kernal:
- EXTRN XCOMMS : NEAR ; The XCOMMS kernal interrupt driver
- EXTRN COMMS_GPORT : NEAR ; Verify port existence COMMS function
-
- ;
- ; ===============================================================
- ; Definitions
- ; ===============================================================
- ;
-
- NULL EQU 00h ; End of copyright message string
- CR EQU 0Dh ; Carriage return
- LF EQU 0Ah ; Line feed
-
- DEFAULT_XCOMMS EQU 7Fh ; Assumed this to be XCOMMS vector
- LOW_INTERRUPT EQU 41h ; This is the last one to search
- XCOMMS_ID EQU 0A66Ah ; Signature
- DEFAULT_BUFSIZE EQU 8 ; (in K bytes) the size of buffers
- BUFFER_SHIFT EQU 6 ; K/para shift left factor
-
-
-
-
- CSEG SEGMENT BYTE PUBLIC 'CODE'
- ASSUME CS:CSEG, DS:CSEG, ES:CSEG
- ;
- ; ===============================================================
- ; Local data
- ; ===============================================================
- ;
- ; NOTE - xcomms_int CONTAINING XCOMMS VECTOR IS WITHIN Main routine
- ;
-
- Copyr DB "XCOMMS revision 2.0", CR, LF
- DB "Copyright (C) 1986, 1987, 1988 Essential Software Incorporated", CR, LF
- DB "Copyright (C) 1986, 1987, 1988 Advanced Firmware Engineering", CR, LF
- DB NULL
-
- XCOMMS_buffers DW ? ; Number of buffers (1K each)
-
- ;
- ; ===============================================================
- ; Local procedures
- ; ===============================================================
- ;
- ; XCOMMS_Link Link the XCOMMS guy
- ; atoi ASCII to integer
-
- ;
- ; ===============================================================
- ; XCOMMS_Link Link the XCOMMS guy
- ; ===============================================================
- ;
- ; Called initially when XCOMMS is being setup from CLI.
- ;
- ; Input Description
- ; -------------- ---------------------------
- ; Not applicable
- ;
- ; Output Description
- ; -------------- ---------------------------
- ; CY = NC OK - linked successfully
- ; AL = 00
- ; CY = C Error - used by XCOMMS (or anything else)
- ; AL = 01 Already installed
- ; AL = 02 All vectors used - none are available
- ;
- ; Registers used Description
- ; -------------- ---------------------------
- ; CX Interrupt vector list counter
- ; ES, DX The vector segment register
- ; BX The vector offset
- ; ===============================================================
- ;
-
-
- XCOMMS_Link PROC NEAR
-
- PUSH ES
- PUSH DX
- PUSH CX
- PUSH BX
-
- ;
- ; Examine all of the available interrupt vectors between
- ; xcomms_int and LOW_INTERRUPT. If XCOMMS is already
- ; installed, an error code is returned. Otherwise, the
- ; vector number is stored (in xcomms_int) and the
- ; previous contents forgotten. THE TSR VERSION OF XCOMMS MUST
- ; ALWAYS KEEP ITS VECTOR!
- ;
- MOV CL, xcomms_int
- XOR CH, CH
- SUB CX, LOW_INTERRUPT
- INC CX ; Setup loop counter
- _XL_try_again:
- MOV AL, xcomms_int
- getvec
- MOV AX, BX
- OR AX, DX
- JNE _XL_loop ; Someone used it!
-
- MOV AL, xcomms_int
- MOV BX, OFFSET XCOMMS
- MOV DX, SEG XCOMMS
- setvec
- CLC
- MOV AL, 00h
- JMP SHORT _XL_Exit
-
- _XL_loop: ; Who owns the vector?
- MOV ES, DX
- CMP WORD PTR ES:[BX+2], XCOMMS_ID
- MOV AL, 01h
- JE _XL_Error ; XCOMMS is already there???
- DEC xcomms_int ; Look for another vector
- LOOP _XL_try_again
- MOV AL, 02h ; None are available
- _XL_Error:
- STC
- _XL_Exit:
- POP BX
- POP CX
- POP DX
- POP ES
- RET
- XCOMMS_Link ENDP
-
- ;
- ; ===============================================================
- ; Global procedures
- ; ===============================================================
- ;
- ; Main Entry program (called from THE_END module)
-
- ;
- ; ===============================================================
- ; Main Entry program (called from THE_END module)
- ; ===============================================================
- ;
- ; First the XCOMMS interrupt vector is allocated as long as
- ; (1) a vector is available, and
- ; (2) XCOMMS was not previously installed
- ;
- ; Next, XCOMMS_Entry routine (XCOMMS request 0002) is called
- ; with the buffer pool address and number of buffers to setup.
- ;
- ; Finally, the number of paragraphs are returned to reserve based
- ; on the following components:
- ; Take the size of the program (offset The_End) and divide by 16
- ; Add 1 for left overs
- ; Take the number of buffers, adjust based on 16 (BUFFER_SHIFT)
- ;
- ; NOTE - xcomms_int CONTAINING XCOMMS VECTOR IS WITHIN Main routine
- ;
- ; Input Description
- ; -------------- ---------------------------
- ; DS, CS Pointer to CSEG (this) segment
- ;
- ; Output Description
- ; -------------- ---------------------------
- ; AH = 00 Terminate (and DO NOT MAKE RESIDENT)
- ; AL Exit status (ERRORLEVEL)
- ; AH = 01 Terminate and make resident
- ; AL = 00 Success status
- ; DX Number of paragraphs to reserve for XCOMMS
- ;
- ; Registers used Description
- ; -------------- ---------------------------
- ; Not applicable
- ;
- ; ===============================================================
- ;
-
- Main PROC NEAR
-
- ; Setup all XCOMMS services
-
- CALL XCOMMS_Link ; First find a vector
- MOV AH, 0 ; Assume cannot make resident
- JNC _Main_skip
- JMP _Main_exit ; Already in Use! ERROR !!!!
- _Main_skip:
- ; Are there any arguments?
-
- CALL getarg
- MOV CX, DEFAULT_BUFSIZE
- JC _Main_buffer_init
- CALL atoi ; Convert the argument
- ; CX has number of buffers!
-
- ; Everything is OK - now invoke the XCOMMS kernal XC_entry
- ; function with the buffer addresses:
- ;
- ; DX:BX Buffer address
- ; CX Number of 1K buffers
-
- _Main_buffer_init:
- MOV XCOMMS_buffers, CX ; Save buffer count
- MOV BX, OFFSET The_End ; Base buffer address
- MOV DX, SEG The_End
- MOV AX, 0002 ; xc_entry kernal request
- CALL DO_XCOMMS
- ;
- ; Check if anymore arguments: (AX implies call to XCOMMS_link)
- ;
- ; argument AX CX DX
- ; COM1 1401 0000 0000
- ; COM2 1401 0000 0001
- ; COM1X 1401 0001 0000
- ; COM2X 1401 0001 0001
- ; |
- ; |
- ; V
-
- xcomms_loop:
- CALL getarg ; Get next argument
- JNC xcomms_nope ; Exit - no more arguments
- JMP xcomms_bye ; Exit - no more arguments
- xcomms_nope:
- MOV AX, 0004 ; Assume an argument error
-
- CMP BYTE PTR [SI], 'C' ; First character 'C'
- JE _1
- CMP BYTE PTR [SI], 'c'
- JE _1
- JMP _Main_exit ; Exit - illegal argument??
- _1:
- INC SI
- CMP BYTE PTR [SI], 'O' ; Second character 'O'
- JE _2
- CMP BYTE PTR [SI], 'o'
- JE _2
- JMP _Main_exit ; Exit - illegal argument??
- _2:
- INC SI
- CMP BYTE PTR [SI], 'M' ; Third character 'M'
- JE _3
- CMP BYTE PTR [SI], 'm'
- JE _3
- JMP _Main_exit ; Exit - illegal argument??
- _3:
- INC SI ; *** Rev 2.0 start ***
- CALL atoi
- DEC CX ; COM1 really is unit 0
- MOV DX, CX ; Return port number
- PUSH DX
- CALL COMMS_GPORT
- POP DX
- CMP AX, 0 ; Test for port presence
- JL _Main_exit
- ; *** Rev 2.0 end ***
- ; Drop on down, SI point to next OK
- _4:
- MOV CX, 0001 ; Assume XON and XOFF
- CMP BYTE PTR [SI], 'X' ; Optional Fifth character 'X'
- JE _5
- CMP BYTE PTR [SI], 'x'
- JE _5
- MOV CX, 0000
- _5:
- PUSH CX ; Save XON/XOFF flag
- PUSH DX ; Save unit #
- MOV AX, 01401h ; XCOMMS_Link request
- MOV CX, 0000 ; Ignore DTR, RTS stuff
- CALL DO_XCOMMS
- POP DX ; Restore unit # and flag
- PUSH DX
- MOV AX, 1403h ; DTR on
- CALL DO_XCOMMS
- POP DX ; Restore unit # and flag
- PUSH DX
- MOV AX, 1405h ; RTS on
- CALL DO_XCOMMS
- POP DX ; Restore unit # and flag
- POP CX
- CMP CX, 0000 ; Enable XON?
- JE xcomms_tagain
- MOV AX, 1409h ; Enable XON flow control
- MOV BX, 10
- MOV CX, 800 ; XON-XOFF range
- CALL DO_XCOMMS
- MOV AX, 0004 ; Something wrong???
- JC _Main_exit
- xcomms_tagain:
- JMP xcomms_loop
- xcomms_bye:
-
- ;
- ; return to the caller COMMAND LINE invoker (THE_END module) with:
- ;
- ; AH = 01 Make XCOMMS resident
- ; AL = 00 Successful status
- ; DX Number of paragraphs to save
- ;
-
- MOV CL, 4
- MOV DX, OFFSET The_End ; Save Vector procedures
- SHR DX, CL
- INC DX ; Add for paragraph boundary
- ADD DX, 256/16 ; Adjust for SPH
-
- MOV BX, XCOMMS_buffers ; Add the buffer size
- MOV CL, BUFFER_SHIFT
- SHL BX, CL
- ADD DX, BX
-
- MOV AL, 00h ; SUCCESS! Install it
- MOV AH, 01h
-
- _Main_exit:
- RET
- Main ENDP
-
-
- DO_XCOMMS PROC NEAR
- DB 0CDh ; Int <XCOMMS>
- xcomms_int DB DEFAULT_XCOMMS ; XCOMMS Interrupt Entry
- RET
- DO_XCOMMS ENDP
-
- CSEG ENDS
- END
-
-