home *** CD-ROM | disk | FTP | other *** search
/ Power Programming / powerprogramming1994.iso / progtool / modem / async1.arc / ASYNC.ASM next >
Assembly Source File  |  1985-09-13  |  26KB  |  546 lines

  1.  
  2.         Page    60,132
  3.         .Radix  16
  4.         Title   Communications Interface Routine
  5.         Subttl  Macros
  6.         Page
  7. Save    Macro   R1,R2,R3,R4,R5,R6,R7,R8,R9,R10
  8.         Irp     Rx,<R1,R2,R3,R4,R5,R6,R7,R8,R9,R10> ;Repeat for each parm
  9.         Ifnb    <Rx>                            ;If this parm not blank
  10.         Push    Rx                              ;Save the register
  11.         Endif                                   ;End Ifnb
  12.         Endm                                    ;End Irp
  13.  
  14.  
  15. ;;      The Restore macro makes use of the fact that R1-R10 are still defined,
  16. ;;      but, being a different macro, this will not expand when the Save macro
  17. ;;      is used.  Note that the Restore macro will restore whatever registers
  18. ;;      were last Save'd in the assembly listing, not during execution.
  19. ;;      Therefore, its use is restricted to restoring the previous sequential
  20. ;;      Save macro's registers.
  21.  
  22. Restore Macro
  23.         Irp     Rx,<R10,R9,R8,R7,R6,R5,R4,R3,R2,R1> ;Repeat for each parm
  24.         Ifnb    <Rx>                      ;If this parm not blank
  25.         Pop     Rx                        ;Pop the register
  26.         Endif                             ;End Ifnb
  27.         Endm                              ;End Irp
  28.         Endm                              ;End of Restore macro
  29.         Endm                              ;End of Save Macro
  30.  
  31. Setint  Macro   Vector,Routine            ;Sets an interrupt vector
  32.         Lea     DX,Routine                ;Address the routine
  33.         Mov     AX,25*100+Vector          ;Set the vector
  34.         Int     21                        ;Call DOS to do it
  35.         Endm
  36.  
  37. Incbuf  Macro   Buffer
  38.         Local   Notend                    ;Not at end of buffer label
  39.  
  40. ;;      Macro to increment the buffer pointer.  This macro is used
  41. ;;      internally by other buffer processing macros.  The pointer to
  42. ;;      be incremented must be in BX.  Results in BX.
  43.  
  44.         Inc     BX                        ;Point at next character
  45.         Cmp     BX,Offset Buffer.Buff + Length Buff ;At end of buffer?
  46.         Jb      Notend                    ;No - continue
  47.         Lea     BX,Buffer.Buff            ;Point back to start of buffer
  48.  
  49. Notend  Label   Near                      ;Not at end of buffer
  50.         Endm                              ;End of macro
  51.  
  52. Bufinit Macro   Buffer                    ;Initialize the buffers
  53.  
  54. ;;      This macro must be called once for each buffer.  It's purpose
  55. ;;      is to ensure the pointers are set up correctly before the
  56. ;;      buffers are used.  Unless the buffers are initialized, the
  57. ;;      results will be unpredictable.
  58.  
  59.         Lea     BX,Buffer.Buff            ;Get address of buffer
  60.         Mov     Buffer.Staptr,BX          ;Set start of data address
  61.         Mov     Buffer.Endptr,BX          ;End of data too (buffer empty)
  62.         Endm                              ;End of macro
  63.  
  64. Putbuf  Macro   Buffer                    ;Insert a character in the buffer
  65.         Local   Bufull
  66.  
  67. ;;      This macro puts a byte into BUFFER.  Origin is AL, and it uses the
  68. ;;      BX reg.  The carry flag is set if the buffer is full and the routine
  69. ;;      cannot place a bit in the buffer, and is cleared if the character is
  70. ;;      inserted in the buffer and pointers updated.
  71. ;;      The buffer must have been defined with the BUFFER structure.
  72.  
  73.         Mov     BX,Buffer.Endptr          ;Get pointer to end of buffer
  74.         Incbuf  Buffer                    ;Point at next character
  75.         Cmp     BX,Buffer.Staptr          ;Buffer full?
  76.         Je      Bufull                    ;Yes - buffer overrun
  77.         Mov     [BX],AL                   ;Store a byte
  78.         Mov     Buffer.Endptr,BX          ;Replace new pointer
  79.         Stc                               ;Inverse of carry flag returned
  80.  
  81. Bufull  Label   Near                      ;Get a character from the buffer
  82.         Cmc                               ;Invert carry bit for return code
  83.         Endm                              ;End of macro
  84.  
  85. Getbuf  Macro   Buffer                    ;Get a character from the buffer
  86.         Local   Bufemp
  87.  
  88. ;;      This macro gets a character from BUFFER and returns it in AL.  It
  89. ;;      uses the BX reg.  Carry flag is set if the buffer is empty, and
  90. ;;      cleared if a character is returned in AL.
  91. ;;      The buffer must have been defined with the BUFFER structure.
  92.  
  93.         Mov     BX,Buffer.Staptr          ;Get buffer data start
  94.         Cmp     BX,Buffer.Endptr          ;Any data in buffer?
  95.         Je      Bufemp                    ;Yes - go transmit it
  96.         Incbuf  Buffer                    ;Point at next character
  97.         Mov     AL,[BX]                   ;Get a byte
  98.         Mov     Buffer.Staptr,BX          ;Restore pointer
  99.         Stc                               ;Set complement of carry flag
  100.  
  101. Bufemp  Label   Near
  102.         Cmc                               ;Set true return flag
  103.         Endm
  104.  
  105. Flush   Macro   Buffer                    ;Flush the buffer
  106.  
  107. ;;      This macro will flush BUFFER by setting the start and end
  108. ;;      pointers equal.  It uses the BX reg.
  109.  
  110.         Mov     BX,Buffer.Staptr          ;Get start of data
  111.         Mov     Buffer.Endptr,BX          ;Set end = start (empty)
  112.         Endm
  113.  
  114. ;       Structure used for buffer definition.
  115. ;       Staptr = Endptr means buffer is full.  Otherwise buffer has data
  116. ;       in it.
  117.  
  118.  
  119. Buffer  Struc
  120. Buff    Db      256d Dup (0)              ;Buffer size in decimal
  121. Staptr  Dw      0                         ;Start of data pointer
  122. Endptr  Dw      0                         ;End of data pointer
  123. Buffer  Ends
  124.  
  125. Inital  Record  Speed:3, Parity:2, Stop:1, Len:2 ;Init call parms in AL
  126.  
  127.         Subttl  Equates
  128.         Page
  129.  
  130. ;               Line status bits -- AH
  131. Timeout Equ     80                        ;Time out error
  132. Tbufemp Equ     40                        ;Transmit buffer empty
  133. Tbufnfl Equ     20                        ;Transmit buffer not full
  134. Brkdet  Equ     10                        ;Break detect
  135. Framerr Equ     08                        ;Framing error
  136. Parerr  Equ     04                        ;Parity error
  137. Rcveovr Equ     02                        ;Receive buffer overrun
  138. Rdatrdy Equ     01                        ;Receive buffer has data
  139.  
  140. ;               Modem status bits -- AL
  141. Rlsd    Equ     80                        ;Received line signal detect
  142. Ri      Equ     40                        ;Ring indicator
  143. Dsr     Equ     20                        ;Data set ready
  144. Cts     Equ     10                        ;Clear to send
  145. Drlds   Equ     08                        ;Delta receive line signal detect
  146. Teri    Equ     04                        ;Trailing edge ring indicator
  147. Ddsr    Equ     02                        ;Delta data set ready
  148. Dcts    Equ     01                        ;Delta clear to send
  149.  
  150. ;               Interrupt Enable reg bit definitions
  151. Msint   Equ     08                        ;Modem status int bit
  152. Rlsint  Equ     04                        ;Receive line status int bit
  153. Thrint  Equ     02                        ;Transmit holding reg empty int bit
  154. Daint   Equ     01                        ;Data availalbe interrupt
  155.  
  156. ;               Modem Control Port
  157.  
  158. Out2    Equ     08                        ;Out2 bit
  159. Out1    Equ     04                        ;Out1 bit
  160. Rts     Equ     02                        ;Request to Send
  161. Dtr     Equ     01                        ;Data Terminal Ready
  162.  
  163. ;       Other equates and records
  164. Asysmsk Equ     10                        ;System interrupt (port 21) mask
  165. Perror  Equ     -1                        ;Paramater error
  166. Baseadr Equ     3F8                       ;Comm port 1 base address
  167.  
  168.         Subttl  Constants
  169.         Page    +
  170. Comm    Segment Para Public 'Code'
  171.         Assume CS:Comm ,DS:Comm ,ES:nothing ,SS:Nothing
  172.  
  173.         Org     100h                      ;Set starting point
  174. Entry   Label   Near                      ;Initialization entry point
  175.         Jmp     Start                     ;Go to initialization code
  176.  
  177.         Db      'Asynchronous Communications Port Driver '
  178.         Db      '(C) Copyright 1985 by Jerry D. Stuckle.'
  179.         Db      'Released to Public Domain for non-business use only.'
  180.  
  181.  
  182. Divisor Label   Word                      ;Table of divisor values
  183.         Dw      1047d                     ; 110 baud
  184.         Dw       768d                     ; 150 baud
  185.         Dw       384d                     ; 300 baud
  186.         Dw       192d                     ; 600 baud
  187.         Dw        96d                     ;1200 baud
  188.         Dw        48d                     ;2400 baud
  189.         Dw        24d                     ;4800 baud
  190.         Dw        12d                     ;9600 baud
  191.  
  192. Functbl Label   Word                      ;Function request table of routines
  193.         Dw      Copen                     ;AH = 0 Open communications port
  194.         Dw      Csend                     ;AH = 1 Send a character
  195.         Dw      Crcve                     ;AH = 2 Receive a character
  196.         Dw      Cstat                     ;AH = 3 Get buffer status
  197.         Dw      Cclos                     ;AH = 4 Close communications port
  198.  
  199. Funcnt  Equ     ($ - Functbl) / 2         ;Number of words in table
  200.  
  201.  
  202.         Subttl  Data Areas
  203.         Page
  204. ;       Transmit and receive buffer structures
  205.  
  206. Xmit    Buffer  <,,>                      ;No override for initial values
  207. Rcve    Buffer  <,,>                      ;No override for initial values
  208.  
  209. Lstatus Db      0                         ;Line status byte
  210. Mstatus Db      0                         ;Modem status byte
  211.  
  212.  
  213.         Subttl  Interface Routines
  214.         Page
  215. Int14   Proc    Near                      ;Interrupt 14 input
  216.         Sti                               ;Other interrupts are OK here.
  217.         Save    DS,DX,SI,DI,BX            ;Save all required regs
  218.         Push    CS                        ;Place CS on stack so...
  219.         Pop     DS                        ;...we can set DS
  220.         Or      DX,DX                     ;Is DX 0?
  221.         Jnz     Parmerr                   ;No - error found - return
  222.         Cmp     AH,Funcnt                 ;Check against number of entries in..
  223.         Ja      Parmerr                   ;..the table and branch if too high.
  224.         Mov     DX,Baseadr                ;Get port base address
  225.         Xor     BH,BH                     ;One byte index being used
  226.         Mov     BL,AH                     ;Get function code
  227.         Shl     BX,1                      ;Multiply by 2
  228.         Call    Functbl[BX]               ;Call the correct routine
  229.         Jmp     Short Intret              ;Go return to caller
  230.  
  231. Parmerr Label   Near                      ;Paramater error detected
  232.         Mov     AH,Perror                 ;Move in error code
  233.  
  234. Intret  Label   Near                      ;Return to caller
  235.         Restore                           ;Put back all registers
  236.         Iret                              ;Interrupt return
  237. Int14   Endp                              ;End of mainline code
  238.  
  239.         Subttl  Open the Comm port
  240.         Page
  241. Copen   Proc    Near
  242.         Mov     AH,AL                     ;Save parms in AH
  243.         Add     DX,3                      ;Point at line control reg
  244.         In      AL,DX                     ;Get the reg in AL
  245.         Or      AL,80                     ;Turn on Divisor Latch Bit
  246.         Out     DX,AL                     ;Enable the latch
  247.         Sub     DX,3                      ;Point back to base port
  248.         Xor     BH,BH                     ;Insure BH is low values
  249.         Mov     BL,AH                     ;Get all init parms in BL
  250.         And     BL,Mask Speed             ;Turn off excess bits
  251.         Mov     CL,Speed                  ;Get the shift value
  252.         Shr     BL,CL                     ;And move it over.
  253.         Shl     BL,1                      ;X2 for index into word table
  254.         Lea     SI,Divisor[BX]            ;Set pointer to correct divisor
  255.         Lodsb                             ;Get the low order of the divisor
  256.         Out     DX,AL                     ;Set into the divisor latch
  257.         Lodsb                             ;Get the high order of the divisor
  258.         Inc     DX                        ;Point to the high order port
  259.         Out     DX,AL                     ;And set latch high order
  260.         Inc     DX                        ;Now back to the...
  261.         Inc     DX                        ;...DLAB bit
  262.         Mov     AL,AH                     ;Get the original parms in AL
  263.         And     AL,Mask Parity + Mask Stop + Mask Len ;Leave on only desired bits.
  264.  
  265. ;       Now magically, the rest of the bits in AL match exactly
  266. ;       the Line Control Register bits (maybe it was planned?).
  267.  
  268.         Out     DX,AL                     ;And set the other parms in the LCR
  269.  
  270. ;       Now we have all the requested parms set, all that remains is to
  271. ;       set DTR and RTS, and enable the interrupts on the async board
  272. ;       and from the system (port 21).  Note that this uses negative logic
  273. ;       (a bit being '0' means this interrupt is active).
  274.  
  275.         Push    DX                        ;Save base address on stack
  276.         Mov     DX,21                     ;Address interrupt control reg
  277.         In      AL,DX                     ;Get current interrupts
  278.         And     AL,0FF-Asysmsk            ;Allow Async interrupts from port 1
  279.         Out     DX,AL                     ;Put it back out
  280.         Pop     DX                        ;Restore base addr from stack
  281.         Inc     DX                        ;Point to Modem Control Reg
  282.         Mov     AL,Out2+Rts+Dtr           ;RTS and DTR
  283.         Out     DX,AL                     ;Set the Modem Control Reg
  284.         Sub     DX,3                      ;Back up to Interupt Enable Reg
  285.         In      AL,DX                     ;Port might already be set.
  286.         Or      AL,Msint+Rlsint+Daint     ;Modem status+Line status+Data avail
  287.         Out     DX,AL                     ;Set the reg
  288.         Nop                               ;Allow dummy machine cycle
  289.  
  290. ;       Disable all interrupts before flushing buffers and getting status.
  291.  
  292.         Cli                               ;Disable again
  293.         Flush   Xmit                      ;Flush the transmit buffer
  294.         Flush   Rcve                      ;Flush the receive buffer
  295.         Add     DX,4                      ;Point to Line Status Reg
  296.         In      AL,DX                     ;Get the status
  297.         In      AL,DX                     ;Do it again to clear any errors
  298.         Mov     Lstatus,AL                ;Set the status byte
  299.         Inc     DX                        ;Point to Modem Status Reg
  300.         In      AL,DX                     ;Get the status
  301.         In      AL,DX                     ;Again to clear any delta bits
  302.         Mov     Mstatus,AL                ;Set current modem status
  303.         Sti                               ;All done with buffers - enable ints
  304.  
  305.         Call    Cstat                     ;Allow Cstat to set status
  306.         Ret                               ;Return to caller
  307.  
  308. Copen   Endp
  309.  
  310.         Subttl  Put character in AL into buffer
  311.         Page
  312. Csend   Proc    Near                      ;Put the character in AX
  313.         Putbuf  Xmit                      ;Put AL to the transmit buffer
  314.         Jc      Csend2                    ;If carry, return buffer full
  315.         Inc     DX                        ;Point at Interrupt enable register
  316.         In      AL,DX                     ;Get the port
  317.         Test    AL,Thrint                 ;Is transmit already enabled?
  318.         Jnz     Csend1                    ;Yes - return
  319.         Or      AL,Thrint                 ;Enable xmit hold reg interrupt
  320.         Out     DX,AL                     ;And put it back out
  321.  
  322. Csend1  Label   Near
  323.         Dec     DX                        ;Point back to base address
  324.         Call    Ahstat                    ;Get status in AH
  325.         And     AH,0FF-Timeout            ;Turn off timeout bit
  326.         Ret                               ;Return to caller
  327.  
  328. Csend2  Label   Near
  329.         Call    Ahstat                    ;Get status in AH
  330.         Or      AH,Timeout                ;Set timeout bit (can't send)
  331.         Ret                               ;Return to caller
  332.  
  333. Csend   Endp
  334.  
  335.         Subttl  Receive a character from the buffer into AL
  336.         Page
  337. Crcve   Proc    Near
  338.         Getbuf  Rcve
  339.         Jc      Crcve1                    ;If buffer empty, return FF in AH
  340.         Call    Ahstat                    ;Get status in AH
  341.         And     AH,Timeout+Brkdet+Framerr+Parerr+Rcveovr ; Only error bits
  342.         Ret                               ;And return to caller
  343.  
  344. Crcve1  Label   Near
  345.         Mov     AH,-1                     ;Indicate buffer empty
  346.         Ret                               ;And return to caller
  347.  
  348. Crcve   Endp
  349.  
  350.         Subttl  Get port status
  351.         Page
  352. Cstat   Proc    Near
  353.         Call    Ahstat                    ;Get line status in AH
  354.         Mov     AL,Mstatus                ;Get modem status
  355.         Ret                               ;And return to caller
  356.  
  357. Ahstat  Proc    Near
  358.         Xor     AH,AH                     ;New line status (0)
  359.         Xchg    AH,Lstatus                ;Get line status and reset it
  360.  
  361. ;       Set the Transmit buff
  362.  
  363.         Mov     BX,Xmit.Endptr            ;Get start pointer
  364.         Cmp     BX,Xmit.Staptr            ;If Endptr = Staptr, Buffer empty
  365.         Jne     Ahstat1                   ;If not empty, check if full
  366.         Or      AH,Tbufemp+Tbufnfl        ;Turn on empty and not full
  367.         Jmp     Short Ahstat2             ;Check receive buffer
  368.  
  369. Ahstat1 Label   Near                      ;Transmit not empty, check if full
  370.         Incbuf  Xmit                      ;Point at next character
  371.         Cmp     BX,Xmit.Staptr            ;Equal to start of buffer?
  372.         Je      Ahstat2                   ;Yes - buffer is full.  Continue.
  373.         Or      AH,Tbufnfl                ;Not full, so set the bit.
  374.  
  375. Ahstat2 Label   Near
  376.         Mov     BX,Rcve.Staptr            ;Get start pointer
  377.         Cmp     BX,Rcve.Endptr            ;If Start = End, buffer empty
  378.         Jne     Ahstat3                   ;If empty, continue
  379.         Ret                               ;Else all done, so return to caller
  380.  
  381. ;       Now we have all the bits in AH set, so lets return to the caller.
  382.  
  383. Ahstat3 Label   Near
  384.         Or      AH,Rdatrdy                ;Set receive data ready
  385.         Ret                               ;Return to caller
  386.  
  387. Ahstat  Endp
  388.  
  389. Cstat   Endp
  390.  
  391.         Subttl  Close the Comm Port and flush the buffers
  392.         Page
  393. Cclos   Proc    Near
  394.         Xor     AL,AL                     ;No interrupts
  395.         Inc     DX                        ;Point at IER
  396.         Out     DX,AL                     ;Disable the interrupts
  397.         Push    DX                        ;Save IER address on stack
  398.         Mov     DX,21                     ;System interrupt mask
  399.         In      AL,DX                     ;Get the port
  400.         Or      AL,Asysmsk                ;Disable the interrupt
  401.         Out     DX,AL                     ;And put it back to the port
  402.         Pop     DX                        ;Restore origingal value of DX
  403.         Add     DX,3                      ;Point at Modem control reg
  404.         Out     DX,AL                     ;Turn off all bits
  405.         Sub     DX,3                      ;Back to base address
  406.         Flush   Xmit                      ;Clear the transmit buffer
  407.         Flush   Rcve                      ;Clear the receive buffer
  408.         Ret                               ;And return to caller
  409.  
  410. Cclos   Endp
  411.  
  412.         Subttl  Interrupt handlers
  413.         Page    +
  414. ;**********************************************************************
  415. ;*                                                                    *
  416. ;*        ASYNC INTERRUPT HANDLERS                                    *
  417. ;*                                                                    *
  418. ;**********************************************************************
  419. Int0C   Proc  Near
  420.         Sti                               ;Allow interrupts
  421.         Save    AX,BX,DX,DS               ;Save the regs
  422.         Mov     DX,20                     ;System interrupt controller
  423.         Mov     AL,20                     ;Reset interrupt pending
  424.         Out     DX,AL                     ;Put back to system controller
  425.         Push    CS                        ;Put CS into stack...
  426.         Pop     DS                        ;And pop it back into DS
  427.         Mov     DX,Baseadr                ;Get address of async port
  428.         Inc     DX                        ;Point at...
  429.         Inc     DX                        ;...Interrupt ID reg
  430.  
  431. Intloop Label   Near                      ;Handle interrupts loop
  432.         In      AL,DX                     ;Get interrupt type
  433.         Test    AL,1                      ;Any interrupt pending?
  434.         Jnz     Asynrtn                   ;No - return
  435.         Xor     BH,BH                     ;Prepare for indexed call
  436.         Mov     BL,AL                     ;Interrupt code to index reg
  437.         Push    DX                        ;Save DX across call
  438.         Call    Inttbl[BX]                ;Call the correct routine
  439.         Pop     DX                        ;Restore original DX
  440.         Jmp     Intloop                   ;Loop until all interrupts handled.
  441.  
  442. Asynrtn Label  Near
  443.         Restore
  444.         Iret                              ;Return from interrupt
  445.  
  446. Inttbl  Label   Word
  447.         Dw      Modemst                   ;Modem status interrupt
  448.         Dw      Xmithrg                   ;Transmit holding reg empty
  449.         Dw      Rdatint                   ;Receive data available
  450.         Dw      Rcvrlst                   ;Receiver line status
  451.  
  452.         Subttl  Get the modem status
  453.         Page
  454. Modemst Proc    Near                      ;Modem status
  455.         Add     DX,4                      ;Point at modem status reg
  456.         In      AL,DX                     ;Read it
  457.         Mov     Mstatus,AL                ;Place in status byte
  458.         Ret                               ;Return to caller
  459. Modemst Endp
  460.  
  461.         Subttl  Transmit a character from the buffer
  462.         Page
  463. Xmithrg Proc    Near                      ;Xmit hold reg empty
  464.         Dec     DX                        ;Point at IER
  465.         Cli                               ;Disable while working with buffer
  466.         Getbuf  Xmit                      ;Get a character from the buffer
  467.         Jc      Xmithr1                   ;No - disable transmit interrupts
  468.         Dec     DX                        ;Point at transmit holding reg
  469.         Out     DX,AL                     ;Put it out
  470.         Sti                               ;Enable interrupts
  471.         Ret                               ;Return to caller
  472.  
  473. Xmithr1 Label   Near
  474.         In      AL,DX                     ;Get the interrupt reg
  475.         And     AL,0FF-Thrint             ;Turn off xmit holing reg bit
  476.         Out     DX,AL                     ;And send it back out
  477.         Sti                               ;Re-enable interrupts
  478.         Ret                               ;Return to caller
  479.  
  480. Xmithrg Endp
  481.  
  482.         Subttl  Receive a byte into the buffer
  483.         Page
  484. Rdatint Proc    Near
  485.         Dec     DL                        ;Point to ...
  486.         Dec     DX                        ;... data reg
  487.         Cli                               ;Disable interrupts
  488.         In      AL,DX                     ;Get a byte
  489.         Test    Lstatus,Parerr            ;Parity error this byte?
  490.         Jz      Rdatpok                   ;No, parity OK
  491.         Or      AL,80h                    ;Bad parity, set high bit in AL
  492.         And     Lstatus,0FFh-Parerr       ;Turn off parity error
  493. Rdatpok Label   Near
  494.         Putbuf  Rcve                      ;Put into receive buffer
  495.         Jc      Rcve2                     ;If full, set overrun bit
  496.         Sti
  497.         Ret                               ;Return to caller
  498.  
  499. Rcve2   Label   Near
  500.         Sti                               ;Enable interrupts again
  501.         Or      Lstatus,Rcveovr           ;Set overrun
  502.         Ret                               ;And return to caller
  503.  
  504. Rdatint Endp
  505.  
  506.         Subttl  Receiver line status interrupt
  507.         Page
  508. Rcvrlst Proc    Near
  509.         Add     DL,3                      ;Point at line status reg
  510.         In      AL,DX                     ;Go read it
  511.         And     Lstatus,Rcveovr           ;Turn off all but overrun bit
  512.         And     AH,0FF-(Tbufemp+Tbufnfl+Rcveovr+Rdatrdy) ;Unwanted bits off
  513.         Or      Lstatus,AL                ;And turn on new status bits
  514.         Ret                               ;Return to caller
  515.  
  516. Rcvrlst Endp
  517.  
  518. Int0C   Endp
  519.  
  520. Resend  Equ     $                         ;Resident code ends here
  521.  
  522.         Subttl  Initialization routine
  523.         Page    +
  524. Start   Proc    Near                      ;Initialization code
  525.  
  526. ;       First of all, initialize the buffers
  527.  
  528.         Bufinit Xmit
  529.         Bufinit Rcve
  530.  
  531. ;       Now let's set the interrupt handlers
  532.  
  533.         Setint  0C,Int0C                  ;Port 1 Interrupt and routine
  534.         Setint  14,Int14                  ;Program interface interrupt
  535.  
  536. ;       And finally, terminate but leave resident code
  537. ;       Use the old Int 27 call for DOS 1.x compatability.
  538.  
  539.         Lea     DX,Resend                 ;Address end of resident section
  540.         Int     27                        ;Use Int 27 for DOS 1.0 Compatability
  541.  
  542. Start   Endp                              ;End of procedure
  543.  
  544. Comm    Ends
  545.         End     Entry
  546.