home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / CPM / BBSING / MBBS / MB7201-1.ASM < prev    next >
Assembly Source File  |  2000-06-30  |  5KB  |  187 lines

  1. ;*************************************************************************
  2. ;
  3. ;                 MB7201-1.ASM
  4. ;             MBYE (Modular 'BYE')
  5. ;              7201 MPSC UART I/O routines
  6. ;                with 4618  RTC as timer    
  7. ;             ****** for EPSON QX-10 ******
  8. ;                  Version 1.0
  9. ;
  10. ; Renamed and fixed to work with MBYE    02/15/84   Kim Levitt
  11. ; Adapted from BY3-KPSM.ASM             12/15/83   Albert Doolittle    
  12. ; Adapted for use with BYE3-12           12/07/83   Steve Sanders
  13. ; Original Z80-SIO routine             Ver. 1.3   by Steve Fox 
  14. ;
  15. =========================================================================
  16. ;
  17. ;    Set base port for SIO & CTC chips
  18. ;
  19. BASEP:    EQU    11h        ;Base port for SIO
  20. BASEC:    EQU    06h        ;Base port for CTC baud rate generator
  21. ;
  22. ;The following define the port addresses to use.
  23. ;
  24. DPORT:    EQU    BASEP        ;Data port
  25. SPORT:    EQU    BASEP+2        ;Status/Control port
  26. BPORT:    EQU    BASEC        ;Baud rate port
  27. VPORT:    EQU    BASEC+1        ;Vector port
  28. ;
  29. ;The following are SPORT commands (output these to SPORT)
  30. ;
  31. RESCHN:    EQU    00011000b    ;Reset channel
  32. RESSTA:    EQU    00010000b    ;Reset ext/status
  33. WRREG1:    EQU    00000000b    ;Value to write to register 1
  34. WRREG3:    EQU    11000001b    ;8 bits/char, Rx enable
  35. WRREG4:    EQU    01000100b    ;16x, 1 stop bit, no parity
  36. DTROFF:    EQU    00000000b    ;DTR off, RTS off
  37. DTRON:    EQU    11101010b    ;DTR on, 8 bits/char, Tx enable, RTS on
  38. ONINS:    EQU    00110000b    ;Error reset
  39. ;
  40. ;The following are SPORT status masks
  41. ;
  42. DAV:    EQU    00000001b    ;Data available
  43. TBMT:    EQU    00000100b    ;Transmit buffer empty
  44. DCD:    EQU    00001000b    ;Data carrier detect
  45. PE:    EQU    00010000b    ;Parity error
  46. OE:    EQU    00100000b    ;Overrun error
  47. FE:    EQU    01000000b    ;Framing error
  48. ERR:    EQU    PE+OE+FE    ;Parity, overrun and framing error
  49. ;
  50. ;Now comes the time to decide how we set the baud rate.  Set it properly
  51. ;for your particular CTC configuration
  52. ;
  53. BDVECT:    EQU    0B6H        ;QX-10 Vector word
  54. ;
  55. ; Set Speed values for CTC Command:
  56. ;
  57. BD300:    EQU    0A001H        ;300 Baud
  58. BD1200:    EQU    06800H        ;1200 Baud
  59. ;
  60. MDINIT:
  61.     MVI    A,0        ;select WR0 (to be sure)
  62.     OUT    SPORT
  63.     MVI    A,RESCHN    ;Reset channel
  64.     OUT    SPORT
  65.     MVI    A,4        ;Setup to write register 4
  66.     OUT    SPORT
  67.     MVI    A,WRREG4
  68.     OUT    SPORT
  69.     MVI    A,1        ;Setup to write register 1
  70.     OUT    SPORT
  71.     MVI    A,WRREG1
  72.     OUT    SPORT
  73.     MVI    A,5        ;Setup to write register 5
  74.     OUT    SPORT
  75.     MVI    A,DTROFF    ;Clear DTR
  76.     OUT    SPORT        ;..Causing Hang-Up
  77.     MVI    A,3        ;Setup to write register 3
  78.     OUT    SPORT
  79.     MVI    A,WRREG3    ;Initialize receive register
  80.     OUT    SPORT
  81.     RET            ;Return
  82. ;
  83. ; This routine will raise DTR to answer the phone
  84. ;
  85. MDANSW:
  86.     MVI    A,5        ;WR5
  87.     OUT    SPORT
  88.     MVI    A,DTRON        ;turn on DTR
  89.     OUT    SPORT
  90.     RET            ;Return
  91. ;
  92. ;The following routine checks to make sure we still have carrier.
  93. ;If there is no carrier, it will return with the Zero flag set.
  94. ;
  95. MDCARCK:
  96.     MVI    A,RESSTA    ;Reset status, select WR0:
  97.     OUT    SPORT
  98.     IN    SPORT        ;Get status
  99.     ANI    DCD        ;Check for data carrier
  100.     RET            ;Return
  101. ;
  102. ;The following routine determines if there is a character waiting
  103. ;to be received.  If no character is waiting, the Zero flag will be set,
  104. ;otherwise, 255 will be returned in register A.
  105. ;
  106. MDINST:
  107.     IN    SPORT        ;Get status
  108.     ANI    DAV        ;Got a character?
  109.     RZ            ;Return if none
  110.     ORI    0FFh        ;..Otherwise, set the proper flag
  111.     RET            ;...and return
  112. ;
  113. ;The following is a routine that will input one character from the modem
  114. ;port.  If there is nothing there, it will return garbage... so use the
  115. ;MDINST routine first.
  116. ;
  117. MDINP:
  118.     IN    DPORT        ;Get character
  119.     ANI    7FH        ;Strip parity
  120.     RET            ;Return
  121. ;
  122. ;The following is a routine to determine if the transmit buffer is empty.
  123. ;If it is empty, it will return with the Zero flag clear.  If the transmitter
  124. ;is busy, then it will return with the Zero flag set.
  125. ;
  126. MDOUTST:
  127.     IN    SPORT
  128.     ANI    TBMT        ;Mask it
  129.     RET            ;Return
  130. ;
  131. ;The following is a routine that will output one character in register A
  132. ;to the modem.  REMEMBER, that is register A, not register C.
  133. ; ** Use MDOUTST first to see if buffer is empty **
  134. ;
  135. MDOUTP:
  136.     OUT    DPORT        ;Send it
  137.     RET            ;Return
  138. ;
  139. ;These next routines set the proper baud rates for the modem.  If you do
  140. ;not support the particular rate, then simply put the lable in front of
  141. ;the SETINV routine.  If the baud rate change was successful, make SURE
  142. ;the Zero flag is set.
  143. ;
  144. ;Set up for 300 baud
  145. ;
  146. SET300:
  147.     PUSH    H
  148.     LXI    H,BD300        ;Load rate
  149.     JMP    SETBAUD
  150. ;
  151. ;Set up for 1200 baud
  152. ;
  153. SET1200:
  154.     PUSH    H
  155.     LXI    H,BD1200    ;Load rate
  156. ;
  157. SETBAUD:
  158.     MVI    A,BDVECT    ;Get Vector addr
  159.     OUT    VPORT        ;Send to CTC
  160.     MOV    A,H
  161.     OUT    BPORT
  162.     MOV    A,L
  163.     OUT    BPORT        ;Send rate
  164.     POP    H
  165.     XRA    A        ;Say rate is OK
  166.     RET            ;Return
  167. ;
  168. ;The following routine returns a 255 because we were not able to set to
  169. ;the proper baud rate because either the serial port or the modem can't
  170. ;handle it.
  171. ;
  172. SET110:            ;110 baud not supported
  173. SET450:            ;450 baud not supported
  174. SET600:            ;600 baud not supported
  175. SET710:            ;710 baud not supported
  176. ;
  177.     ORI    0FFH    ;Make sure zero flag is not set
  178.     RET        ;and return...
  179. ;
  180. ;***********************************************************************
  181. ;
  182. ; That's it for the modem dependent I/O routines. Patch these into MBYE
  183. ; where it says INSERT YOUR MODEM DEPENDENT ROUTINES and it should work.
  184. ;
  185. ;************************************************************************
  186. ;
  187.