     1                                  ;	TITLE MSAUX - DOS 3.3
     2                                  ;----------------------------------------------------------------
     3                                  ;								:
     4                                  ;	     A U X - AUXILARY DEVICE DRIVER			:
     5                                  ;								:
     6                                  ;								:
     7                                  ;   This file contains the Auxilary Device Driver.  The 	:
     8                                  ; auxilary driver handles calls to and from the RS-232 port.	:
     9                                  ; Three devices uses this code: AUX, COM1, and COM2.  AUX and	:
    10                                  ; COM1 talk to the zero RS-232 card and COM2 talks to the	:
    11                                  ; 'one' RS-232 card.  The beginning of the interrupt entry      :
    12                                  ; point for these devices sets the variable AUXNUM in the	:
    13                                  ; msbio.asm module.  If the value is 0 the routines in this	:
    14                                  ; file will talk to the the 'zero' card.  If the value in       :
    15                                  ; AUXNUM is 1 the routines will talk to the 'one' card.         :
    16                                  ; The procedure GETDX is called to put the value 0 or 1 in	:
    17                                  ; the DX register depending on the value in AUXBUF.		:
    18                                  ;								:
    19                                  ;   The routines in this files are:				:
    20                                  ;								:
    21                                  ;	routine 		function			:
    22                                  ;	------- 		--------			:
    23                                  ;	AUX$READ		Read characters from the	:
    24                                  ;				  specified device.		:
    25                                  ;	AUX$RDND		Non-desrucrtive read with	:
    26                                  ;				  no waiting.			:
    27                                  ;	AUX$FLSH		Flush specified device input	:
    28                                  ;				  buffer.			:
    29                                  ;	AUX$WRIT		Write characters to the 	:
    30                                  ;				  specified device.		:
    31                                  ;	AUX$WRST		Get status of specified 	:
    32                                  ;				  device			:
    33                                  ;								:
    34                                  ;  These routines are not called directly.  Call are made via	:
    35                                  ; the strategy and interrupt entry point (see Device Header).	:
    36                                  ;								:
    37                                  ;  Data structure:						:
    38                                  ;    The Aux Device has a two byte buffer called AUXBUF.  The	:
    39                                  ;  first byte is for the zero card, the second byte is for the	:
    40                                  ;  one card.  A zero value in the byte indicates the buffer is	:
    41                                  ;  empty.  The routines use GETBX to get the address of the	:
    42                                  ;  buffer.							:
    43                                  ;								:
    44                                  ;----------------------------------------------------------------
    45                                  
    46                                  ;;Ver 3.30 modification ---------------------------
    47                                  	itest equ 0
    48                                  	%include "msgroup.mac"	;DEFINE CODE SEGMENT
     1                              <1> EVBOUND equ 1  ;THIS VALUE BEING 0 DOES NO BOUNDARY ALLIGNMENT, VALUE 1	  ;3.30
     2                              <1> 	     ; ALIGNS TO EVEN						  ;3.30
     3                              <1> 
     4                              <1> ; NASM original macros
     5                              <1> 
     6                              <1> %include "dcodeseg.nas"
     1                              <2> 
     2                              <2> %ifndef DCODESEGNAS
     3                              <2> %assign DCODESEGNAS 1
     4                              <2> 
     5                              <2> section DOSCODETABLE align=2 PUBLIC class=DOSCODE
     6                              <2> ; (no prior section) ; DOSCODETABLE		ENDS
     7                              <2> section DOSCODECODE align=1 PUBLIC class=DOSCODE
     8                              <2> ; (no prior section) ; DOSCODECODE		ENDS
     9                              <2> section DOSBIOCODE align=2 PUBLIC class=DOSCODE
    10                              <2> section BIOCODE	align=2 PUBLIC class=DOSCODE
    11                              <2> 
    12                              <2> %ifnidni DOSENTRYGROUP, DOSCODEGROUP
    13                              <2>  group DOSCODEGROUP DOSCODETABLE DOSCODECODE DOSBIOCODE BIOCODE
    14                              <2> %endif
    15                              <2> 
    16                              <2> %endif
     7                              <1> 
     8                              <1> 	%if EVBOUND	;;IF EVEN (WORD) ALLIGNMENT IS REQUESTED,	  ;3.30
     9                              <1> 
    10                              <1> %imacro EVENB 0.nolist
    11                              <1> 	EVEN	;;ADJUST TO EVEN BOUNDARY
    12                              <1> %endmacro
    13                              <1> 
    14                              <1> %imacro ODD 0.nolist
    15                              <1> %if (($ - $$) % 2) == 0
    16                              <1> 	db ?
    17                              <1> %endif
    18                              <1> %endmacro
    19                              <1> 
    20                              <1> 	%else	;;SINCE EVEN ALLIGNMENT IS NOT DESIRED, JUST USE BYTE ALLI;3.30 GNMENT
    21                              <1> 
    22                              <1> %imacro EVENB 0.nolist
    23                              <1> ;;REQUEST FOR WORD ALLIGNMENT DOES NOTHING				  ;3.30
    24                              <1> %endmacro
    25                              <1> 
    26                              <1> %imacro ODD 0.nolist
    27                              <1> ;;REQUEST FOR ODD ALLIGNMENT DOES NOTHING				  ;3.30
    28                              <1> %endmacro
    29                              <1> 
    30                              <1> 	%endif								  ;3.30
    31                              <1> 
    32                              <1> %imacro CODE_SEGMENT 0.nolist
    33                              <1> 	section BIOCODE
    34                              <1> %endmacro
    35                              <1> 
    36                              <1> ; end of NASM original macros
    37                              <1> 
    38                              <1> 	CODE_SEGMENT							  ;3.30
    39                              <1> 	ASSUME	CS:BIOCODE 						  ;3.30
    40                              <1> 									  ;3.30
    49                                  	%include "jumpmac.mac"
     1                              <1> 						  ;;Rev 3.30 Modification
     2                              <1> ;
     3                              <1> ; given a label <lbl> either 2 byte jump to another label <lbl>_J
     4                              <1> ; if it is near enough or 3 byte jump to <lbl>
     5                              <1> ;
     6                              <1> 
     7                              <1> ; NASM original macros
     8                              <1> 
     9                              <1> %if 0
    10                              <1> %imacro jump 1.nolist
    11                              <1> ;.xcref
    12                              <1> 
    13                              <1>     %ifndef %1_J                       ;; is this the first invocation
    14                              <1> %%a:      JMP %1
    15                              <1>     %ELSE
    16                              <1> 	%IF (%1_J >= $) || ($-%1_J > 126)
    17                              <1> %%a:      JMP %1                         ;; is the jump too far away?
    18                              <1> 	%ELSE
    19                              <1> %%a:      JMP %1_J                      ;; do the short one...
    20                              <1> 	%ENDIF
    21                              <1>     %ENDIF
    22                              <1>     %ixdefine %1_j %%a
    23                              <1> ;.cref
    24                              <1> %endmacro
    25                              <1> ;.xcref  jump
    26                              <1> %else
    27                              <1> %imacro jump 1.nolist
    28                              <1> ;REDEFINE THE ABOVE MACRO TO ALWAYS TRY A 3 BYTE NEAR JUMP		 
    29                              <1> 		jmp %1
    30                              <1> %endmacro					;;End of Modification
    31                              <1> %endif
    32                              <1> 
    33                              <1> 
    50                                  	%include "msmacro.mac"
     1                              <1> 
     2                              <1> %include "dcodeseg.nas"
     1                              <2> 
     2                              <2> %ifndef DCODESEGNAS
     3                              <2> %assign DCODESEGNAS 1
     4                              <2> 
     5                              <2> section DOSCODETABLE align=2 PUBLIC class=DOSCODE
     6                              <2> ; (no prior section) ; DOSCODETABLE		ENDS
     7                              <2> section DOSCODECODE align=1 PUBLIC class=DOSCODE
     8                              <2> ; (no prior section) ; DOSCODECODE		ENDS
     9                              <2> section DOSBIOCODE align=2 PUBLIC class=DOSCODE
    10                              <2> section BIOCODE	align=2 PUBLIC class=DOSCODE
    11                              <2> 
    12                              <2> %ifnidni DOSENTRYGROUP, DOSCODEGROUP
    13                              <2>  group DOSCODEGROUP DOSCODETABLE DOSCODECODE DOSBIOCODE BIOCODE
    14                              <2> %endif
    15                              <2> 
    16                              <2> %endif
     3                              <1> section BIOCODE
     4                              <1> 
     5                              <1> ;
     6                              <1> ; This file contains three macros used in debugging the system.  If the
     7                              <1> ; variable "itest" (in msbio.asm) is nonzero code is included in the
     8                              <1> ; modules to print debugging messages.	The level of debugging is controlled
     9                              <1> ; by the value of the variable fTestBits in msbio.asm.	Specific bits in
    10                              <1> ; the variable determine which messages to print.  The equ's below tell
    11                              <1> ; which bits control which funcitons.  For example the fifth bit
    12                              <1> ; cooresponds to disk activity (see fTestDisk equ below).
    13                              <1> ;
    14                              <1> ;   The macros in the file are:
    15                              <1> ;
    16                              <1> ;	message    Prints an ascii string on the screen.
    17                              <1> ;		   Example usage:
    18                              <1> ;
    19                              <1> ;		      message fTestDisk, <"Start Disk Write", CR, LF>
    20                              <1> ;		      message fTestINIT, <"Begin BDS initialization">
    21                              <1> ;
    22                              <1> ;
    23                              <1> ;	MNUM	   Print the value in a register or memory location on
    24                              <1> ;		   the screen. Value is displayed in hex.
    25                              <1> ;		   Usage:
    26                              <1> ;		      MNUM  bitpattern, valueLocation
    27                              <1> ;
    28                              <1> ;		   valueLocation is typically a regester:
    29                              <1> ;
    30                              <1> ;		      mnum  fTestCom, AX
    31                              <1> ;		      mnum  fTestDisk, DX
    32                              <1> ;
    33                              <1> ;		   ValueLocation can also be a memory location:
    34                              <1> ;
    35                              <1> ;		      mnum  fTestINIT, Final_Dos_Location
    36                              <1> ;
    37                              <1> ;		   If no valueLocation is given the macro defaults to
    38                              <1> ;		   the BX register.
    39                              <1> ;
    40                              <1> ;	ZWAIT	    Stops the program until any key is pressed.
    41                              <1> ;
    42                              <1> ;
    43                              <1> ;	The three macros preserve all register values.	If "test" is zero
    44                              <1> ;	defined during assembly then the  marco produce no code.
    45                              <1> ;
    46                              <1> 
    47                              <1> 	%IF	itest							  ;3.30
    48                              <1> 		EXTRN	MSGOUT:NEAR,MSGNUM:NEAR 			  ;3.30
    49                              <1> 	    EXTRN   NUMBUF:BYTE,DIGITS:BYTE,FTESTBITS:WORD		  ;3.30
    50                              <1> 		EXTRN	DUMPBYTES:NEAR,OUTCHAR:NEAR,HEX_TO_ASCII:NEAR	  ;3.30
    51                              <1> 
    52                              <1> 
    53                              <1> fTestALL    equ     1111111111111111b	; watch everything
    54                              <1> fTestHARD   equ     0000000000000001b	; watch hard disk initialization
    55                              <1> fTest96     equ     0000000000000010b	; watch 96 tpi activity
    56                              <1> FTEST13     EQU     0000000000000100B	; WATCH INT 13 ACTIVITY 	  ;3.30
    57                              <1> FTESTCOM    EQU     0000000000001000B	; WATCH PACKET ACTIVITY 	  ;3.30
    58                              <1> FTESTINIT   EQU     0000000000010000B	; WATCH INITIALIZATION MESSAGES   ;3.30
    59                              <1> FTESTDISK   EQU     0000000000100000B	; WATCH DISK DEVICE DRIVER CALLS  ;3.30
    60                              <1> FTESTCON    EQU     0000000001000000B	; WATCH SYSTEM WAIT ACTIVITY IN CO;3.30 NSOLE
    61                              <1> FtestClock  equ     0000000010000000b	; wathc clock device  5/2/86  ;3.30
    62                              <1> 
    63                              <1> ; NASM original macros
    64                              <1> 
    65                              <1> ;
    66                              <1> ; message macro -- see above for description
    67                              <1> ;
    68                              <1> 
    69                              <1> %unimacro stripangles 2+.nolist
    70                              <1> 
    71                              <1> %imacro stripangles 2+.nolist
    72                              <1> %defstr %%param %2
    73                              <1> %rep 16
    74                              <1>  %substr %%opening %%param 1
    75                              <1>  %ifidn %%opening, '<'
    76                              <1>   %substr %%param %%param 2,-1
    77                              <1>  %endif
    78                              <1> %endrep
    79                              <1> %rep 16
    80                              <1>  %strlen %%length %%param
    81                              <1>  %substr %%closing %%param %%length
    82                              <1>  %ifidn %%closing, '>'
    83                              <1>   %substr %%param %%param 1,-2
    84                              <1>  %endif
    85                              <1> %endrep
    86                              <1> %deftok %%token %%param
    87                              <1> %1 %%token
    88                              <1> %endmacro
    89                              <1> 
    90                              <1> %imacro MESSAGE 2+
    91                              <1> 	jmp short %%b
    92                              <1> %%a:
    93                              <1> 	stripangles db, %2
    94                              <1> 	db 0
    95                              <1> %%b:	push	SI
    96                              <1> 	push	AX
    97                              <1> 	mov	AX, %1
    98                              <1> 	mov	SI, OFFSET %%a
    99                              <1> 	call	MSGOUT
   100                              <1> 	pop	AX
   101                              <1> 	pop	SI
   102                              <1> %endmacro
   103                              <1> 
   104                              <1> 
   105                              <1> ;
   106                              <1> ; mnum macro -- see above for description
   107                              <1> ;
   108                              <1> 
   109                              <1> %imacro MNum 1-2
   110                              <1> 	push	AX
   111                              <1> %ifempty %2
   112                              <1> 	mov	AX,%1
   113                              <1> 	call	MSGNUM
   114                              <1> %else
   115                              <1> 	push	BX
   116                              <1> 	mov	BX,%2
   117                              <1> 	mov	AX,%1
   118                              <1> 	call	MSGNUM
   119                              <1> 	pop	BX
   120                              <1> %endif
   121                              <1> 	pop	AX
   122                              <1> %endmacro
   123                              <1> 
   124                              <1> 
   125                              <1> ;
   126                              <1> ; zwait macro -- see above for description
   127                              <1> ;
   128                              <1> 
   129                              <1> %imacro ZWAIT 0
   130                              <1> 	Message fTestALL,<"? ">
   131                              <1> 	CALL	ZWAITrtn
   132                              <1> %endmacro
   133                              <1> 
   134                              <1> ZWAITrtn:
   135                              <1> 	pushf				; save the flags
   136                              <1> 	push	AX			; preserve AX
   137                              <1> 	xor	AH, AH			; set command to get character ;3.30*
   138                              <1> 	int	16h			; call rom keyboard routine    ;3.30*
   139                              <1> 	pop	AX			; restore AX
   140                              <1> 	popf				; restore the flags
   141                              <1> 	ret
   142                              <1> 
   143                              <1> ;Dump_byte dumps the memory contents in hex. 				  ;3.30
   144                              <1> ;DUMPOFFLABEL should be a label or a variable defined in DUMPSEG.	  ;3.30
   145                              <1> %imacro DUMP_BYTE 3
   146                              <1> 	push	es							  ;3.30
   147                              <1> 	PUSH	DS							  ;3.30
   148                              <1> 	PUSH	SI							  ;3.30
   149                              <1> 	PUSH	CX							  ;3.30
   150                              <1> 									  ;3.30
   151                              <1> 	MOV	CX, %1							  ;3.30
   152                              <1> 	MOV	DS, CX							  ;3.30
   153                              <1> 	MOV	SI, OFFSET %2						  ;3.30
   154                              <1> 	MOV	CX, %3							  ;3.30
   155                              <1> 	call	dumpbytes						  ;3.30
   156                              <1> 									  ;3.30
   157                              <1> 	POP	CX							  ;3.30
   158                              <1> 	POP	SI							  ;3.30
   159                              <1> 	POP	DS							  ;3.30
   160                              <1> 	pop	es							  ;3.30
   161                              <1> %endmacro								  ;3.30
   162                              <1> 									  ;3.30
   163                              <1> ;Dump_Byte_Reg dumps the memory contents in hex. -  4/9/86		  ;3.30
   164                              <1> ;DUMPOFFREG should be a register contains the offset value in DUMPSEG.	  ;3.30
   165                              <1> %imacro DUMP_BYTE_REG 3
   166                              <1> DUMP_BYTE_REG	MACRO	DUMPSEG, DUMPOFFREG, BYTELENGTH 		  ;3.30
   167                              <1> 	push	es							  ;3.30
   168                              <1> 	PUSH	DS							  ;3.30
   169                              <1> 	PUSH	SI							  ;3.30
   170                              <1> 	PUSH	CX							  ;3.30
   171                              <1> 									  ;3.30
   172                              <1> 	MOV	CX, %1							  ;3.30
   173                              <1> 	MOV	DS, CX							  ;3.30
   174                              <1> 	MOV	SI, %2							  ;3.30
   175                              <1> 	MOV	CX, %3							  ;3.30
   176                              <1> 	call	dumpbytes						  ;3.30
   177                              <1> 									  ;3.30
   178                              <1> 	POP	CX							  ;3.30
   179                              <1> 	POP	SI							  ;3.30
   180                              <1> 	POP	DS							  ;3.30
   181                              <1> 	pop	es							  ;3.30
   182                              <1> %endmacro								  ;3.30
   183                              <1> 
   184                              <1> %else
   185                              <1> 		; if test is not defined then make macro into null statements
   186                              <1> %imacro Message 0-1+.nolist
   187                              <1> %endmacro
   188                              <1> 
   189                              <1> %imacro MNUM 0-1+.nolist
   190                              <1> %endmacro
   191                              <1> 
   192                              <1> %imacro ZWAIT 0-1+.nolist
   193                              <1> %endmacro
   194                              <1> 
   195                              <1> %imacro DUMP_BYTE 0-1+.nolist
   196                              <1> %endmacro
   197                              <1> 
   198                              <1> %imacro DUMP_BYTE_REG 0-1+.nolist
   199                              <1> %endmacro
   200                              <1> 
   201                              <1> %endif
   202                              <1> 
   203                              <1> %unimacro PATHSTART 2
   204                              <1> %unimacro PATHEND 2
   205                              <1> 
   206                              <1> %imacro PATHSTART 2
   207                              <1> 	%IF	PATHGEN							  ;3.30
   208                              <1> 	    PUBLIC  %2%1S,%2%1E						  ;3.30
   209                              <1> 	    %2%1S LABEL	 BYTE						  ;3.30
   210                              <1> 	%ENDIF								  ;3.30
   211                              <1> %endmacro								  ;3.30
   212                              <1> 									  ;3.30
   213                              <1> %imacro PATHEND 2
   214                              <1> 	%IF	PATHGEN							  ;3.30
   215                              <1> 	    %2%1E LABEL	 BYTE						  ;3.30
   216                              <1> 	%ENDIF								  ;3.30
   217                              <1> %endmacro								  ;3.30
    51                                  
    52                                  	EXTRN ERR$CNT:NEAR	;MSBIO1
    53                                  	EXTRN GETDX:NEAR	;MSBIO1
    54                                  	EXTRN RDEXIT:NEAR	;MSCON
    55                                  	EXTRN EXIT:NEAR 	;MSBIO1
    56                                  	EXTRN BUS$EXIT:NEAR	;MSBIO1
    57                                  				;DATA
    58                                  	EXTRN AUXBUF:BYTE	;MSDATA
    59                                  
    60                                  ;		VALUES IN AH, REQUESTING FUNCTION OF INT 14H IN ROM BIOS
    61                                  AUXFUNC_SEND	 EQU	1	;TRANSMIT
    62                                  AUXFUNC_RECEIVE  EQU	2	;READ
    63                                  AUXFUNC_STATUS	 EQU	3	;REQUEST STATUS
    64                                  
    65                                  ;		ERROR FLAGS, REPORTED BY INT 14H
    66                                  
    67                                  ;	 THESE FLAGS REPORTED IN AH:
    68                                  FLAG_DATA_READY  EQU	01H	;DATA READY
    69                                  FLAG_OVERRUN	 EQU	02H	;OVERRUN ERROR
    70                                  FLAG_PARITY	 EQU	04H	;PARITY ERROR
    71                                  FLAG_FRAME	 EQU	08H	;FRAMING ERROR
    72                                  FLAG_BREAK	 EQU	10H	;BREAK DETECT
    73                                  FLAG_TRANHOL_EMP EQU	20H	;TRANSMIT HOLDING REGISTER EMPTY
    74                                  FLAG_TRANSHF_EMP EQU	40H	;TRANSMIT SHIFT REGISTER EMPTY
    75                                  FLAG_TIMEOUT	 EQU	80H	;TIMEOUT
    76                                  
    77                                  ;	THESE FLAGS REPORTED IN AL:
    78                                  FLAG_DELTA_CTS	 EQU	01H	;DELTA CLEAR TO SEND
    79                                  FLAG_DELTA_DSR	 EQU	02H	;DELTA DATA SET READY
    80                                  FLAG_TRAIL_RING  EQU	04H	;TRAILING EDGE RING INDICATOR
    81                                  FLAG_DELTA_SIG	 EQU	08H	;DELTA RECEIVE LINE SIGNAL DETECT
    82                                  FLAG_CTS	 EQU	10H	;CLEAR TO SEND
    83                                  FLAG_DSR	 EQU	20H	;DATA SET READY
    84                                  FLAG_RING	 EQU	40H	;RING INDICATOR
    85                                  FLAG_REC_SIG	 EQU	80H	;RECEIVE LINE SIGNAL DETECT
    86                                  ;;End of modification ------------------
    87                                  
    88                                  
    89                                  ;----------------------------------------------------------------
    90                                  ;								  :
    91                                  ;	Read zero or more characters from Auxilary Device	  :
    92                                  ;								  :
    93                                  ;	input:[es:di] points to area to receive aux data	  :
    94                                  ;	      cx has number of bytes to be read 		  :
    95                                  ;	      "auxnum" first byte has number of aux device (rel 0):
    96                                  ;								  :
    97                                  ;----------------------------------------------------------------
    98                                  	PUBLIC AUX$READ
    99                                  AUX$READ PROC NEAR
   100                                   assume ds:DOSGROUP, es:nothing, ss:nothing
   101                                  				; SET BY AUX DEVICE DRIVER ENTRY ROUTINE
   102 00000000 E311                    	jcxz	EXVEC2		; if no characters, get out
   103 00000002 E88700                  	call	GETBX		; put address of AUXBUF in BX
   104 00000005 31C0                    	xor	AX,AX		; clear AX register
   105 00000007 8607                    	xchg	AL,[BX] 	; Get character , if any, from
   106                                  				;   buffer and clear buffer
   107 00000009 08C0                    	or	AL,AL		; if AL is nonzero there was a
   108                                  				;   character in the buffer
   109 0000000B 7503                    	jnz	AUX2		; if so skip AUXIN call
   110                                  AUX1:				;
   111 0000000D E80600                  	call	AUXIN		; get character from port
   112                                  AUX2:				;
   113 00000010 AA                      	stosb			; store character
   114 00000011 E2FA                    	loop	AUX1		; if more character, go around again
   115                                  EXVEC2: 			;
   116 00000013 E9(0000)                	Jump	EXIT		; all done, successful exit
   117                                  AUX$READ ENDP
   118                                  
   119                                  ;
   120                                  ; AUXIN: make a call on ROM BIOS to read character from
   121                                  ;	 the auxilary device, then do some error checking.
   122                                  ;	 If an error occurs then AUXIN jumps to ERR$CNT and
   123                                  ;	 does NOT return to where it was called from.
   124                                  ;
   125                                  
   126                                  AUXIN	PROC	NEAR
   127                                  
   128 00000016 B402                    	mov	ah,AUXFUNC_RECEIVE
   129 00000018 E84800                  	call	AUXOP
   130                                  	 			;check for Frame, Parity, or Overrun errors
   131                                  	 			;WARNING: these error bits are unpredictable 
   132                                  	 			;         if timeout (bit 7) is set
   133 0000001B F6C40E                  	test	ah,FLAG_FRAME | FLAG_PARITY | FLAG_OVERRUN
   134 0000001E 740A                    	jz	AROK		;No error if all bits are clear
   135                                  
   136                                  	 ;Error getting character
   137 00000020 83C402                  	add	sp,+2		;Remove rtn address (near call)
   138 00000023 30C0                    	xor	al,al
   139 00000025 0CB0                    	or	al,FLAG_REC_SIG | FLAG_DSR | FLAG_CTS
   140                                  
   141 00000027 E9(0000)                	JUMP	ERR$CNT
   142                                  AROK:
   143 0000002A C3                      	RET			;CHAR JUST READ IS IN AL, STATUS IS IN AH
   144                                  AUXIN	ENDP
   145                                  
   146                                  ;----------------------------------------------------------------
   147                                  ;								:
   148                                  ;	Aux non-destructive read with no waiting		:
   149                                  ;								:
   150                                  ;	input: [es:di] points to area to receive aux data	:
   151                                  ;								:
   152                                  ;----------------------------------------------------------------
   153                                  ;
   154                                  	PUBLIC	AUX$RDND
   155                                  AUX$RDND PROC	NEAR
   156                                   assume ds:DOSGROUP, es:nothing, ss:nothing
   157                                  				; SET BY AUX DEVICE DRIVER ENTRY ROUTINE
   158 0000002B E85E00                  	call	GETBX		; have BX point to AUXBUF
   159 0000002E 8A07                    	mov	AL,[BX] 	; copy contents of buffer to AL
   160 00000030 08C0                    	or	AL,AL		; if AL is non-zero (char in buffer)
   161 00000032 7514                    	jnz	AUXRDX		;   then return character
   162 00000034 E82600                  	call	AUXSTAT 	;   if not, get status of AUX device
   163 00000037 F6C401                  	TEST	AH,FLAG_DATA_READY ;TEST DATA READY
   164 0000003A 740F                    	jz	AUXBUS		;   then device is busy (not ready)
   165                                  
   166 0000003C A820                    	TEST	AL,FLAG_DSR	;TEST DATA SET READY
   167 0000003E 740B                    	jz	AUXBUS		;   then device is busy (not ready)
   168 00000040 E8D3FF                  	call	AUXIN		;   else aux is ready, get character
   169 00000043 E84600                  	call	GETBX		; have bx point to AUXBUF
   170 00000046 8807                    	mov	[BX],AL 	; save character in buffer
   171                                  AUXRDX: 			;
   172 00000048 E9(0000)                	Jump	RDEXIT		; return character
   173                                  
   174                                  AUXBUS: 			;
   175 0000004B E9(0000)                	Jump	BUS$EXIT	; jump to device busy exit
   176                                  AUX$RDND ENDP
   177                                  
   178                                  ;----------------------------------------------------------------
   179                                  ;								:
   180                                  ;		Aux Output Status				:
   181                                  ;								:
   182                                  ;----------------------------------------------------------------
   183                                  	PUBLIC AUX$WRST
   184                                  AUX$WRST PROC	NEAR
   185                                   assume ds:DOSGROUP, es:nothing, ss:nothing
   186                                  				; SET BY AUX DEVICE DRIVER ENTRY ROUTINE
   187 0000004E E80C00                  	call	AUXSTAT 	; get status of AUX in AX
   188                                  				; now test to see if device is busy
   189                                  				; if this bit is not set,
   190                                  ;;Ver 3.30 modification -----------------------
   191 00000051 A820                    	TEST	AL,FLAG_DSR	;TEST DATA SET READY
   192 00000053 74F6                    	jz	AUXBUS		;   then device is busy (not ready)
   193 00000055 F6C420                  	TEST	AH,FLAG_TRANHOL_EMP ;TEST TRANSMIT HOLD REG EMPTY
   194                                  ;;End of modification -------------------------
   195 00000058 74F1                    	jz	AUXBUS		;   then device is busy (not ready)
   196                                  Exit equ EXIT	; NASM port label
   197 0000005A E9(0000)                	Jump	Exit
   198                                  
   199                                  AUX$WRST ENDP
   200                                  
   201                                  ;
   202                                  ; AUXSTAT makes a call on the ROM-BIOS to determine the status
   203                                  ;	  of the auxilary device
   204                                  ;	  Outputs:
   205                                  ;		AX is filled with status of port.
   206                                  ;		DX is changes to specify which card - either 0, 1 (, 2, 3) ;ba
   207                                  ;		NO other registers are modified
   208                                  ;
   209                                  
   210                                  AUXSTAT	proc near
   211 0000005D B403                    	mov	ah,AUXFUNC_STATUS
   212 0000005F E80100                  	call	AUXOP
   213 00000062 C3                      	ret
   214                                  AUXSTAT endp
   215                                  
   216                                  AUXOP	PROC	NEAR
   217                                  				;AH=FUNCTION CODE
   218                                  				;0=INIT, 1=SEND, 2=RECEIVE, 3=STATUS
   219 00000063 E8(0000)                	call	GETDX		; have DX point to proper card
   220 00000066 CD14                    	int	14h		; call rom-bios for status
   221 00000068 C3                      	ret
   222                                  AUXOP	ENDP
   223                                  
   224                                  ;----------------------------------------------------------------
   225                                  ;								:
   226                                  ;  Flush AUX Input buffer - set contents of AUXBUF to zero	:
   227                                  ;								:
   228                                  ;----------------------------------------------------------------
   229                                  	PUBLIC AUX$FLSH
   230                                  AUX$FLSH PROC	NEAR
   231                                   assume ds:DOSGROUP, es:nothing, ss:nothing
   232                                  				; SET BY AUX DEVICE DRIVER ENTRY ROUTINE
   233 00000069 E82000                  	call	GETBX		; get BX to point to AUXBUF
   234 0000006C C60700                  	mov	BYTE PTR [BX],0 ; zero out buffer
   235 0000006F E9(0000)                	Jump	Exit		; all done, successful return
   236                                  AUX$FLSH ENDP
   237                                  
   238                                  
   239                                  
   240                                  ;----------------------------------------------------------------
   241                                  ;								:
   242                                  ;		Write to Auxilary Device			:
   243                                  ;								:
   244                                  ;----------------------------------------------------------------
   245                                  	PUBLIC	AUX$WRIT
   246                                  AUX$WRIT PROC	NEAR
   247                                   assume ds:DOSGROUP, es:nothing, ss:nothing
   248                                  				; SET BY AUX DEVICE DRIVER ENTRY ROUTINE
   249 00000072 E39F                    	jcxz	EXVEC2		; if CX is zero, no characters
   250                                  				;   to be written, jump to exit
   251                                  AUX$LOOP:
   252 00000074 268A05                  	mov	AL,[ES:DI]	; get character to be written
   253 00000077 47                      	inc	DI		; move DI pointer to next character
   254                                  ;;Ver 3.30 modification ---------------------------
   255 00000078 B401                    	MOV	AH,AUXFUNC_SEND ;VALUE=1, INDICATES A WRITE
   256 0000007A E8E6FF                  	CALL	AUXOP		;SEND CHARACTER OVER AUX PORT
   257                                  
   258 0000007D F6C480                  	TEST	AH,FLAG_TIMEOUT ;CHECK FOR ERROR
   259                                  ;;End of modification ---------------------------
   260 00000080 7405                    	jz	AWOK		;   then no error
   261 00000082 B00A                    	mov	AL,10		;   else indicate write fault
   262 00000084 E9(0000)                	Jump	ERR$CNT 	; call error routines
   263                                  
   264                                  				; if CX is non-zero, still more
   265                                  AWOK:
   266 00000087 E2EB                    	loop	AUX$LOOP	; more characrter to print
   267 00000089 E9(0000)                	Jump	Exit		; all done, successful return
   268                                  AUX$WRIT ENDP
   269                                  
   270                                  
   271                                  ;
   272                                  ;  GETBX puts the address of AUXBUF (the Auxilary Device buffer)
   273                                  ;	 in BX.  After calling GETBX, a routine can get to AUXBUF
   274                                  ;	 with [BX].
   275                                  ;
   276                                  ;  NOTE: The getdx routine is in msbio1 and looks like:
   277                                  ;	mov	dx,word ptr [cs:auxnum]
   278                                  ;
   279                                  GETBX	PROC	NEAR
   280                                   assume ds:DOSGROUP, es:nothing, ss:nothing
   281 0000008C E8(0000)                	call	GETDX
   282 0000008F 89D3                    	mov	BX,DX
   283 00000091 81C3[0000]              	add	BX,OFFSET AUXBUF	; access with ds
   284 00000095 C3                      	ret
   285                                  GETBX	ENDP
   286                                  
   287                                  ; (no prior section) ; CODE	ENDS
   288                                  	END
