home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / cpm / basic / cpmio.mqc / CPMIO.MAC
Encoding:
Text File  |  1985-02-10  |  3.4 KB  |  170 lines

  1. ; BASCOM CPMIO replacement by S. Kluger
  2. ; version 1.11 as of 02/07/84
  3. ;
  4. ; PURPOSE:
  5. ; to enhance the operation of BASCOM compiled programs which
  6. ; must by the nature of their environment be non-abortable.
  7. ; A program compiled with BASCOM can normally be aborted by
  8. ; halting a text display with ^S, and then typing ^C. Since
  9. ; console output is handled by the BDOS, the BDOS ^C trap
  10. ; will branch to warm boot, and that could be a disaster if
  11. ; the program runs in a secure environment with the user
  12. ; normally unable to enter CP/M, or where CP/M entry depends
  13. ; on various controlled conditions. One example is Dick Lieber's
  14. ; SIGNON program for RCPM systems, or for that matter, any
  15. ; logon-type program used on RCPM systems.
  16. ;
  17. ; This CPMIO replacement retains the ^S handling of the
  18. ; original, while totally ignoring ^C. Note that the $LSTOT
  19. ; implementation has not been changed.
  20. ;
  21. ; PLUGGING IT IN:
  22. ; First, use M80 to assemble this file to make CPMIO.REL.
  23. ; Now, if you have Digital Research's LIB.COM, do the following:
  24. ; A>REN OLIB.REL=BASLIB.REL
  25. ; A>LIB BASLIB=OLIB<CPMIO>
  26. ; that's all. How to do it with Microsoft's library manager is
  27. ; anyone's guess - I prefer the simplicity of DRI products.
  28. ; And a warning... this has not been tested on BASCOM 5.3 with BRUN!
  29. ; I suspect there the CP/M character IO routines are contained in
  30. ; BRUN rather than BASLIB, in which case conversion would not
  31. ; be trivial at all.
  32. ;
  33.     extrn    $$optr,$$pout,$$sfwa,$$slwa,$$tout,$ini0
  34.     extrn    $memry,cpment,cpmwrm
  35. ;
  36.     public    $init,$ioini,$lptot,$osext,$ttyin,$ttyot,$ttyst
  37.     public    cpmvrn,cpmrea,cpmwri
  38. ;
  39. a0197:    nop
  40.     nop
  41.     nop
  42. a019a:    nop
  43.     nop
  44.     nop
  45. cot:    nop
  46.     nop
  47.     nop
  48. cpmvrn:    mov    a,m
  49. cpmrea:    nop
  50. cpmwri:    nop
  51. ;
  52. $init:    mov    b,h
  53.     mov    c,l
  54.     lhld    cpment+1
  55.     sphl
  56.     push    b
  57.     lxi    d,0ff00h
  58.     dad    d
  59.     shld    $$slwa
  60.     lhld    $memry
  61.     inx    h
  62.     inx    h
  63.     shld    $$sfwa
  64.     jmp    $ini0
  65. ;
  66. ; IO initialization. set up jumps to BIOS
  67. ; sneaky BASCOM makes sure we call the destinations
  68. ; of the BIOS jump table, rather than the jump
  69. ; table itself!
  70. ;
  71. $ioini:    mvi    a,0c3h
  72.     sta    a0197
  73.     sta    a019a
  74.     sta    cot        ;added conout
  75.     lhld    cpmwrm+1
  76.     lxi    d,4
  77.     dad    d
  78.     mov    e,m
  79.     inx    h
  80.     mov    d,m
  81.     xchg
  82.     shld    a0197+1
  83.     xchg
  84.     inx    h
  85.     inx    h
  86.     mov    e,m
  87.     inx    h
  88.     mov    d,m
  89.     xchg
  90.     shld    a019a+1
  91.     xchg
  92.     inx    h
  93.     inx    h
  94.     mov    e,m
  95.     inx    h
  96.     mov    d,m
  97.     xchg
  98.     shld    cot+1        ;set up our new conout
  99.     mvi    c,0ch
  100.     call    cpment
  101.     sta    cpmvrn
  102.     ora    a
  103.     lxi    h,1514h
  104.     jz    a014b
  105.     lxi    h,2221h
  106. a014b:    shld    cpmrea
  107.     lxi    h,$$tout
  108.     shld    $$optr
  109.     mvi    m,1
  110.     inx    h
  111.     mvi    m,50h
  112.     mvi    a,84h
  113.     sta    $$pout+1
  114.     mvi    a,1
  115.     sta    $$pout
  116.     mvi    a,0ffh
  117.     sta    $$pout-1
  118.     ret
  119. ;
  120. $ttyst:    push    b
  121.     push    d
  122.     push    h
  123.     call    a0197
  124.     ora    a
  125.     jmp    a0190
  126. ;
  127. $ttyin:    push    b
  128.     push    d
  129.     push    h
  130.     call    a019a
  131.     jmp    a0190
  132. ;
  133. ; The $ttyout routine used to go through the BDOS,
  134. ; which gives RCPM operators headaches. We use BIOS
  135. ; output here, but still implement the ^S check
  136. ; (but without warmboot at ^S^C)
  137. ;
  138. $ttyot:    push    b
  139.     push    d
  140.     push    h
  141.     mov    c,a
  142.     call    cot
  143.     push    psw        ;save byte
  144.     call    $ttyst
  145.     jz    none
  146.     call    $ttyin        ;get the waiting char
  147.     cpi    'S'-40h        ;is it ^S?
  148.     jnz    none        ;nope - ignore it
  149.     call    $ttyin        ;wait for a response
  150. none:    pop    psw
  151.     jmp    a0190
  152. ;
  153. $lptot:    push    b
  154.     lxi    b,0ff05h
  155. a0187:    push    d
  156.     push    h
  157.     push    psw
  158.     ana    b
  159.     mov    e,a
  160.     call    cpment
  161.     pop    psw
  162. a0190:    pop    h
  163.     pop    d
  164.     pop    b
  165.     ret
  166. ;
  167. $osext:    jmp    cpmwrm
  168. ;
  169.     end
  170.