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 / MB8250-1.ASM < prev    next >
Assembly Source File  |  2000-06-30  |  7KB  |  251 lines

  1. ;***********************************************************************
  2. ;
  3. ;               MBYE (Modular 'BYE')
  4. ;            8250 UART routines
  5. ;           v1.0 (02/07/84) by Kim Levitt
  6. ;
  7. ;    This is adapted from the WD8250 routines in BYE3.
  8. ;
  9. ;    These routines will allow the easy patching of MBYE for any 
  10. ; type of modem/serial port combination.  Certain routines must return
  11. ; status flags, so please be careful to set the flags as directed.
  12. ;
  13. ; This version is for the Western Digital 8250 chip that is hooked up to
  14. ; an external modem.  If your modem cannot detect a ring, then set
  15. ; NORING true.
  16. ;
  17. ;=======================================================================
  18. ;
  19. ; 02/07/84  Altered and renamed to work with MBYE    - Kim Levitt
  20. ; 11/27/83  Altered and renamed to work with BYE3    - Irv Hoff
  21. ; 08/04/83  Added MDQUIT routine            - Paul Traina
  22. ; 07/18/83  Fixed several bugs that I put in         - Paul Traina
  23. ; 10/04/82  Initial re-write of old 8250 routines    - Paul Traina
  24. ;
  25. ;=======================================================================
  26. ;
  27. ; The following define the port address to use.
  28. ;
  29. BASEP:    EQU    0D8H        ;Base port modem port
  30. DATPORT:EQU    BASEP        ;Data port
  31. LPORT:    EQU    BASEP+3        ;Line control
  32. CPORT:    EQU    BASEP+4        ;Modem control
  33. SPORT:    EQU    BASEP+5        ;Line status port
  34. MSPORT:    EQU    BASEP+6        ;Modem status port
  35. RPORT:    EQU    BASEP+6        ;Ring indicator port
  36. ;
  37. ; Line status bits
  38. ;
  39. DAV:    EQU    00000001B    ;Data available
  40. ORUN:    EQU    00000010B    ;Overrun error
  41. PERR:    EQU    00000100B    ;Parity error
  42. FERR:    EQU    00001000B    ;Framing error
  43. ERR:    EQU    ORUN+PERR+FERR    ;Error bits
  44. TBMT:    EQU    00100000B    ;Transmitt buffer empty
  45. ;
  46. ; Modem status bits
  47. ;
  48. DSR:    EQU    00100000B    ;Data set ready
  49. RDET:    EQU    01000000B    ;Ring detect
  50. DCD:    EQU    10000000B    ;Carrier detect
  51. ;
  52. ; Baud rate divisors
  53. ;
  54. BR300LS: EQU    080H        ;300 baud
  55. BR300MS: EQU    001H
  56. BR450LS: EQU    000H        ;450 baud
  57. BR450MS: EQU    001H
  58. BR600LS: EQU    0C0H        ;600 baud
  59. BR600MS: EQU    000H
  60. BR120LS: EQU    060H        ;1200 baud
  61. BR120MS: EQU    000H
  62. ;
  63. ;    Modem control bits
  64. ;
  65. DTR:    EQU    00000001B    ;Data terminal ready
  66. RTS:    EQU    00000010B    ;Request to send
  67. OUT1:    EQU    00000100B    ;Aux output #1
  68. OUT2:    EQU    00001000B    ;Aux output #2
  69. ;
  70. ;    Line control bits
  71. ;
  72. WLS0:    EQU    00000001B    ;Word length select 0
  73. WLS1:    EQU    00000010B    ;Word length select 1
  74. STB:    EQU    00000100B    ;Stop bit select
  75. PEN:    EQU    00001000B    ;Parity enable
  76. PES:    EQU    00010000B    ;Even parity select
  77. SPS:    EQU    00100000B
  78. BRKS:    EQU    01000000B    ;Break
  79. DLAB:    EQU    10000000B
  80. ;
  81. ;
  82. ;***********************************************************************
  83. ;
  84. ; If any of your routines zaps anything other than the Accumulator, then
  85. ; you must preserve all other registers.
  86. ;
  87. ;***********************************************************************
  88. ;
  89. ; This routine should turn off everything on the modem, and get it ready
  90. ; to wait for a ring.  (Also hang it up)
  91. ;
  92. MDINIT:
  93.     XRA    A        ;Shut off DTR & RTS
  94.     OUT    CPORT        ;..which turns off modem.
  95.     RET
  96. ;
  97. ; The following routine will make the modem answer the phone.
  98. ;
  99. MDANSW:
  100.     MVI    A,DTR+RTS    ;Turn on DTR and let modem answer phone
  101.     OUT    CPORT
  102.     CALL    SET300        ;Set 300 baud (for init only)
  103.     MVI    A,WLS0+WLS1    ;8 data bits, 1 stop bit, no parity
  104.     OUT    LPORT
  105.     RET
  106. ;
  107. ; The following is a routine to determine if there is a character wait-
  108. ; ing to be received, if none, Zero flag will be set, otherwise, 0FFH
  109. ; will be returned in register A.  Remember that the system will like
  110. ; you a little more if you also mask out framing, parity, and overrun
  111. ; errors.
  112. ;
  113. MDINST:
  114.     PUSH    B        ;Save BC
  115.     IN    SPORT        ;Get status
  116.     MOV    B,A        ;Save it in B (status cleared by read)
  117.     ANI    DAV        ;Data available?
  118.     JZ    NDAV        ;Return if not ready
  119.     MOV    A,B        ;else, check error bits
  120.     ANI    ERR        ;for parity/overrun/framing errors
  121.     JZ    DAVA        ;if none, ok...
  122.     IN    DPORT        ;else clear garbage
  123. ;
  124. NDAV:
  125.     XRA    A        ;say no data
  126.     POP    B        ;restore BC
  127.     RET            ;and return
  128. ;
  129. DAVA:
  130.     ORI    0FFH        ;We have a character
  131.     POP    B        ;restore BC
  132.     RET            ;and return
  133. ;
  134. ; The following is a routine to determine if the transmit buffer is
  135. ; empty.  If it is empty, it will return with the Zero flag clear.  If
  136. ; the transmitter is busy, then it will return with the Zero flag set.
  137. ;
  138. MDOUTST:
  139.     IN    SPORT
  140.     ANI    TBMT
  141.     RET
  142. ;
  143. ; The following is a routine that will check to make sure we still have
  144. ; carrier.  If there is no carrier, it will return with the Zero flag
  145. ; set.
  146. ;
  147. MDCARCK:
  148.     IN    MSPORT            ;Get modem status
  149.     ANI    DCD            ;Got a carrier?
  150.     RET
  151. ;
  152. ; The following routine will check to see if the phone is ringing, if it
  153. ; isn't, it will return with Zero set, otherwise Zero will be cleared.
  154. ;
  155. MDRING:
  156.     IN    RPORT        ;Ringing?
  157.     ANI    RDET        ;1=yes, 0=no
  158.     RET
  159. ;
  160. ; The following is a routine that will input one character from the
  161. ; modem port.  If there is nothing there, it will return garbage...
  162. ; so use the MDINST routine first.
  163. ;
  164. MDINP:
  165.     IN    DATPORT        ;get character
  166.     ANI    7FH        ;strip parity and other garbage
  167.     RET
  168. ;
  169. ; The following is a routine that will output one character in register
  170. ; A to the modem.  REMEMBER, that is register A, not register C.
  171. ;
  172. ; ** Use MDOUTST first to see if buffer is empty **
  173. ;
  174. MDOUTP:
  175.     OUT    DATPORT        ;send it
  176.     RET
  177. ;
  178. ; These next routines set the proper baud rates for the modem.  If you
  179. ; do not support the particular rate, then simply remove that routine
  180. ; and put the pointer in front of SETINV.
  181. ;
  182. ; If the baud rate change was successful, make SURE the Zero flag is set.
  183. ;
  184. ; The following routine returns a 255 because we were not able to set to
  185. ; the proper baud rate because either the serial port or the modem can't
  186. ; handle it.
  187. ;
  188. SET110:                ;110 baud is seldom used
  189. SET600:                ;600 bause is only for PMMI
  190. SET710:                ;710 baud is only for PMMI
  191. ;
  192. SETINV:
  193.     ORI    0FFH
  194.     RET
  195. ;
  196. ; Set up for 300 baud
  197. ;
  198. SET300:
  199.     PUSH    D        ;Set 300
  200.     MVI    D,BR300MS
  201.      MVI    E,BR300LS
  202.     JMP    SETALL
  203. ;
  204. ; Set up for 450 baud
  205. ;
  206. SET450:
  207.     PUSH    D        ;Set 450
  208.     MVI    D,BR450MS
  209.     MVI    E,BR450LS
  210.     JMP    SETALL
  211. ;
  212. ; Set up for 1200 baud
  213. ;
  214. SET1200:
  215.     PUSH    D        ;Set 1200
  216.     MVI    D,BR120MS
  217.     MVI    E,BR120LS
  218. ;
  219. SETALL:
  220.     CALL    SETBAUD
  221.     POP    D
  222.     XRA    A
  223.     RET
  224. ;
  225. ; This routine takes the baud rate divisors passed in the DE register
  226. ; and sets the modem port accordingly.
  227. ;
  228. SETBAUD:
  229.     MVI    A,83H        ;Set DLAB
  230.     OUT    LPORT
  231.     MOV    A,E        ;Get LSB
  232.     OUT    DATPORT
  233.     MOV    A,D        ;Get MSB
  234.     OUT    DATPORT+1
  235.     MVI    A,WLS0+WLS1    ;8 data bits, no parity, 1 stop bit
  236.     OUT     LPORT
  237.     PUSH    B
  238.     MVI    B,2        ;wait about .2 seconds
  239.     CALL    DELAY
  240.     POP    B
  241.     IN    DATPORT        ;Clear out any inpuyt chars.
  242.     IN    DATPORT
  243.     RET
  244. ;
  245. ; Ok, that's all of the modem dependant routines that MBYE uses, so if
  246. ; you patch this file into your copy of MBYE, then it should work out
  247. ; well.
  248. ;
  249. ;**********************************************************************
  250. ;
  251.