home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / mskermit / msxwng.asm < prev    next >
Assembly Source File  |  2020-01-01  |  24KB  |  812 lines

  1.     name msxwng
  2. ; File MSXWNG.ASM
  3. ; Last mmodification: 29 Juli 1988
  4. ; MS-DOS Kermit system-dependent module for the Wang PC
  5. ; Jeff Damens, CUCCA
  6. ; Add global entry point vtstat for use by Status in mssset.
  7. ; Correct corruption of registers in GETBAUD, CLRBUF, and POSCUR.
  8. ; Add clearing of terminal emulation flag, flags.vtflg, in procedure lclini.
  9. ; Joe R. Doupnik 12 March 1986
  10. ; Add global procedures ihosts and ihostr to handle host initialization
  11. ; when packets are to be sent or received by us,resp. 24 March 1986
  12. ; Add global procedure dtrlow (without worker serhng) to force DTR & RTS low
  13. ; in support of Kermit command Hangup. Says Not Yet Implemented. [jrd]
  14. ; Add global procedure Dumpscr, called by Ter in file msster, to dump screen
  15. ;  to a file. Just does a beep for now. 13 April 1986 [jrd]
  16. ; Add some dummy procedures and symbols to assemble and link with the rest
  17. ;  of the kermit release 2.31 of Juli 1st, 1988.
  18. ; Implement dobaud, so that the command SET BAUD has an immediate effect. [ve]
  19.  
  20.         public  serini, serrst, clrbuf, outchr, coms, vts, vtstat, dodel, ctlu
  21.         public  cmblnk, locate, lclini, prtchr, dobaud, clearl
  22.         public  dodisk, getbaud, beep, term, puthlp
  23.         public  count, poscur, machnam, sendbr, putmod, clrmod
  24.         public  setktab, setkhlp, xofsnt, showkey
  25.         public  ihosts, ihostr, dtrlow, dumpscr                 ; [jrd]
  26.     public    pcwait, shomodem, getmodem, sendbl, serhng    ; [ve]
  27.     public    comptab, termtb                 ; [ve]
  28.         include mssdef.h
  29.  
  30. false   equ     0
  31. true    equ     1
  32.  
  33. ctrla   equ     1               ; Control-A.
  34. escape    equ    27        ; [ve]
  35.  
  36. auxin   equ     3
  37. auxout  equ     4
  38. auxfil  equ     3               ; file number of aux file.
  39. iordy   equ     6               ; input ready function
  40. write   equ     40h
  41. wbios   equ     88h
  42. settrp  equ     02h
  43. clrtrp  equ     03h
  44. chrrdy  equ     01h
  45. txrdy   equ     02h
  46.  
  47. rcvdat  equ     1080h
  48. rcvstat equ     1082h
  49. rcvmod  equ     1084h
  50. rcvcmd  equ     1086h
  51. trdat   equ     1088h
  52. trmod   equ     108ch
  53. wrcmd   equ     108eh
  54.  
  55. ; mode bits
  56. mod1    equ     4dh                     ; clock rate, 8 bits, 1 stop bit
  57. mod2    equ     30h                     ; internal clock
  58.  
  59. ; command register bits
  60. txen    equ     01h
  61. dtr     equ     02h
  62. rxen    equ     04h
  63. brk     equ     08h
  64. clrerr  equ     10h
  65. rts     equ     20h
  66.  
  67.  
  68. datas   segment public 'datas'
  69.         extrn   drives:byte, flags:byte, trans:byte
  70.         extrn   portval:word, port1:byte, port2:byte, dmpname:byte ; [jrd]
  71.  
  72. portin  db      0
  73. crlf    db      cr,lf,'$'
  74. machnam db    'FIELD TEST [ve] Wang$'
  75. hngmsg  db      cr,lf,' The phone should have hungup.',cr,lf,'$' ; [jrd]
  76. hnghlp  db      cr,lf,' The modem control lines DTR and RTS for the current'
  77.         db      ' port are forced low (off)'
  78.         db      cr,lf,' to hangup the phone. Normally, Kermit leaves them'
  79.         db      ' high (on) when it exits.'
  80.         db      cr,lf,'$'                                       ; [jrd]
  81. rdbuf   db      80 dup (?)      ; temp buf [jrd]
  82. noimp   db      cr,lf,'Command not implemented.$'
  83. shkmsg  db      'Not implemented.'
  84. shklen  equ     $-shkmsg
  85. xofsnt  db      0               ; Say if we sent an XOFF.
  86. xofrcv  db      0               ; Say if we received an XOFF.
  87. setktab db      0
  88. setkhlp db      0
  89. invseq    db    escape,'[7m$'    ; Reverse video on.
  90. nrmseq    db    escape,'[0m$'    ; Reverse video off.
  91. ivlseq  db      79 dup (' '),cr,'$'     ; Make a line inverse video
  92. comphlp db      cr,lf,'1 (COM1)   2 (COM2)$'
  93. delstr  db      BS,' ',BS,'$'   ; Delete string.
  94. clrlin    db    cr,escape,'[K$'
  95. tmp     db      ?,'$'
  96. temp    dw      0
  97. temp1   dw      ?               ; Temporary storage.
  98. temp2   dw      ?               ; Temporary storage.
  99.  
  100. ; Entries for choosing communications port. [19b]
  101. comptab db      04H
  102.         db      01H,'1$'
  103.         dw      01H
  104.         db      01H,'2$'
  105.         dw      00H
  106.         db      04H,'COM1$'
  107.         dw      01H
  108.         db      04H,'COM2$'
  109.         dw      00H
  110.  
  111. termtb  db      tttypes                 ; entries for Status, not Set
  112.         mkeyw   'Heath-19',ttheath
  113.         mkeyw   'none',ttgenrc
  114.         mkeyw   'Tek4010',tttek
  115.         mkeyw   'VT102',ttvt100
  116.         mkeyw   'VT52',ttvt52
  117.  
  118.  
  119. ; variables for serial interrupt handler
  120.  
  121. source  db      bufsiz DUP(?)   ; Buffer for data from port.
  122. bufout  dw      0               ; buffer removal ptr
  123. count   dw      0               ; Number of chars in int buffer.
  124. bufin   dw      0               ; buffer insertion ptr
  125. telflg  db      0               ; Are we acting as a terminal. [16] [17c]
  126. clreol    db    escape,'[0K$'
  127. blank    db    escape,'[H',escape,'[J$'
  128. movcur    db    escape,'['
  129. colno   db      20 dup (?)
  130. ten     db      10
  131. prthnd  dw      0
  132. ourarg  termarg <>
  133. ; must parallel baud rate defs in pcdefs.
  134. baudtab db      0ffh            ; 45.5 baud (not supported)
  135.         db      0               ; 50
  136.         db      1               ; 75
  137.         db      2               ; 110
  138.         db      3               ; 134.5
  139.         db      4               ; 150
  140.         db      5               ; 300
  141.         db      6               ; 600
  142.         db      7               ; 1200
  143.         db      8               ; 1800
  144.         db      9               ; 2000
  145.         db      10              ; 2400
  146.         db      12              ; 4800
  147.         db      14              ; 9600
  148.         db      15              ; 19.2k
  149.         db      0ffh            ; 38.4k (ha)
  150.  
  151. nbaud   equ     $-baudtab
  152. qid     dw      ?
  153. prtcnt  dw      ?
  154. trqid   dw      ?
  155. tmqid   dw      ?
  156. brflg   db      ?
  157. datas   ends
  158.  
  159. code    segment public 'code'
  160.         extrn   comnd:near, dopar:near, prserr:near
  161.         extrn   sleep:near                              ; [jrd]
  162.         assume  cs:code,ds:datas
  163.  
  164.  
  165. ;; Wait for the # of milliseconds in ax, for non-IBM compatibles.
  166. ;; Thanks to Bernie Eiben for this one. Modified to use adjustable
  167. ; inner loop counter (pcwcnt, adjusted by proc pcwtst) by [jrd].
  168.  
  169. pcwcnt  dw      240             ; number of loops for 1 millisec in pcwait
  170.  
  171. pcwait  proc    near
  172.         push    cx
  173. pcwai0: mov     cx,pcwcnt       ; inner loop counter for 1 ms (240 @ 4.77 MHz)
  174. pcwai1: sub     cx,1            ; inner loop takes 20 clock cycles
  175.         jnz     pcwai1
  176.         dec     ax              ; outer loop counter
  177.         jnz     pcwai0          ; wait another millisecond
  178.         pop     cx
  179.         ret
  180. pcwait  endp
  181.  
  182.  
  183. DODISK  PROC    NEAR
  184.         mov ah,gcurdsk                  ; Current disk value to AL.
  185.         int dos
  186.         mov dl,al                       ; Put current disk in DL.
  187.         mov ah,seldsk                   ; Select current disk.
  188.         int dos                         ; Get number of drives in AL.
  189.         mov drives,al
  190.         ret
  191. DODISK  ENDP
  192.  
  193. ; Clear the input buffer before sending a packet. [20e]
  194.  
  195. CLRBUF  PROC    NEAR
  196.         push    ax              ; save regs [jrd]
  197.         push    bx              ; [jrd]
  198. clrb2:  mov     ah,ioctl        ; [jrd]
  199.         mov     bx,auxfil
  200.         mov     al,iordy
  201.         int     dos
  202.         cmp     al,0ffh
  203.         jne     clrb1                   ; not ready, keep going
  204.         mov     ah,auxin
  205.         int     dos
  206. ;;;[jrd]        jmp     clrbuf                  ; read char and keep going.
  207.         jmp     clrb2           ; [jrd]
  208. clrb1:  mov     count,0
  209.         mov ax,offset source
  210.         mov bufin,ax
  211.         mov bufout,ax
  212.         pop     bx              ; restore regs [jrd]
  213.         pop     ax              ; [jrd]
  214.         ret
  215. CLRBUF  ENDP
  216.  
  217. ; Common routine to clear to end-of-line. [19a]
  218.  
  219. CLEARL  PROC    NEAR
  220.         mov dx,offset clreol
  221.         mov ah,prstr
  222.         int dos
  223.         ret
  224. CLEARL  ENDP
  225.  
  226. ; This routine should set the baud rate for the current port but it
  227. ; is actually done in SERINI.
  228. ; WHY??? Let's do it here and in SERINI, don't matter if the baud rate
  229. ;     is set twice! [ve]
  230. dobaud  proc    near
  231.     mov dx,rcvcmd
  232.     in al,dx        ; read cmd register to reset mode ptr.
  233.     mov dx,trmod
  234.     mov al,mod1
  235.     out dx,al
  236.     push bx
  237.     mov bx,portval
  238.     mov si,[bx].baud
  239.     pop bx
  240.     mov al,baudtab[si]
  241.     or al,mod2
  242.     out dx,al
  243.         ret
  244. dobaud  endp
  245.  
  246. ; Send a break out the current serial port.  Returns normally.
  247. sendbl:
  248. sendbr: push dx
  249.         push ax
  250.         push cx
  251.         push ds                 ; preserve data segment
  252.         mov ax,cs
  253.         mov ds,ax               ; handler is in code segment
  254.         mov al,settrp
  255.         mov bx,txrdy            ; interrupt on transmitter empty
  256.         mov cx,0                ; interrupt immediately
  257.         mov dx,offset sendb1    ; handler routine
  258.         int wbios
  259.         pop ds
  260.         mov trqid,bx
  261.         push ds
  262.         mov ax,cs
  263.         mov ds,ax
  264.         mov al,settrp
  265.         mov bx,0                ; 10 ms timer
  266.         mov cx,21               ; after 21 times - approx 200 ms.
  267.         mov dx,offset sendb2    ; timer interrupt
  268.         int wbios
  269.         pop ds
  270.         mov tmqid,bx
  271.  
  272.         mov brflg,1
  273.         mov dx,rcvcmd
  274.         in al,dx                ; Read command register.
  275.         or al,brk+txen          ; Set send-break bit.
  276.         mov dx,wrcmd            ; Write command register.
  277.         out dx,al
  278. pause:  cmp brflg,0
  279.         jne pause               ; while non-zero, keep going
  280.         mov al,clrtrp           ; clear the trap
  281.         mov bx,trqid
  282.         int wbios
  283.         mov al,clrtrp
  284.         mov bx,tmqid
  285.         int wbios
  286.         pop cx
  287.         pop ax
  288.         pop dx
  289.         ret
  290.  
  291. sendb1  proc    far
  292.         ret
  293. sendb1  endp
  294.  
  295. sendb2  proc    far
  296.         push ax
  297.         push ds
  298.         mov ax,seg datas
  299.         mov ds,ax
  300.         mov brflg,0
  301.         mov dx,rcvcmd
  302.         in al,dx
  303.         and al,not (txen + brk)
  304.         mov dx,wrcmd
  305.         out dx,al
  306.         pop ds
  307.         pop ax
  308.         ret
  309. sendb2  endp
  310.  
  311.  
  312. ; Write a line in inverse video at the bottom of the screen...
  313. ; the line is passed in dx, terminated by a $.  Returns normally.
  314. putmod  proc    near
  315.         push    dx              ; preserve message
  316.         mov     dx,24 * 100H    ; line 24
  317.         call    poscur
  318.         mov     dx,offset invseq ; put into inverse video
  319.         mov     ah,prstr
  320.         int     dos
  321.         pop     dx
  322.         int     dos
  323.         mov     dx,offset nrmseq ; normal videw
  324.         int     dos
  325.         ret                     ; and return
  326. putmod  endp
  327.  
  328. ; Clear the mode line written by putmod.  Returns normally.
  329. clrmod  proc    near
  330.         mov     dx,24 * 100H
  331.         call    poscur
  332.         call    clearl
  333.         ret
  334. clrmod  endp
  335.  
  336. ; Put a help message one the screen in reverse video.  Pass
  337. ; the message in AX, terminated by a null.  Returns normally.
  338. ; The message is put wherever the cursor currently is located.
  339. puthlp  proc    near
  340.         push ax
  341.         mov ah,prstr            ; Leave some room before the message.
  342.         mov dx,offset crlf
  343.         int dos
  344.         mov dx,offset invseq    ; Put into reverse video.
  345.         int dos
  346.         pop si                  ; Put message address here.
  347. puth0:  mov ah,prstr
  348.         mov dx,offset ivlseq    ; Make line inverse video
  349.         int dos
  350. puth1:  lodsb
  351.         cmp al,0                ; Terminated with a null.
  352.         je puth2
  353.         mov dl,al
  354.         mov ah,conout
  355.         int dos
  356.         cmp al,lf               ; Line feed?
  357.         je puth0                ; Yes, clear the next line.
  358.         jmp puth1               ; Else, just keep on writing.
  359. puth2:  mov dx,offset nrmseq    ; Normal video.
  360.         mov ah,prstr
  361.         int dos
  362.         mov dx,offset crlf
  363.         int dos
  364.         ret
  365. puthlp  endp
  366.  
  367. outchr: push dx                 ; Save register.
  368.         mov al,ah
  369.         call dopar
  370.         mov dl,al
  371.         mov ah,auxout
  372.         int dos
  373.         pop     dx
  374.         jmp rskp
  375.  
  376.  
  377. ; This routine blanks the screen.
  378.  
  379. CMBLNK  PROC    NEAR
  380.         mov ah,prstr
  381.         mov dx,offset blank
  382.         int dos
  383.         ret
  384. CMBLNK  ENDP
  385.  
  386. LOCATE  PROC    NEAR
  387.         mov dx,0                ; Go to top left corner of screen.
  388.         jmp poscur              ; callret...
  389. LOCATE  ENDP
  390.  
  391. GETBAUD PROC    NEAR
  392.         push    ax              ; save regs [jrd]
  393.         push    bx              ; [jrd]
  394.         push    cx              ; [jrd]
  395.         push    dx              ; [jrd]
  396.         push    di              ; [jrd]
  397.         push    es              ; [jrd]
  398.         cld
  399.         mov dx,rcvmod
  400.         in al,dx
  401.         in al,dx                ; get second mode word
  402.         and     al,0fh          ; isolate baud rate
  403.         mov cx,nbaud
  404.         mov di,offset baudtab
  405.         mov bx,ds
  406.         mov es,bx               ; address correct segment
  407.         mov bx,portval
  408.         repne scasb             ; look for baud rate
  409.         jne getb1               ; mystery baud rate...
  410.         sub di,offset baudtab + 1
  411.         mov [bx].baud,di        ; store baud rate in comm area
  412.         jmp getb2       ; [jrd]
  413. ;;;[jrd]        ret                     ; and return
  414. getb1:  mov [bx].baud,-1        ; unknown baud rate
  415. getb2:  pop     es      ; restore regs. [jrd]
  416.         pop     di      ; [jrd]
  417.         pop     dx      ; [jrd]
  418.         pop     cx      ; [jrd]
  419.         pop     bx      ; [jrd]
  420.         pop     ax      ; [jrd]
  421.         ret
  422. GETBAUD ENDP
  423.  
  424. ; skip returns if no character available at port,
  425. ; otherwise returns with char in al, # of chars in buffer in dx.
  426. PRTCHR  PROC    NEAR
  427. prtchx: cmp count,0
  428.         je prtch4               ; empty buffer, forget it.
  429.         push si                 ; save reg. [jrd]
  430.         mov si,bufout
  431.         lodsb
  432.         cmp si,offset source + bufsiz
  433.         jb prtch1
  434.         mov si,offset source
  435. prtch1: mov bufout,si
  436.         pop si                  ; [jrd]
  437.         dec count
  438.         push bx
  439.         mov bx,portval
  440.         cmp [bx].parflg,PARNON ; no parity?
  441.         je prtch3               ; then don't strip
  442.         and al,7fh              ; else turn off parity
  443. prtch3: mov dx,count            ; chars left in buffer
  444.         pop bx
  445.         ret
  446. prtch4: jmp rskp                ; no chars...
  447. PRTCHR  ENDP
  448.  
  449. ; IHOSTS - Initialize the host by sending XON, or equivalent, and enter the
  450. ; cycle of clear input buffer, wait 1 second, test if buffer empty then exit
  451. ; else repeat cycle. Requires that the port be initialized before hand.
  452. ; Ihosts is used by the local send-file routine just after initializing
  453. ; the serial port.
  454. ; 22 March 1986 [jrd]
  455.  
  456. IHOSTS  PROC    NEAR
  457.         push    ax              ; save the registers
  458.         push    bx
  459.         push    cx
  460.         push    dx
  461.         mov     bx,portval      ; port indicator
  462.         mov     ax,[bx].flowc   ; put Go-ahead flow control char in ah
  463.         call    outchr          ; send it (release Host's output queue)
  464.          nop                    ; outchr can do skip return
  465.          nop
  466.          nop
  467. ihosts1:call    clrbuf          ; clear out interrupt buffer
  468.         mov     ax,1            ; sleep for 1 second
  469.         call    sleep           ; procedure sleep is in msscom.asm
  470.         call    prtchr          ; check for char at port
  471.          jmp    ihosts1         ; have a char in al, repeat wait/read cycle
  472.          nop                    ; prtchr does skip return on empty buffer
  473.         pop     dx              ; empty buffer. we are done here.
  474.         pop     cx
  475.         pop     bx
  476.         pop     ax
  477.         ret
  478. IHOSTS  ENDP
  479.  
  480. ; IHOSTR - initialize the remote host for our reception of a file by
  481. ; sending the flow-on character (XON typically) to release any held
  482. ; data. Called by receive-file code just after initializing the serial
  483. ; port.         22 March 1986 [jrd]
  484. IHOSTR  PROC    NEAR
  485.         push    ax              ; save regs
  486.         push    bx
  487.         push    cx
  488.         mov     bx,portval      ; port indicator
  489.         mov     ax,[bx].flowc   ; put Go-ahead flow control char in ah
  490.         call    outchr          ; send it (release Host's output queue)
  491.          nop                    ; outchr can do skip return
  492.          nop
  493.          nop
  494.         pop     cx
  495.         pop     bx
  496.         pop     ax
  497.         ret
  498. IHOSTR  ENDP
  499.  
  500. DTRLOW  PROC    NEAR            ; Global proc to Hangup the Phone by making
  501.                                 ; DTR and RTS low.
  502.         mov ah,cmtxt            ; allow text to be able to display help
  503.         mov bx,offset rdbuf     ; dummy buffer
  504.         mov dx,offset hnghlp    ; help message
  505.         call comnd              ; get a confirm
  506.          jmp r
  507. ; not yet imp.  call serhng             ; drop DTR and RTS
  508.         mov ah,prstr            ; give a nice message
  509. ; not yet imp.  mov dx,offset hngmsg
  510.         mov dx,offset noimp     ; for now
  511.         int dos
  512.         jmp rskp
  513. DTRLOW  ENDP
  514.  
  515. ; Hang up the Phone. Similar to SERRST except it just forces DTR and RTS low
  516. ; to terminate the connection. 29 March 1986 [jrd]
  517. ; 5 April 1987 Add 500 millisec wait with lines low before returning. [jrd]
  518. ; Calling this twice without intervening calls to serini should be harmless.
  519. ; If network then call nethangup procedure to hangup the session without
  520. ; losing local name information.
  521. ; Returns normally.
  522.  
  523. serhng  proc    near    ; clear modem's delta status bits and lower DTR & RTS
  524. ; SERHNG is Not Yet Implemented, just do a quick return
  525.         ret
  526. serhng  endp
  527.  
  528. ; Position the cursor according to contents of DX.
  529.  
  530. POSCUR  PROC    NEAR
  531.         push    es              ; save regs. [jrd]
  532.         push    ax              ; [jrd]
  533.         push    dx              ; [jrd]
  534.         push    di              ; [jrd]
  535.         mov     ax,ds
  536.         mov     es,ax                   ; address data segment!!!
  537.         cld
  538.         mov     di,offset colno
  539.         mov     al,dh                   ; row
  540.         inc     al
  541.         call    nout
  542.         mov     al,';'
  543.         stosb
  544.         mov     al,dl                   ; col
  545.         inc     al
  546.         call    nout
  547.         mov     al,'H'
  548.         stosb
  549.         mov     al,'$'
  550.         stosb
  551.         mov     dx,offset movcur
  552.         mov     ah,prstr
  553.         int     dos                     ; print the sequence
  554.         pop     di              ; restore regs [jrd]
  555.         pop     dx              ; [jrd]
  556.         pop     ax              ; [jrd]
  557.         pop     es              ; [jrd]
  558.         ret
  559. POSCUR  ENDP
  560.  
  561. NOUT    PROC    NEAR
  562.         cbw                     ; extend to word
  563.         div     byte ptr ten    ; divide by 10
  564.         or      al,al           ; any quotient?
  565.         jz      nout1           ; no, forget this
  566.         push    ax              ; save current result
  567.         call    nout            ; output high order
  568.         pop     ax              ; restore
  569. nout1:  mov     al,ah           ; get digit
  570.         add     al,'0'          ; make printable
  571.         stosb
  572.         ret                     ; put in buffer and return
  573. NOUT    endp
  574.  
  575. ; Perform a delete.
  576.  
  577. DODEL   PROC    NEAR
  578.         mov ah,prstr
  579.         mov dx,offset delstr    ; Erase weird character.
  580.         int dos
  581.         ret
  582. DODEL   ENDP
  583.  
  584. ; Perform a Control-U.
  585.  
  586. CTLU    PROC    NEAR
  587.         mov ah,prstr
  588.         mov dx,offset clrlin
  589.         int dos
  590.         ret
  591. CTLU    ENDP
  592.  
  593. COMS    PROC    NEAR
  594.         mov dx,offset comptab
  595.         mov bx,offset comphlp
  596.         mov ah,cmkey
  597.         call comnd
  598.          jmp r
  599.         push bx
  600.         mov ah,cmcfm
  601.         call comnd              ; Get a confirm.
  602.          jmp comx               ;  Didn't get a confirm.
  603.          nop
  604.         pop bx
  605.         mov flags.comflg,bl     ; Set the comm port flag.
  606.         cmp flags.comflg,1      ; Using Com 1?
  607.         jne coms0               ; Nope.
  608.         mov ax,offset port1
  609.         mov portval,ax
  610.         ret
  611. coms0:  mov ax,offset port2
  612.         mov portval,ax
  613.         ret
  614. comx:   pop bx
  615.         ret
  616. COMS    ENDP
  617.  
  618. VTS     PROC    NEAR
  619.         jmp notimp
  620. VTS     ENDP
  621.  
  622. VTSTAT  PROC    NEAR    ; For Status display [jrd]
  623.         ret             ; no emulator status to display
  624. VTSTAT  ENDP
  625.  
  626. ; Save the screen to a buffer and then append buffer to a disk file. [jrd]
  627. ; Default filename is Kermit.scn; actual file can be a device too. Filename
  628. ; is determined by mssset and is passed as pointer dmpname.
  629.  
  630. DUMPSCR PROC    NEAR    ; Dumps screen contents to a file. Just Beeps here
  631.         call beep       ; [jrd]
  632.         ret
  633. DUMPSCR ENDP
  634.  
  635.  
  636. notimp: mov ah,prstr
  637.         mov dx,offset noimp
  638.         int dos
  639.         jmp prserr
  640.  
  641. lclini: mov trans.escchr,ctrla  ; Use Control-A as escape char.
  642.         mov flags.vtflg,0       ; no terminal emulation. [jrd]
  643.         ret
  644.  
  645. showkey:
  646.         mov ax,offset shkmsg
  647.         mov cx,shklen
  648.         ret
  649.  
  650. ; SHOW MODEM, displays current status of lines DSR, CD, and CTS.
  651. ; Uses byte mdmhand, the modem line status register. [jrd]
  652. shomodem proc   near
  653.  ; NOT YET IMPLEMENTED, just do a quick return:
  654.       ret
  655. shomodem endp
  656.  
  657. ; Get modem status and set global byte mdmhand. Preserve all registers.
  658. getmodem proc   near                    ; gets modem status upon request
  659.  ; NOT YET IMPLEMENTED, just do a quick return:
  660.         ret
  661. getmodem endp
  662.  
  663.  
  664. ;     Common initialization for using serial port.
  665.  
  666. SERINI  PROC    NEAR
  667.         cmp portin,0            ; already inited?
  668.         jne serin1              ; yes, skip it
  669.         mov portin,1            ; remember inited
  670.         mov dx,rcvcmd
  671.         in al,dx                ; read cmd register to reset mode ptr.
  672.         mov dx,trmod
  673.         mov al,mod1
  674.         out dx,al
  675.         push bx
  676.         mov bx,portval
  677.         mov si,[bx].baud
  678.         pop bx
  679.         mov al,baudtab[si]
  680.         or al,mod2
  681.         out dx,al
  682.         mov dx,wrcmd
  683.         mov al,txen+dtr+rxen+clrerr+rts
  684.         out dx,al               ; enable transmit and receive
  685.         call clrbuf             ; empty buffer
  686.         mov al,settrp
  687.         mov bx,chrrdy           ; interrupt on character ready
  688.         mov cx,0                ; interrupt immediately
  689.         mov dx,offset serint    ; handler routine
  690.         mov prtcnt,0            ; no characters in yet
  691.         push ds
  692.         mov si,cs
  693.         mov ds,si
  694.         int wbios
  695.         pop ds
  696.         or al,al
  697.         jne serin1
  698.         mov qid,bx              ; preserve trap identification
  699. serin1: ret                     ; We're done. [21c]
  700. SERINI  ENDP
  701.  
  702. SERRST  PROC    NEAR
  703.         cmp portin,0            ; already de-inited?
  704.         je serrs1               ; yes, skip this
  705.         push bx                 ; save reg. [jrd]
  706.         mov portin,0
  707.         mov al,clrtrp
  708.         mov bx,qid
  709.         int wbios
  710.         pop bx                  ; [jrd]
  711. serrs1: ret
  712. SERRST  ENDP
  713.  
  714. ; serial interrupt handler
  715. serint  proc    far
  716.         push ds
  717.         push ax
  718.         push dx
  719.         push di
  720.         mov ax,seg datas
  721.         mov ds,ax
  722.         mov di,bufin
  723.         mov dx,rcvdat
  724.         in al,dx
  725.         mov [di],al
  726.         inc di
  727.         cmp di,offset source + bufsiz
  728.         jb sernt1
  729.         mov di,offset source
  730. sernt1: mov bufin,di
  731.         inc count
  732.         pop di
  733.         pop dx
  734.         pop ax
  735.         pop ds
  736.         ret
  737. serint  endp
  738.  
  739.  
  740. ; Generate a short beep.
  741.  
  742. BEEP    PROC    NEAR
  743.         mov dl,bell
  744.         mov ah,conout
  745.         int dos
  746.         ret
  747. BEEP    ENDP
  748.  
  749. ; Jumping to this location is like retskp.  It assumes the instruction
  750. ;   after the call is a jmp addr.
  751.  
  752. RSKP    PROC    NEAR
  753.         pop bp
  754.         add bp,3
  755.         push bp
  756.         ret
  757. RSKP    ENDP
  758.  
  759. ; Jumping here is the same as a ret.
  760.  
  761. R       PROC    NEAR
  762.         ret
  763. R       ENDP
  764.  
  765. term    proc    near
  766.         mov si,ax               ; this is source
  767.         mov di,offset ourarg    ; place to store arguments
  768.         mov ax,ds
  769.         mov es,ax               ; address destination segment
  770.         mov cx,size termarg
  771.         rep movsb               ; copy into our arg blk
  772. term1:  call prtchr
  773.         jmp short term2         ; have a char...
  774.         nop
  775.         nop
  776.         jmp short term3         ; no char, go on
  777. term2:  and al,7fh
  778.         push ax
  779.         mov dl,al
  780.         mov ah,dconio
  781.         int dos                 ; write out the character
  782.         pop ax
  783.         test ourarg.flgs,capt   ; capturing output?
  784.         jz term3                ; no, forget it
  785.         call ourarg.captr       ; else call the routine
  786. term3:  mov ah,dconio
  787.         mov dl,0ffh
  788.         int dos
  789.         or al,al
  790.         jz term1                ; no character, go on
  791.     cmp al,ourarg.escc    ; escape char?
  792.         je term4                ; yes, exit
  793.         push ax                 ; save char
  794.         mov ah,al
  795.         call outchr             ; output the character
  796.         nop
  797.         nop
  798.         nop
  799.         pop ax
  800.         test ourarg.flgs,lclecho ; echoing?
  801.         jz term1                ; no, continue loop
  802.         mov dl,al
  803.         mov ah,dconio
  804.         int dos
  805.         jmp term1               ; else echo and keep going
  806. term4:  ret
  807. term    endp
  808. code    ends
  809.         end
  810.         end
  811.  
  812.