home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / cpm / utils / asmutl / asmlib.lbr / SBC800IO.AZM / SBC800IO.ASM
Encoding:
Assembly Source File  |  1991-06-25  |  4.5 KB  |  172 lines

  1. ;----------------------------------------------------------------
  2. ;         This is a module in the ASMLIB library.
  3. ;
  4. ;                 SBC-800 I/O Drivers
  5. ;
  6. ; This is the I/O driver module of ASMLIB and has ALL the I/O routines
  7. ; for the system (EXCEPT from line input). Note that the routines do no 
  8. ; initialization which is assumed to have been done already.
  9. ;
  10. ; COE    Send accumulator to console.
  11. ; CIE   Get console into accumulator. No echo.
  12. ; CST   Get console status, 00 = no character there.
  13. ; LOE   Send accumulator to list device.
  14. ; LST   Get list device output status.
  15. ; IONUM    Get the identification number of this i/o driver
  16. ;
  17. ;            Written         R.C.H.     22/10/83
  18. ;            Last Update    R.C.H.       14/12/83
  19. ;
  20. ;----------------------------------------------------------------
  21.     name    'SBC800IO'
  22. ;
  23.     public    coe,cie,cst,loe,lst,ionum
  24. ;
  25.     maclib    z80
  26. ;
  27. num    equ    02            ; 01 = cpmio, 02 = sbc800io
  28. ;
  29. ; In an SBC-800 the Serial I/O is done via a Dart. This module does
  30. ; all the I/O through this of course. This driver also has X-on / Xoff
  31. ; handshaking if equate is set. If serial = true then the LOE type
  32. ; of ASMLIB functions go through the second serial port and if false
  33. ; then they go via the parallel port (8255) of SBC-800.
  34. ;
  35. true    equ    0ffffh
  36. false    equ    not true
  37. xon    equ    true        ; enables X-on Xoff on console
  38. serial    equ    true        ; enables serial printer driver
  39. data0    equ    088h
  40. stat0    equ    data0 + 1
  41. data1    equ    data0 + 2
  42. stat1    equ    data0 + 3
  43. ;
  44. rxrdy    equ    01        ; receiver got a character bit
  45. txrdy    equ    04        ; transmitter empty bit
  46. ;
  47. ; The following are the parallel printer port equates.
  48. ;
  49. pp0a    equ    084h        ; Busy / status port
  50. pp0b    equ    pp0a + 1    ; data port
  51. pp0c    equ    pp0a + 2    ; Ack line on this port
  52. pp0d    equ    pp0a + 3    ; strobe line here
  53. ;
  54. ;
  55. ionum:
  56.     mvi    l,num
  57.     ret
  58. ;
  59. ;----------------------------------------------------------------
  60. ;     Print the character in the accumulator to the screen       *
  61. ;----------------------------------------------------------------
  62. ;
  63. coe:
  64.     push    psw
  65.     push    psw            ; Preserve the character
  66. coe1:
  67.     in    stat0            ; is there transmitter empty
  68.     ani    txrdy
  69.     jrz    coe1            ; wait for it
  70.     pop    psw            ; get the byte
  71.     out    data0            ; send it
  72. ;
  73. ; Here we may need X-on / X-off if the equate is set.
  74. ;
  75.     if    xon
  76.     call    cst            ; character come back ??
  77.     jrz    coefin            ; exit if not then
  78. ; Else get the character
  79.     call    cie            ; get it
  80.     cpi    019            ; is it X-off ?
  81.     jrnz    coefin
  82. coe2:    ; Wait for an X-on
  83.     call    cie
  84.     cpi    017            ; X-on ?
  85.     jrnz    coe2
  86.     endif
  87. coefin:
  88.     pop    psw            ; Restore the character
  89.     ret
  90. ;
  91. ;----------------------------------------------------------------
  92. ;     Send the accumulator character to the list device
  93. ;----------------------------------------------------------------
  94. ;
  95. loe:
  96.     push    psw
  97. loe1:                ; loop point till Xmitter empty
  98.     call    lst
  99.     jrz    loe1            ; Wait till transmitter empty
  100.     pop    psw            ; restore data
  101. ;
  102.     if    serial            ; It is a serial output device
  103.     out    data1            ; send to dart now
  104. ;
  105.     else                ; It is a parallel printer
  106.     out    pp0b            ; send to data port
  107.     push    psw
  108. ppout1:
  109.     mvi    a,0fh
  110.     out    pp0d            ; Set strobe low
  111.     dcr    a            ; Turn lsb off
  112.     out    pp0d            ; Send strobe low
  113. ppout2:
  114.     in    pp0c            ; Test Ack Line
  115.     ani    1
  116.     jrz    ppout2            ; Wait till asserted
  117.     pop    psw            ; Restore character through all
  118.     endif
  119. ;
  120.     ret
  121. ;
  122. ;----------------------------------------------------------------
  123. ;           Get a character from the console
  124. ;----------------------------------------------------------------
  125. ;
  126. cie:
  127.     call    cst            ; get status till <> 0
  128.     jrz    cie            ; the character is in A
  129.     in     data0            ; send to serial channel 0
  130.     ani    07fh            ; mask off parity
  131.     ret
  132. ;
  133. ;----------------------------------------------------------------
  134. ; Get the console status. 00 = no character all else = read.
  135. ;----------------------------------------------------------------
  136. ;
  137. cst:    ; Use dos function 11
  138.     in    stat0
  139.     ani    rxrdy            ; is there a character there
  140.     rz                ; retunr if no character
  141.     mvi    a,0ffh
  142.     ret
  143. ;
  144. ;----------------------------------------------------------------
  145. ; Get the list output status. If = 00 then no character may be
  146. ; sent to the device.
  147. ;----------------------------------------------------------------
  148. ;
  149. lst:
  150.     if    serial            ; Read the darts status
  151.     in    stat1
  152.     ani    txrdy            ; transmitter ready mask
  153.     rz
  154.     mvi    a,0ffh            ; character is there if here
  155.     ret                ; return the device as ready
  156. ;
  157.     else                ; Else it is the centronic printer
  158.     in    pp0a            ; Test Busy bit
  159.     ani    080h
  160.     cma                ; Complement
  161.     ora    a
  162.     rz
  163.     mvi    a,0ffh            ; Return with a not busy byte
  164.     ret
  165.     endif
  166. ;
  167.     end
  168.  
  169.  
  170.  
  171.  
  172.