home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / osborne / osbplink.asm < prev    next >
Assembly Source File  |  1994-07-13  |  16KB  |  817 lines

  1. ;                    PLINK.ASM  ver 6.4
  2. ;              (revised 6/14/81)
  3. ;
  4. ;PLINK is a CP/M transient command which allows the user to
  5. ;PLINK currently supports two way transfer of text files between
  6. ;the CP/M disk and the remote computer. The following control
  7. ;codes may be initiated from the console keyboard:
  8. ;
  9. ;Control-E      Exit PLINK to CP/M "warm-boot".
  10. ;
  11. ;Control-T      Transmit ASCII file to remote system, asks for
  12. ;               drive (A, B, etc.) and filename.typ.
  13. ;
  14. ;Control-C      Aborts transmission of file to remote system.
  15. ;
  16. ;Control-Y      Switches between saving and ignoring
  17. ;        incoming ASCII data in RAM buffer,
  18. ;        for later transfer to disk.
  19. ;
  20. ;Control-W      Writes RAM buffer to disk, and asks for drive
  21. ;               and filename.typ.
  22. ;
  23. ;Del (delete)   Backspace when in command mode (e.g. ^T or ^W).
  24. ;
  25. ;Control-U      Aborts current line when in command mode.
  26. ;
  27. ;(Note: all other control codes are passed to modem output, and
  28. ;may be interpreted by the remote system as various control
  29. ;functions.)
  30. ;
  31. ;
  32. ;bdos entry point and function codes
  33. ;
  34. base    equ    0    ;<<-- set to offset of CP/M for your
  35.             ;system, standard systems are 0, some
  36.             ;'alternate' systems are 4200H
  37. ;
  38. bdos    equ    base+5
  39. resdsk    equ    13    ;reset disk system
  40. offc    equ    15    ;open file
  41. cffc    equ    16    ;close file
  42. dffc    equ    19    ;delete file
  43. rrfc    equ    20    ;read record
  44. wrfc    equ    21    ;write record
  45. mffc    equ    22    ;make file
  46. ;
  47. ;TRS80 pickles and trout sio calls
  48. ;offset by -3 that is add 3 to all calls
  49. ;
  50. setsio    equ    30h    ;set up z80 sio
  51. siotst    equ    33h    ;read sio status
  52. sioinp    equ    36h    ;input a char
  53. sioout    equ    39h    ;output a char
  54. ;
  55. ;
  56. ;default fcb and field definitions
  57. ;
  58. fcb    equ    base+5ch
  59. fn    equ    1    ;file name field (rel)
  60. ft    equ    9    ;file type field (rel)
  61. ex    equ    12    ;file extent field (rel)
  62. nr    equ    32    ;next record field (rel)
  63. dbuf    equ    base+80h ;default disk buffer address
  64. ;
  65. ;ascii control characters
  66. ;
  67. cr    equ    0dh    ;carriage return
  68. lf    equ    0ah    ;line feed
  69. del    equ    7fh    ;delete (rubout)
  70. bell    equ    07h    ;bell signal
  71. tab    equ    09h    ;horizontal tab
  72. xon    equ    11h    ;x-on character
  73. null    equ    00h    ;null char
  74. ;
  75. ;the following "trigger" equate is set to "lf" (linefeed)
  76. ;by default. an optional trigger char may be passed via fcb1
  77. ;
  78. ; ie:  PLINK B        will set trigger to "bell"
  79. ;
  80. ;the following options are allowed
  81. ;
  82. ;    1. B = bell  07h
  83. ;    2. X = xon   11h
  84. ;    3. U = upload no trigger check at all
  85. ;
  86. ;any other ascii character may be passed through fcb1
  87. ;
  88. ;
  89. trigger    equ    LF    ;default value
  90. ;
  91. ;
  92. ;warning character for low memory
  93. ;
  94. wrnsig    equ    BELL    ;if you have one, put 'BELL' here
  95.             ;...else put '*' here.
  96. ;
  97. ;
  98. ;    **main program**
  99. ;
  100.     org    base+100h
  101. ;
  102.     jmp    4000h
  103.     org    base+4000h
  104. lnki:    lxi    sp,stack+64 ;create local stack
  105.     lhld    base+1    ;point to CP/M jmp table
  106.     lxi    d,3    ;get ready to add 3
  107.     dad    d    ;point to con status jmp
  108.     shld    citcal+1 ;modify call adrs
  109.     dad    d    ;point to con in jmp
  110.     shld    rccal+1    ;modify call adrs
  111.     dad    d    ;point to con out jmp
  112.     shld    wccal+1    ;modify call adrs
  113.     lda    fcb+1    ;see if optional trigger char
  114.     cpi    20h    ;blank.. ?
  115.     jz    skp    ;..blank so use default "lf"
  116.     cpi    'B'    ;bell wanted
  117.     jz    trgbel
  118.     cpi    'X'    ;xon wanted
  119.     jz    trgxon
  120.     cpi    'U'    ;uploading no checking for trigger
  121.     jz    trgupl
  122. ;
  123. settrg    sta    overly+1 ;store the character as is then
  124.     jmp    skp
  125. ;
  126. trgbel    mvi    a,bell
  127.     jmp    settrg
  128. ;
  129. trgxon    mvi    a,xon
  130.     jmp    settrg
  131. ;
  132. trgupl    xra    a     ;zero out jump
  133.     sta    overl1+1 ;change check for c/r to null
  134.     sta    overl2+1 ;and send linefeeds as well
  135.     jmp    skp
  136. ;
  137. skp:    equ    $
  138. ;
  139. ;
  140. cont:
  141.     xra    a    ;clear char buffers
  142.     sta    inch
  143.     sta    outch
  144.     sta    flag    ;clear text save flag
  145.     lxi    h,tbuf    ;set ptr to tbuf
  146.     shld    ptr
  147.     lxi    h,0    ;size = 0
  148.     shld    size
  149.     lxi    h,lnkims  ;print sign-on message
  150.     call    wcs
  151. ;
  152. ;main loop
  153. ;
  154. lnki3:    call    citest    ;jump if no data from console
  155.     jz    lnki4
  156.     call    rcc    ;else read console data
  157.     cpi    20h
  158.     cc    pcc    ;call pcc if control char
  159.     jc    lnki4    ;jump if pcc handled char
  160.     ori    80h    ;else set valid data bit
  161.     sta    inch    ;and store in input char buffer
  162. ;
  163. lnki4:    lda    outch    ;jump if no data for console
  164.     ora    a
  165.     jp    lnki5
  166.     ani    7fh    ;else discard valid data bit
  167.     call    wcc    ;send char to console
  168.     xra    a    ;then clear output char buffer
  169.     sta    outch
  170. ;
  171. lnki5:    call    mitest    ;jump if no data from modem
  172.     jz    lnki6
  173.     call    rmc2    ;else read modem data
  174.     call    save    ;save char in text buffer if flag on
  175.     ori    80h    ;set data valid bit
  176.     sta    outch    ;store in output char buffer
  177. ;
  178. lnki6:    call    motest    ;jump if modem xmit buffer busy
  179.     jnz    lnki7
  180.     lda    inch    ;jump if no data for modem
  181.     ora    a
  182.     jp    lnki7
  183.     ani    7fh    ;discard valid data bit
  184.     call    wmc
  185. ;
  186.     xra    a    ;...then clear input char buffer
  187.     sta    inch
  188. ;
  189. lnki7:    jmp    lnki3    ;end of main loop
  190. ;
  191. lnkims:    db    cr,lf,'PLINK ver 6.4'
  192.     db    cr,lf,cr,lf
  193.     db    '[^T]ransmit, [^Y]ank, [^W]rite, [^E]xit, [^C]ancel'
  194.     db    cr,lf,'Ready',cr,lf,lf,0
  195. ;
  196. ;pcc - process control character
  197. ;
  198. pcc:    cpi    'E'-40h    ;jump out if ctrl e
  199.     jnz    pcc1
  200.     push    h
  201.     lxi    h,ays    ;print 'are you sure'
  202.     call    wcs
  203.     pop    h
  204.     call    rcc    ;get answer
  205.     call    wcc    ;echo it
  206.     ani    5fh    ;make upper case
  207.     cpi    'Y'    ;yes?
  208.     jz    pccex    ;exit
  209.     call    wccr    ;crlf
  210.     stc        ;tell plink to ignore this character
  211. ;
  212. ;
  213. pcc1:    cpi    'T'-40h    ;jump if not control-t
  214.     jnz    pcc2
  215.     call    stf    ;transmit text file to modem
  216.     stc        ;tell plink to ignore this character
  217.     ret
  218. ;
  219. pcc2:    cpi    'Y'-40h    ;jump if not control-y
  220.     jnz    pcc3
  221.     lda    flag
  222.     dcr    a    ;was it zero?
  223.     jnz    pcc2a    ;yes
  224.     sta    flag    ;no, was 1, now 0
  225.     lxi    h,pcmnix ;print ignore incoming stuff
  226.     jmp    pcc2b
  227. ;
  228. pcc2a:    mvi    a,1    ;turn on text save flag
  229.     sta    flag
  230.     lxi    h,pccmr    ;print 'saving incoming text in memory'
  231. ;
  232. pcc2b:    call    wcs
  233.     stc        ;tell plink to ignore this character
  234.     ret
  235. ;
  236. pcc3:    cpi    'W'-40h    ;jump if not control-W
  237.     jnz    pcc4
  238.     xra    a    ;turn off text save flag
  239.     sta    flag
  240.     call    wtb    ;write text buffer to disk
  241.     stc
  242.     ret
  243. ;
  244. pcc4:    stc        ;let plink handle all other cont. codes
  245.     cmc
  246.     ret
  247. ;
  248. pccex:    lxi    h,disms    ;print 'modem not disconnected'
  249.     call    wcs
  250.     jmp    base    ;exit to warm boot
  251. ;
  252. ays:    db    cr,lf,'Exit to CP/M - are you sure (Y or N)? ',0
  253. ;
  254. disms:    db    cr,lf,'+++ Exit to CP/M +++',cr,lf,0
  255. ;
  256. pccmr:    db    cr,lf,'Saving incoming text in memory',cr,lf,0
  257. pcmnix:    db    cr,lf,'Ignoring incoming text',cr,lf,0
  258. ;
  259. ;stf - send text file (to modem)
  260. ;
  261. stf:    call    gfn    ;get name of disk file to send
  262.     jc    stf6    ;jump if file name error
  263.     call    open    ;try to open specified file
  264.     cpi    255    ;jump if file not found
  265.     jz    stf7
  266. ;
  267. stf1:    call    read    ;read next record into dbuf
  268.     cpi    1    ;jump if end-of-file
  269.     jz    stf5
  270.     lxi    h,dbuf     ;point to disk buffer
  271.     mvi    c,128
  272. ;
  273. stf2:    mov    a,m    ;fetch next char from dbuf
  274.     inx    h
  275.     cpi    'Z'-40h    ;jump if end-of-file character
  276.     jz    stf5
  277. ;
  278. overl2    cpi    lf    ;ignore line feeds
  279.     jz    stf4
  280.     call    wmc    ;write character to modem
  281.     call    wcc    ;write character to console
  282. ;
  283. overl1    cpi    cr    ;jump if not carriage return
  284.     jnz    stf4
  285. ;
  286. stf3:    call    citest    ;check console data ready
  287.     jz    stf3a    ;no data there
  288.     call    rcc    ;get console character
  289.     cpi    'C'-40h    ;control c aborts it
  290.     jz    stf8
  291. ;
  292. stf3a:    call    mitest    ;wait for next modem character
  293.     jz    stf3
  294.     call    rmc2    ;check modem for trigger char.
  295. ;
  296. overly    cpi    trigger
  297.     jnz    stf3
  298.     call    wccr    ;send crlf to console
  299. ;
  300. stf4:    dcr    c    ;loop thru rest of dbuf
  301.     jnz    stf2
  302.     jmp    stf1    ;go get next record from disk
  303. ;
  304. stf5:    lxi    h,stfsm    ;print 'file send complete'
  305.     call    wcs
  306.     ret
  307. ;
  308. stf6:    lxi    h,stfs1    ;print 'file name error'
  309.     call    wcs
  310.     ret
  311. ;
  312. stf7:    lxi    h,stfs2    ;print 'file not found'
  313.     call    wcs
  314.     ret
  315. ;
  316. stf8:    lxi    h,stfsa    ;print 'file send aborted'
  317.     call    wcs
  318.     ret
  319. ;
  320. stfsm:    db    'File send complete',cr,lf,0
  321. stfs1:    db    'File name error or abort',cr,lf,0
  322. stfs2:    db    'File not found',cr,lf,0
  323. stfsa:    db    cr,lf,'File send aborted',cr,lf,0
  324. ;
  325. ;save - save char in text buffer if flag on
  326. ;
  327. ;  entry conditions
  328. ;     a - character to save
  329. ;
  330. save:    push    psw
  331.     lda    flag
  332.     ora    a
  333.     jnz    save1
  334.     pop    psw
  335.     ret
  336. ;
  337. save1:    pop    psw
  338.     cpi    del    ;rubout (del) ?
  339.     rz        ;yes, ignore it
  340.     cpi    20h    ;test for control characters
  341.     jnc    save2    ;jump if not control char.
  342.     cpi    cr    ;allow cr to be saved
  343.     jz    save2
  344.     cpi    lf    ;allow lf to be saved
  345.     jz    save2
  346.     cpi    tab    ;allow tab to be saved
  347.     jz    save2
  348.     ret        ;ignore all other control chars.
  349. ;
  350. save2:    push    h
  351.     lhld    size    ;size = size + 1
  352.     inx    h
  353.     shld    size
  354.     lhld    ptr
  355.     mov    m,a
  356.     inx    h
  357.     shld    ptr
  358.     push    psw
  359.     lda    base+7    ;get system size
  360.     sui    1    ;so we dont crash CP/M
  361.     cmp    h    ;are we out of room?
  362.     jz    saveab    ;yes, abort
  363.     sui    4    ;leave some room (1k)
  364.     cmp    h
  365.     mvi    a,wrnsig  ;signal console running out of space
  366.     cc    wcc
  367.     pop    psw
  368.     pop    h
  369.     ret
  370. ;
  371. ;saveab - ran out of room, issue message and flow
  372. ;      through to disk save routine
  373. ;
  374. savend:    db    bell,cr,lf,'Aborting - no room left',0
  375. ;
  376. saveab:    lxi    sp,stack+64  ;reinitialize stack
  377.     lxi    h,savend  ;print 'aborting - no room left'
  378.     call    wcs
  379.     lxi    h,lnki    ;set up return address
  380.     push    h    ;leave it on the stack
  381. ;
  382. ;wtb - write text buffer to disk
  383. ;
  384. wtb:    lhld    size    ;jump if text buffer empty
  385.     mov    a,l
  386.     ora    h
  387.     jz    wtb5
  388.     mvi    c,resdsk ;reset in case read-only
  389.     call    bdos
  390.     call    gfn    ;get file name
  391.     jc    wtb6    ;jump if file name error
  392.     call    delt    ;delete old file, if any
  393.     call    make    ;make new file
  394.     lhld    size    ;de = tbuf size
  395.     xchg
  396.     lxi    h,dbuf    ;top of stack points to dbuf
  397.     push    h
  398.     lxi    h,tbuf    ;hl points to tbuf
  399. ;
  400. wtb1:    mvi    c,128    ;disk buffer size
  401. ;
  402. wtb2:    mov    a,m    ;fetch next byte of tbuf
  403.     inx    h
  404.     xthl
  405.     mov    m,a    ;store in dbuf
  406.     inx    h
  407.     xthl
  408.     dcx    d    ;size = size - 1
  409.     mov    a,d    ;exit loop if size = 0
  410.     ora    e
  411.     jz    wtb3
  412.     dcr    c    ;loop until dbuf full
  413.     jnz    wtb2
  414.     call    write    ;write full dbuf to disk
  415.     xthl        ;top of stack points to dbuf
  416.     lxi    h,dbuf
  417.     xthl
  418.     jmp    wtb1    ;loop until end of tbuf
  419. ;
  420. wtb3:    pop    h    ;hl points to current place in dbuf
  421. ;
  422. wtb4:    mvi    m,'Z'-40h ;store eof code
  423.     inx    h
  424.     dcr    c    ;loop thru rest of dbuf
  425.     jnz    wtb4
  426.     call    write    ;write last sector to disk
  427.     call    close    ;clean up act and go home
  428.     lxi    h,tbuf    ;clear text buffer
  429.     shld    ptr
  430.     lxi    h,0
  431.     shld    size
  432.     lxi    h,wtbsm    ;print 'buffer saved on disk'
  433.     call    wcs
  434.     ret
  435. ;
  436. wtb5:    lxi    h,wtbs1    ;print 'text buffer empty'
  437.     call    wcs
  438.     ret
  439. ;
  440. wtb6:    lxi    h,wtbs2    ;print 'file name error'
  441.     call    wcs
  442.     ret
  443. ;
  444. wtbsm:    db    cr,lf,'Buffer saved on disk',cr,lf
  445.     db    'Memory save cancelled',cr,lf,0
  446. wtbs1:    db    'Text buffer empty',cr,lf,0
  447. wtbs2:    db    'File name error or abort',cr,lf,0
  448. ;
  449. ;wcs - write console string
  450. ;
  451. ;  entry conditions
  452. ;     hl - points to string (term by zero byte)
  453. ;
  454. wcs:    mov    a,m
  455.     inx    h
  456.     ora    a
  457.     rz
  458.     call    wcc
  459.     jmp    wcs
  460. ;
  461. ;wccr - write console carriage return (and line feed)
  462. ;
  463. wccr:    mvi    a,cr
  464.     call    wcc
  465.     mvi    a,lf
  466. ;
  467. ;wcc - write console character
  468. ;
  469. ;  entry conditions:
  470. ;     a - character to write
  471. ;
  472. wcc:    push    psw
  473.     push    b
  474.     push    d
  475.     push    h
  476.     mov    c,a    ;get character for cbios
  477. wccal:    call    $-$    ;modified by init.
  478.     pop    h
  479.     pop    d
  480.     pop    b
  481.     pop    psw
  482.     ret
  483. ;
  484. ;rcs - read console string (with echo)
  485. ;
  486. ;  exit conditions
  487. ;     b - number of characters read (<255)
  488. ;    hl - points to last char stored (cr)
  489. ;
  490. rcs:    lxi    h,ibuf
  491.     mvi    b,0
  492. ;
  493. rcs1:    call    rcc    ;read next char from console
  494.     cpi    del    ;jump if not del
  495.     jnz    rcs2
  496.     inr    b    ;ignore del if ibuf already empty
  497.     dcr    b
  498.     jz    rcs1
  499.     dcx    h    ;else discard last char
  500.     mov    a,m    ;echo discarded char to console
  501.     call    wcc
  502.     dcr    b    ;decrement count
  503.     jmp    rcs1    ;    and loop
  504. ;
  505. rcs2:    cpi    'U'-40h    ;jump if not control u
  506.     jnz    rcs3
  507.     call    wccr    ;else abort current line
  508.     jmp    rcs    ;    and start over
  509. ;
  510. rcs3:    call    wcc    ;echo char to console
  511.     mov    m,a    ;store char in ibuf
  512.     inr    b    ;increment count
  513.     cpi    cr    ;jump if carriage return
  514.     jz    rcs4
  515.     inx    h    ;else advance pointer
  516.     jmp    rcs1    ;    and loop
  517. ;
  518. rcs4:    mvi    a,lf    ;issue line feed and return
  519.     call    wcc
  520.     ret
  521. ;
  522. ;rcc - read console character
  523. ;
  524. ;  exit conditions
  525. ;     a - character read
  526. ;
  527. rcc:    push    b
  528.     push    d
  529.     push    h
  530. rccal:    call    $-$    ;modified by init.
  531.     pop    h
  532.     pop    d
  533.     pop    b
  534.     ret
  535. ;
  536. ;wmc - write modem character
  537. ;
  538. ;  entry conditions
  539. ;     a - character to write
  540. ;
  541. ;
  542. wmc:
  543.     ani    7fh
  544.     sta    xyz
  545.     di
  546.     out    0
  547.     mvi    a,0
  548.     sta    0ef08h
  549.     lda    xyz
  550.     sta    2a01h
  551.     out    1
  552.     mvi    a,1
  553.     sta    0ef08h
  554.     ei
  555.     ret
  556. ;
  557. ;rmc - read modem character
  558. ;
  559. ;  exit conditions:
  560. ;     a - character read
  561.     di
  562.     out    0
  563.     mvi    a,0
  564.     sta    0ef08h
  565. rmc:
  566.     lda    2a00h
  567.     ani    01h
  568.     cpi    00h
  569.     jz    rmc
  570.     out 1
  571.     mvi    a,1
  572.     sta    0ef08h
  573.     ei
  574. rmc2:    di
  575.     out    0
  576.     mvi    a,0
  577.     sta    0ef08h
  578.     lda    2a01h
  579.     sta    xyz
  580.     out    1
  581.     mvi    a,1
  582.     sta    0ef08h
  583.     ei
  584.     lda    xyz
  585.     ani    7fh
  586.     ret
  587. ;
  588. ;
  589. ;
  590. ;gfn - get file name
  591. ;
  592. gfn:    lxi    h,gfnsd    ;print 'which drive?'
  593.     call    wcs
  594.     call    rcc    ;get answer from console
  595.     call    wcc    ;echo it to console
  596.     ani    5fh    ;make upper case
  597.     cpi    'C'-40h    ;^C means abort
  598.     jz    gfn6
  599.     sui    'A'-1
  600.     jc    gfn    ;require alphabetic
  601.     jz    gfn
  602.     cpi    17    ;allow 16 drives (as in CP/M 2.x)
  603.     jnc    gfn
  604.     sta    fcb
  605. ;
  606. gfnb:    lxi    h,gfns1    ;print 'filename? '
  607.     call    wcs
  608.     call    rcs    ;read response into ibuf
  609.     lxi    h,fcb+fn  ;blank fill fn and ft fields
  610.     mvi    c,11
  611. ;
  612. gfn1:    mvi    m,' '
  613.     inx    h
  614.     dcr    c
  615.     jnz    gfn1
  616.     lxi    h,ibuf    ;point to input buffer
  617.     lxi    d,fcb+fn  ;scan off fn field
  618.     mvi    c,9
  619. ;
  620. gfn2:    mov    a,m    ;fetch next char from ibuf
  621.     inx    h
  622.     cpi    61h    ;if lc, convert to uc
  623.     jc    gfn2a
  624.     sui    20h
  625. ;
  626. gfn2a:    cpi    cr    ;jump if end of line
  627.     jz    gfn5
  628.     cpi    '.'    ;jump if end of name
  629.     jz    gfn3
  630.     stax    d    ;else store char in fn field
  631.     inx    d
  632.     dcr    c    ;loop if 8 or less chars so far
  633.     jnz    gfn2
  634.     jmp    gfn6    ;else take error exit
  635. ;
  636. gfn3:    lxi    d,fcb+ft  ;scan off ft field
  637.     mvi    c,4
  638. ;
  639. gfn4:    mov    a,m    ;fetch next char from ibuf
  640.     inx    h
  641.     cpi    61h    ;if lc, convert to uc
  642.     jc    gfn4a
  643.     sui    20h
  644. ;
  645. gfn4a:    cpi    cr    ;jump if end of line
  646.     jz    gfn5
  647.     stax    d    ;else store char in ft field
  648.     inx    d
  649.     dcr    c    ;loop if 3 or less chars so far
  650.     jnz    gfn4
  651.     jmp    gfn6    ;else take error exit
  652. ;
  653. gfn5:    xra    a
  654.     sta    fcb+ex    ;set extent number to zero
  655.     sta    fcb+nr    ;set record number to zero
  656.     stc        ;clear error flag and return
  657.     cmc
  658.     ret
  659. ;
  660. gfn6:    stc        ;set error flag and return
  661.     ret
  662. ;
  663. gfnsd:    db    cr,lf,'Which drive? ',0
  664. gfns1:    db    cr,lf,'Filename? ',0
  665. ;
  666. ;open - open disk file
  667. ;
  668. open:    push    h
  669.     push    d
  670.     push    b
  671.     lxi    d,fcb
  672.     mvi    c,offc
  673.     call    bdos
  674.     pop    b
  675.     pop    d
  676.     pop    h
  677.     ret
  678. ;
  679. ;read - read record from disk file
  680. ;
  681. read:    push    h
  682.     push    d
  683.     push    b
  684.     lxi    d,fcb
  685.     mvi    c,rrfc
  686.     call    bdos
  687.     pop    b
  688.     pop    d
  689.     pop    h
  690.     ret
  691. ;
  692. ;close - close disk file
  693. ;
  694. close:    push    h
  695.     push    d
  696.     push    b
  697.     lxi    d,fcb
  698.     mvi    c,cffc
  699.     call    bdos
  700.     pop    b
  701.     pop    d
  702.     pop    h
  703.     ret
  704. ;
  705. ;delt - delete disk file
  706. ;
  707. delt:    push    h
  708.     push    d
  709.     push    b
  710.     lxi    d,fcb
  711.     mvi    c,dffc
  712.     call    bdos
  713.     pop    b
  714.     pop    d
  715.     pop    h
  716.     ret
  717. ;
  718. ;write - write record to disk
  719. ;
  720. write:    push    h
  721.     push    d
  722.     push    b
  723.     lxi    d,fcb
  724.     mvi    c,wrfc
  725.     call    bdos
  726.     pop    b
  727.     pop    d
  728.     pop    h
  729.     ret
  730. ;
  731. ;make - make new disk file
  732. ;
  733. make:    push    h
  734.     push    d
  735.     push    b
  736.     lxi    d,fcb
  737.     mvi    c,mffc
  738.     call    bdos
  739.     pop    b
  740.     pop    d
  741.     pop    h
  742.     ret
  743. ;
  744. ;citest - check console input status
  745. ;
  746. citest:    push    b
  747.     push    d
  748.     push    h
  749. citcal:    call    $-$    ;modified by init.
  750.     ora    a    ;set zero flag
  751.     pop    h
  752.     pop    d
  753.     pop    b
  754.     ret        ;zero flag carries answer
  755. ;
  756. ;mitest - check modem input status
  757. mitest:    di
  758.     out    0
  759.     mvi    a,0
  760.     sta    0ef08h
  761.     lda    2a00h
  762.     sta    xyz
  763.     out    1
  764.     mvi    a,1
  765.     sta    0ef08h
  766.     ei
  767.     lda    xyz
  768.     ani    01h
  769.     cpi    00h
  770.     jnz    mitst1
  771.     ora    a
  772.     jmp    mitst2
  773. mitst1    cma
  774.     ora    a
  775. mitst2    ret
  776. ;
  777. ;
  778. ;motest - check modem output status
  779. ;
  780. motest:
  781.     di
  782.     out    0
  783.     mvi    a,0
  784.     sta    0ef08h
  785.     lda    2a00h
  786.     sta    xyz
  787.     out    1
  788.     mvi    a,1
  789.     sta    0ef08h
  790.     ei
  791.     lda    xyz
  792.     xri    02h
  793.     ani    02h
  794.     mvi    a,0
  795.     jz    motst1    ;zero flag carries answer
  796.     cma
  797. ;
  798. motst1:    ora    a    ;set zero flag if ready
  799.     ret
  800. ;
  801. ;data area
  802. ;
  803. xyz:    db    00
  804. inch:    ds    1    ;input char buffer (to cyber)
  805. outch:    ds    1    ;output char buffer (from ciber)
  806. stack:    ds    80    ;local stack
  807. ibuf:    ds    256    ;input buffer
  808. ;
  809. ;text buffer
  810. ;
  811. flag:    ds    1    ;text save flag
  812. ptr:    ds    2    ;text buffer pointer
  813. size:    ds    2    ;text buffer size
  814. tbuf:    equ    $    ;start of text buffer
  815. ;
  816.     end
  817.