home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 15 / CDACTUAL15.iso / cdactual / program / asm / MSKERMIT.ZIP / MSRECV.ASM < prev    next >
Encoding:
Assembly Source File  |  1986-05-17  |  19.0 KB  |  575 lines

  1.     public    read12, read2, rin21, rfile3, read, updrtr, nak, rrinit
  2.     include msdefs.h
  3.  
  4. datas    segment public 'datas'
  5.     extrn    fcb:byte, data:byte, bufpnt:word, chrcnt:word, curchk:byte
  6.     extrn    comand:byte, flags:byte, pack:byte, trans:byte
  7.  
  8. ermes7    db    '?Unable to receive initiate$'
  9. ermes8    db    '?Unable to receive file name$'
  10. ermes9    db    '?Unable to receive end of file$'
  11. erms10    db    '?Unable to receive data$'
  12. infms1    db    cr,'           Receiving: In progress$'
  13. infms3    db    'Completed$'
  14. infms4    db    'Failed$'
  15. infms6    db    'Interrupted$'
  16. remmsg1 db    'Kermit-MS: Invalid filename'
  17. filhlp2 db    ' Confirm with carriage return or specify name '
  18.     db    ' to use for incoming file $'
  19. ender    db    bell,bell,'$'
  20. crlf    db    cr,lf,'$'
  21. temp    dw    0
  22. datas    ends
  23.  
  24. code    segment public
  25.     extrn    gofil:near, outbuf:near, fixfcb:near, comnd:near
  26.     extrn    spack:near, rpack:near, serini:near, serrst:near
  27.     extrn    spar:near, rpar:near, init:near, init1:near, cxmsg:near
  28.     extrn    error:near, ptchr:near, erpos:near, rtpos:near
  29.     extrn    stpos:near, rprpos:near, nppos:near, nout:near
  30.     extrn    dodec:near, doenc:near, errpack:near
  31.     extrn    send11:near, clrmod:near
  32.     assume    cs:code, ds:datas
  33.  
  34.  
  35. ; Update retry count and fall through to send a NAK.
  36. nak0:    call updrtr        ; Update retry count.
  37.  
  38. nak:    mov ax,pack.pktnum     ; Get the packet number we're waiting for.
  39.     mov pack.argblk,ax
  40.     mov pack.argbk1,0
  41.     mov cx,0        ; No data, but this may change.
  42.     call doenc        ; So call encode.
  43.     mov ah,'N'              ; NAK that packet.
  44.     call spack
  45.      jmp abort
  46.      nop            ; So 'jmp rskp' in SPACK comes here. [19a]
  47.     ret            ; Go around again.
  48.  
  49. updrtr: cmp pack.state,'A'      ; Supposed to abort?
  50.     je upd0         ; Yes, don't bother with retry count.
  51.     inc pack.numrtr     ; Increment the number of retries.
  52.     cmp flags.xflg,1    ; Writing to screen?
  53.     je upd0
  54.     call rtpos        ; Position cursor.
  55.     mov ax,pack.numrtr
  56.     call nout        ; Write the number of retries.
  57. upd0:    ret
  58.  
  59. ;    Abort
  60. ABORT    PROC    NEAR
  61.     mov pack.state,'A'      ; Otherwise abort.
  62.     ret
  63. ABORT    ENDP
  64.  
  65. ; init variables for read...
  66. rrinit    proc    near
  67.     mov pack.numpkt,0    ; Set the number of packets to zero.
  68.     mov pack.numrtr,0    ; Set the number of retries to zero.
  69.     mov pack.pktnum,0    ; Set the packet number to zero.
  70.     mov pack.numtry,0    ; Set the number of tries to zero.
  71.     ret
  72. rrinit    endp
  73.  
  74. ;    RECEIVE command  --  Some code moved to the GET routine. [21a]
  75.  
  76. READ    PROC    NEAR
  77.     mov comand.cmrflg,1    ; Say we're receiving a file. [21a start]
  78.     mov comand.cmcr,1    ; Allow bare CR after RECEIVE.
  79.     mov flags.droflg,0    ; Override default drive flag.
  80.     mov flags.nmoflg,0    ; Override file name from other host?
  81.     mov dx,offset fcb    ; Put filename here.
  82.     mov bx,offset filhlp2    ; Text of help message.
  83.     mov ah,cmifi        ; Read in the filename.
  84.     call comnd
  85.      jmp r
  86.     mov comand.cmrflg,0    ; Reset flag.
  87.     mov comand.cmcr,0
  88.     mov flags.wldflg,0    ; Just in case
  89.     mov ah,cmcfm        ; Get a confirm.
  90.     call comnd
  91.      jmp r
  92. read1:    cmp flags.remflg,0    ; remote mode?
  93.     jne read12        ; yes, no printing
  94.     call init
  95. read12: mov flags.cxzflg,0    ; Reset ^X/^Z flag. [20c]
  96.     call rrinit        ; init variables for read
  97.     call serini        ; Initialize serial port. [14]
  98.     cmp flags.remflg,0    ; in remote mode?
  99.     jne read12a        ; yes, no printing
  100.     call init1        ; Clear the line and initialize the buffers.
  101.     call stpos
  102.     mov ah,prstr        ; Be informative.
  103.     mov dx,offset infms1
  104.     int dos
  105.     call rtpos        ; Position cursor.
  106.     mov ax,pack.numrtr
  107.     call nout        ; Write the number of retries.
  108. read12a:mov pack.state,'R'      ; Set the state to receive initiate.
  109. read2:    cmp flags.xflg,1    ; Are we receiving to the screen. [21c]
  110.     je read21        ; Skip the screen stuff. [21c]
  111.     cmp flags.remflg,0    ; maybe remote mode?
  112.     jne read21        ; yup, skip the screen stuff
  113.     call nppos        ; Position cursor for number of packets msg.
  114.     mov ax,pack.numpkt
  115.     call nout        ; Write the number of packets.
  116. read21: mov ah,pack.state    ; Get the state. [21c]
  117.     cmp ah,'D'              ; Are we in the data send state?
  118.     jne read3
  119.     call rdata
  120.     jmp read2
  121. read3:    cmp ah,'F'              ; Are we in the file receive state?
  122.     jne read4
  123.     call rfile        ; Call receive file.
  124.     jmp read2
  125. read4:    cmp ah,'R'              ; Are we in the receive initiate state?
  126.     jne read5
  127.     call rinit
  128.     jmp read2
  129. read5:    cmp ah,'C'              ; Are we in the receive complete state?
  130.     jne read6
  131.     call serrst        ; Reset serial port. [14]
  132.     cmp flags.xflg,0    ; Did we write to the screen? [21c]
  133.     je read51        ; No so print status. [21c]
  134.     mov flags.xflg,0    ; Reset it. [21c]
  135.     jmp rskp        ; Yes, so just return. [21c]
  136. read51: cmp flags.remflg,0    ; remote mode?
  137.     jne read51a        ; yes, keep going
  138.     call stpos        ; Position cursor. [21c]
  139.     mov ah,prstr
  140.     mov dx,offset infms3    ; Plus a little cuteness.
  141.     cmp flags.cxzflg,0    ; Completed or interrupted? [20c]
  142.     je read13        ; Ended normally. [20c]
  143.     mov dx,offset infms6    ; Say was interrupted. [20c]
  144. read13: int dos
  145.     cmp flags.belflg,0    ; Bell desired?  [17a]
  146.     je readnb        ; No.  [17a]
  147.     mov dx,offset ender    ; Ring them bells.    [4]
  148.     int dos         ; [4]
  149. readnb: call clrmod        ; clear 25th line
  150.     call rprpos        ; Put prompt here.
  151. read51a:jmp rskp
  152. read6:    call serrst        ; Reset serial port. [14]
  153.     cmp flags.xflg,0    ; Did we write out to screen? [21c]
  154.     je read61        ; No so print status. [21c]
  155.     mov flags.xflg,0    ; Reset it. [21c]
  156.     jmp rskp        ; Print onto screen. [21c]
  157. read61: cmp flags.remflg,0    ; remote mode?
  158.     jne read7a        ; yes, no printing.
  159.     call stpos        ; Position cursor.  [21c]
  160.     mov ah,prstr
  161.     mov dx,offset infms4    ; Plus a little cuteness.
  162.     int dos
  163.     cmp flags.belflg,0    ; Bell desired?  [17a]
  164.     je read7        ; No.  [17a]
  165.     mov dx,offset ender    ; Ring them bells.   [4]
  166.     int dos         ;  [4]
  167. read7:    call clrmod        ; clear mode line
  168.     call rprpos        ; Put prompt here.
  169. read7a: jmp rskp
  170. READ    ENDP
  171.  
  172.  
  173. ;    Receive routines
  174.  
  175. ;    Receive init
  176.  
  177. RINIT    PROC    NEAR
  178.     mov ah,pack.numtry    ; Get the number of tries.
  179.     cmp ah,imxtry        ; Have we reached the maximum number of tries?
  180.     jl rinit2
  181.     call erpos        ; Position cursor.
  182.     mov dx,offset ermes7
  183.     mov ah,prstr
  184.     int dos         ; Print an error message.
  185.     mov bx,dx
  186.     call errpack        ; Send error packet just in case.
  187.     jmp abort        ; Change the state to abort.
  188. rinit2: inc ah            ; Increment it.
  189.     mov pack.numtry,ah    ; Save the updated number of tries.
  190.     mov ax,pack.argbk2    ; get packet type if here from get
  191.     cmp flags.getflg,1    ; Have we already read in the packet? [21a]
  192.     je rin21a        ; Yes, so don't call RPACK. [21a]
  193.     mov ah,trans.chklen
  194.     mov curchk,ah        ; Save checksum length we want to use.
  195.     mov trans.chklen,1    ; Use 1 char for init packet.
  196.     call rpack        ; Get a packet.
  197.      jmp rin22        ; Trashed packet: nak, retry.
  198.     push ax
  199.     mov ah,curchk
  200.     mov trans.chklen,ah    ; Reset to desired value.
  201.     pop ax
  202. rin21a: cmp ah,'S'              ; Is it a send initiate packet?
  203.     jne rinit3        ; If not see if its an error.
  204. rin21:    mov flags.getflg,0    ; Reset flag. [21a]
  205.     mov ah,pack.numtry    ; Get the number of tries.
  206.     mov pack.oldtry,ah    ; Save it.
  207.     mov pack.numtry,0    ; Reset the number of tries.
  208.     mov ax,pack.argblk    ; Returned packet number.  (Synchronize them.)
  209.     inc ax            ; Increment it.
  210.     and ax,3FH        ; Turn off the two high order bits.
  211.     mov pack.pktnum,ax    ; Save modulo 64 of the number.
  212.     mov bx,pack.numpkt
  213.     inc bx            ; Increment the number of packets.
  214.     mov pack.numpkt,bx
  215.     mov ax,pack.argbk1    ; Get the number of arguments received.
  216.     mov bx,offset data    ; Get a pointer to the data.
  217.     call spar        ; Get the data into the proper variables.
  218.     mov bx,offset data    ; Get a pointer to our data block.
  219.     call rpar        ; Set up the receive parameters.
  220.     xchg ah,al
  221.     mov ah,0
  222.     mov pack.argbk1,ax    ; Store the returned number of arguments.
  223.     mov ah,trans.chklen    ; Checksum length we'll use.
  224.     mov curchk,ah        ; Save it.
  225.     mov trans.chklen,1    ; Use 1 char for init packet.
  226.     mov ah,'Y'              ; Acknowledge packet.
  227.     call spack        ; Send the packet.
  228.      jmp abort
  229.     mov ah,curchk        ; Checksum length we'll use.
  230.     mov trans.chklen,ah    ; Reset to desired value.
  231.     mov ah,'F'              ; Set the state to file send.
  232.     mov pack.state,ah
  233.     ret
  234. rin22:    mov ah,curchk
  235.     mov trans.chklen,ah    ; Reset to desired value.
  236.     jmp nak0        ; Try again.
  237. rinit3: cmp ah,'E'              ; Is it an error packet?
  238.     jne rinit4
  239.     call error
  240. rinit4: jmp abort
  241. RINIT    ENDP
  242.  
  243.  
  244. ;    Receive file
  245.  
  246. RFILE    PROC    NEAR
  247.     cmp pack.numtry,maxtry    ; Have we reached the maximum number of tries?
  248.     jl rfile1
  249.     call erpos        ; Position cursor.
  250.     mov dx,offset ermes8
  251.     mov ah,prstr
  252.     int dos         ; Print an error message.
  253.     mov bx,dx
  254.     call errpack        ; Send error packet just in case.
  255.     jmp abort        ; Change the state to abort.
  256. rfile1: inc pack.numtry     ; Save the updated number of tries.
  257.     call rpack        ; Get a packet.
  258.      jmp nak0        ;  Trashed packet: nak, retry.
  259.     cmp ah,'S'              ; Is it a send initiate packet?
  260.     je rfil10
  261.     call dodec        ; Decode all incoming packets.
  262.     jmp rfile2        ;  No, try next type.
  263. rfil10: cmp pack.oldtry,imxtry    ; Have we reached the maximum number of tries?
  264.     jl rfil12        ; If not proceed.
  265.     call erpos        ; Position cursor.
  266.     mov dx,offset ermes7
  267.     mov ah,prstr
  268.     int dos         ; Print an error message.
  269.     mov bx,dx
  270.     call errpack        ; Send error packet just in case.
  271.     jmp abort        ; Change the state to abort.
  272. rfil12: inc pack.oldtry     ; Save the updated number of tries.
  273.     mov ax,pack.pktnum    ; Get the present packet number.
  274.     cmp ax,0        ; Had we wrapped around? [18 start]
  275.     jne rfilx
  276.     mov ax,64
  277. rfilx:    dec ax            ; Decrement.  [18 end -- new label]
  278.     cmp ax,pack.argblk    ; Is the packet's number one less than now?
  279.     je rfil13
  280.     jmp nak0        ; No, NAK and try again.
  281. rfil13: call updrtr        ; Update retry count.
  282.     mov pack.numtry,0    ; Reset the number of tries.
  283.     mov bx,offset data    ; Get a pointer to our data block.
  284.     call rpar        ; Set up the parameter information.
  285.     xchg ah,al
  286.     mov ah,0
  287.     mov pack.argbk1,ax    ; Save the number of arguments.
  288.     mov ah,'Y'              ; Acknowledge packet.
  289.     call spack        ; Send the packet.
  290.      jmp abort
  291.     ret
  292. rfile2: cmp ah,'Z'              ; Is it an EOF packet?
  293.     jne rfile3        ;  No, try next type.
  294.     cmp pack.oldtry,maxtry    ; Have we reached the maximum number of tries?
  295.     jl rfil21        ; If not proceed.
  296.     call erpos        ; Position cursor.
  297.     mov dx,offset ermes9
  298.     mov ah,prstr
  299.     int dos         ; Print an error message.
  300.     mov bx,dx
  301.     call errpack        ; Send error packet just in case.
  302.     jmp abort        ; Change the state to abort.
  303. rfil21: inc pack.oldtry     ; Increment it.
  304.     mov ax,pack.pktnum    ; Get the present packet number.
  305.     cmp ax,0        ; Had we wrapped around? [18 start]
  306.     jne rfily
  307.     mov ax,64
  308. rfily:    dec ax            ; Decrement.  [18 end -- new label]
  309.     cmp ax,pack.argblk    ; Is the packet's number one less than now?
  310.     je rfil24
  311.     jmp nak0        ; No, NAK and try again.
  312. rfil24: call updrtr        ; Update retry count.
  313.     mov pack.numtry,0
  314.     mov pack.argbk1,0    ; No data.  (The packet number is in argblk.)
  315.     mov cx,0
  316.     call doenc
  317.     mov ah,'Y'              ; Acknowledge packet.
  318.     call spack        ; Send the packet.
  319.      jmp abort
  320.     ret
  321. rfile3: cmp ah,'F'              ; Start of file?
  322.     je rfil31        ; Yes. [21c]
  323.     cmp ah,'X'              ; Text header packet? [21c]
  324.     jne rfile4        ; Neither one.
  325. rfil31: mov ax,pack.argblk    ; Get the packet number. [21c]
  326.     cmp ax,pack.pktnum    ; Is it the right packet number?
  327.     je rfil32
  328.     jmp nak         ; No, NAK it and try again.
  329. rfil32: inc ax            ; Increment the packet number.
  330.     and ax,3FH        ; Turn off the two high order bits.
  331.     mov pack.pktnum,ax    ; Save modulo 64 of the number.
  332.     inc pack.numpkt     ; Increment the number of packets.
  333.     call gofil        ; Get a file to write to.
  334.      jmp abort
  335.     call init1        ; Initialize all the buffers.
  336.     mov ah,pack.numtry    ; Get the number of tries.
  337.     mov pack.oldtry,ah    ; Save it.
  338.     mov pack.numtry,0    ; Reset the number of tries.
  339.     mov pack.argbk1,0    ; No data.  (The packet number is in argblk.)
  340.     mov cx,0
  341.     call doenc
  342.     mov ah,'Y'              ; Acknowledge packet.
  343.     call spack        ; Send the packet.
  344.      jmp abort
  345.     mov pack.state,'D'      ; Set the state to data receive.
  346.     ret
  347. rfile4: cmp ah,'B'              ; End of transmission.
  348.     jne rfile5
  349.     mov ax,pack.pktnum
  350.     cmp ax,pack.argblk    ; Do we match?
  351.     je rfil41
  352.     jmp nak         ; No, NAK it and try again.
  353. rfil41: mov pack.argbk1,0    ; No data.  (Packet number already in argblk).
  354.     mov cx,0
  355.     call doenc
  356.     mov ah,'Y'              ; Acknowledge packet.
  357.     call spack        ; Send the packet.
  358.      jmp abort
  359.     mov pack.state,'C'      ; Set the state to complete.
  360.     ret
  361. rfile5: cmp ah,'E'              ; Is it an error packet.
  362.     jne rfile6
  363.     call error
  364. rfile6: jmp abort
  365. RFILE    ENDP
  366.  
  367.  
  368. ;    Receive data
  369.  
  370. RDATA    PROC    NEAR
  371.     cmp pack.numtry,maxtry    ; Get the number of tries.
  372.     jl rdata1
  373.     call erpos        ; Position cursor.
  374.     mov dx,offset erms10
  375.     mov ah,prstr
  376.     int dos         ; Print an error message.
  377.     mov bx,dx
  378.     call errpack        ; Send error packet just in case.
  379.     jmp abort        ; Change the state to abort.
  380. rdata1: inc pack.numtry     ; Save the updated number of tries.
  381.     call rpack        ; Get a packet.
  382.      jmp nak0        ;  Trashed packet: nak, retry.
  383.     cmp ah,'D'              ; Is it a data packet?
  384.     je rdat11
  385.     call dodec        ; Decode data.
  386.     jmp rdata2        ;  No, try next type.
  387. rdat11: mov ax,pack.pktnum    ; Get the present packet number.
  388.     cmp ax,pack.argblk    ; Is the packet's number correct?
  389.     jz rdat14
  390.     cmp pack.oldtry,maxtry    ; Have we reached the maximum number of tries?
  391.     jl rdat12        ; If not proceed.
  392.     call erpos        ; Position cursor.
  393.     mov dx,offset erms10
  394.     mov ah,prstr
  395.     int dos         ; Print an error message.
  396.     mov bx,dx
  397.     call errpack        ; Send error packet just in case.
  398.     jmp abort        ; Change the state to abort.
  399. rdat12: inc pack.oldtry     ; Save the updated number of tries.
  400.     mov ax,pack.pktnum
  401.     cmp ax,0        ; Had we wrapped around? [18 start]
  402.     jne rdatx
  403.     mov ax,64
  404. rdatx:    dec ax            ; [14] [18 end -- new label]
  405.     cmp ax,pack.argblk    ; Is the packet's number one less than now?
  406.     je rdat13
  407.     jmp nak0        ; No, NAK it and try again.
  408. rdat13: call updrtr        ; Update retry count.
  409.     mov pack.numtry,0    ; Reset number of tries.
  410.     mov pack.argbk1,0    ; No data.  (The packet number is in argblk.)
  411.     mov cx,0
  412.     call doenc
  413.     mov ah,'Y'              ; Acknowledge packet.
  414.     call spack        ; Send the packet.
  415.      jmp abort
  416.     ret
  417. rdat14: inc ax            ; Increment the packet number.
  418.     and ax,3FH        ; Turn off the two high order bits.
  419.     mov pack.pktnum,ax    ; Save modulo 64 of the number.
  420.     inc pack.numpkt     ; Increment the number of packets.
  421.     mov ah,pack.numtry    ; Get the number of tries.
  422.     mov pack.oldtry,ah    ; Save it.
  423.     mov ax,pack.argbk1    ; Get the length of the data.
  424.     cmp flags.cxzflg,0    ; Has the user typed a ^X or ^Z? [20c]
  425.     je rdt14x        ; No, write out the data.
  426.     cmp flags.abfflg,1    ; Discard incomplete files?
  427.     je rdat15        ; If yes don't write data out to file. [20c]
  428. rdt14x: mov bx,offset data    ; Where the data is. [25]
  429.     call ptchr
  430.      jmp abort        ;  Unable to write out chars; abort.
  431. rdat15: mov pack.numtry,0    ; Reset the number of tries.
  432.     mov pack.argbk1,0    ; No data.  (Packet number still in argblk.)
  433.     mov cx,0
  434.     cmp flags.cxzflg,0    ; Interrupt file transfer? [20c]
  435.     je rdat16        ; Nope. [20c]
  436.     mov bx,offset data    ; Send data in ACK in case remote... [20c]
  437.     mov ah,flags.cxzflg    ; ... knows about ^X/^Z. [20c]
  438.     mov [bx],ah        ; Put data into the packet. [20c]
  439.     mov pack.argbk1,1    ; Set data size to 1. [20c]
  440.     mov cx,1
  441. rdat16: call doenc
  442.     mov ah,'Y'              ; Acknowledge packet.
  443.     call spack        ; Send the packet.
  444.      jmp abort
  445.     ret
  446. rdata2: cmp ah,'F'              ; Start of file?
  447.     je rdat20        ; Yup. [21c]
  448.     cmp ah,'X'              ; Text header packet? [21c]
  449.     jne rdata3        ;  No, try next type.
  450. rdat20: cmp pack.oldtry,maxtry    ; Reached the max number of tries? [21c]
  451.     jl rdat21        ; If not proceed.
  452.     call erpos        ; Position cursor.
  453.     mov dx,offset ermes8
  454.     mov ah,prstr
  455.     int dos         ; Print an error message.
  456.     mov bx,dx
  457.     call errpack        ; Send error packet just in case.
  458.     jmp abort        ; Change the state to abort.
  459. rdat21: inc pack.oldtry     ; Save the updated number of tries.
  460.     mov ax,pack.pktnum
  461.     cmp ax,0        ; Had we wrapped around? [18 start]
  462.     jne rdaty
  463.     mov ax,64
  464. rdaty:    dec ax            ; [14 Omitted accidentally - D.T.] [18 end]
  465.     cmp ax,pack.argblk    ; Is the packet's number one less than now?
  466.     je rdat22
  467.     jmp nak0        ; No, NAK it and try again.
  468. rdat22: call updrtr        ; Update retry count.
  469.     mov pack.numtry,0    ; Reset number of tries.
  470.     mov pack.argbk1,0    ; No data.  (The packet number is in argblk.)
  471.     mov cx,0
  472.     call doenc
  473.     mov ah,'Y'              ; Acknowledge packet.
  474.     call spack        ; Send the packet.
  475.      jmp abort
  476.     ret
  477. rdata3: cmp ah,'Z'              ; Is it a EOF packet?
  478.     je rdat3x        ; [13]
  479.     jmp rdata4        ; Try and see if its an error. [13]
  480. rdat3x: mov ax,pack.pktnum    ; Get the present packet number. [13]
  481.     cmp ax,pack.argblk    ; Is the packet's number correct?
  482.     je rdat32
  483.     jmp nak0        ; No, NAK it and try again.
  484. rdat32: inc ax            ; Increment the packet number.
  485.     and ax,3FH        ; Turn off the two high order bits.
  486.     mov pack.pktnum,ax    ; Save modulo 64 of the number.
  487.     inc pack.numpkt
  488.     cmp flags.cxzflg,0    ; Do we want to discard the file? [20c]
  489.     jne rdt32x        ; Yes. [20c]
  490.     cmp pack.argbk1,1    ; One piece of data? [20c]
  491.     jne rdat33        ; Nope - finish writing out file? [20c]
  492.     mov bx,offset data    ; Get data area. [20c]
  493.     mov ah,[bx]        ; Get the data. [20c]
  494.     cmp ah,'D'              ; "D" for discard? [20c]
  495.     jne rdat33        ; Nope - write out file. [20c]
  496. rdt32x: cmp flags.abfflg,0    ; Keep incomplete files?
  497.     je rdat33        ; Yes, go write it out.
  498.     mov ah,closf        ; First, close the file.
  499.     mov dx,offset fcb    ; Give the file parameters. [20c]
  500.     int dos         ; Kill it, ignore errors. [20c]
  501.     mov ah,delf        ; Delete the file if opened. [20c]
  502.     int dos
  503.     cmp flags.cxzflg,'X'    ; Kill one file or all? [20c]
  504.     jne rdat36        ; No so leave flag alone. [20c]
  505.     call cxmsg        ; Clear msg about interrupt. [20c]
  506.     mov flags.cxzflg,0    ; Reset - ^X only kills one file. [20c]
  507.     jmp rdat36
  508. rdat33: mov bx,bufpnt        ; Get the dma pointer.
  509.     mov ax,80H
  510.     sub ax,chrcnt        ; Get the number of chars left in the DMA.
  511.     cmp flags.eofcz,0    ; should we write a ^Z?
  512.     jz rdat35        ; no, keep going
  513.     cmp flags.xflg,0    ; writing to a file?
  514.     jne rdat35        ; no, skip ^Z
  515.     cmp ax,80H        ;   [13 start]
  516.     jne rdat34
  517.     call outbuf        ; Write out buffer if no room for ^Z.
  518.      jmp abort
  519.     mov ax,0        ;   [13 end]
  520.     inc chrcnt        ; Increment size by one (not two). [21b]
  521. rdat34: mov cl,'Z'-100O         ; Put in a ^Z for EOF.
  522.     mov [bx],cl        ; Add it. [21c]
  523.     inc ax
  524.     dec chrcnt
  525. rdat35: mov cx,chrcnt
  526.     mov temp,cx
  527.     call outbuf        ; Output the last buffer.
  528.      jmp abort        ; Give up if the disk is full.
  529.     mov ax,temp        ; Prepare for the function call.
  530.     call fixfcb
  531.     mov ah,closf        ; Close up the file.
  532.     mov dx,offset fcb
  533.     int dos
  534. rdat36: cmp flags.destflg,1    ; Writing to disk?
  535.     je rdat37        ; Yes, skip next part.
  536.     cmp flags.xflg,1    ; Writing to screen?
  537.     je rdat37        ; Yes, skip this part.
  538.     mov dl,ff        ; Send a form feed.
  539.     mov ah,lstout        ; Write out to first printer.
  540.     int dos
  541. rdat37: mov ah,pack.numtry    ; Get the number of tries.
  542.     mov pack.oldtry,ah    ; Save it.
  543.     mov pack.numtry,0    ; Reset the number of tries.
  544.     mov pack.argbk1,0    ; No data.  (The packet number is in argblk.)
  545.     mov cx,0
  546.     call doenc
  547.     mov ah,'Y'              ; Acknowledge packet.
  548.     call spack        ; Send the packet.
  549.      jmp abort
  550.     mov pack.state,'F'
  551.     ret
  552. rdata4: cmp ah,'E'                      ; Is it an error packet.
  553.     jne rdata5
  554.     call error
  555. rdata5: jmp abort
  556. RDATA    ENDP
  557.  
  558.  
  559. ; Jumping to this location is like retskp.  It assumes the instruction
  560. ;   after the call is a jmp addr.
  561.  
  562. RSKP    PROC    NEAR
  563.     pop bp
  564.     add bp,3
  565.     push bp
  566.     ret
  567. RSKP    ENDP
  568.  
  569. R    PROC    NEAR
  570.     ret
  571. R    ENDP
  572.  
  573. code    ends
  574.     end
  575.