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 / MB2651-1.AQM / MB2651-1.ASM
Assembly Source File  |  2000-06-30  |  8KB  |  291 lines

  1. ;***********************************************************************
  2. ;
  3. ;            MBYE (Modular 'BYE')
  4. ;         National Semiconductor 2651 UART I/O routines
  5. ;            v1.0 (02/07/84) by Kim Levitt
  6. ;     (For CompuPro Interfacer 3, Interfacer 4 & System Support 1)
  7. ;
  8. ; These routines will allow the easy patching of BYE3 for any type of
  9. ; modem/serial port combination.  Certain routines must return status
  10. ; flags, so please be careful to set the flags as directed.
  11. ;
  12. ; This version is for the CompuPro Interfacer 3 or 4 that is connected
  13. ; to an external modem.  Note:  I use DSR to tell me if the phone is
  14. ; ringing and DCD tells me when I have carrier.
  15. ;
  16. ; This means, a null-modem cable should be set up as follows:
  17. ;
  18. ;     Modem Interfacer 3/4         Function
  19. ;    2    3        TXD    ->    RXD
  20. ;    3    2        RXD    <-    TXD
  21. ;    4-\            RTS    -\    (jumpered)
  22. ;    5-/            CTS    -/
  23. ;    8    8        DCD    ->    DCD
  24. ;    7    7        Ground    --    Ground
  25. ;    22    20        RI    ->    DSR
  26. ;    20    6        DTR    <-    DSR
  27. ;
  28. ;-----------------------------------------------------------------------
  29. ;
  30. ; 02/07/84  Altered and renamed to work with MBYE    - Kim Levitt
  31. ; 11/27/83  Altered and renamed to work with BYE3    - Irv Hoff 
  32. ; 08/04/83  Added MDQUIT routine which will de-
  33. ;        initalize modem port.            - Paul Traina
  34. ; 07/14/83  Added support for Rixon/US Robotics/Hayes
  35. ;        Smartmodem.  Added support for CompuPro
  36. ;        System Support-1.                - Paul Traina
  37. ; 10/04/82 Routines added, no fuss, mess, or frills.    - Paul Traina
  38. ;
  39. ;***********************************************************************
  40. ;
  41. ; Define which I/O card you are using here
  42. ;
  43. GBCINT3:EQU    YES        ;yes= CompuPro Interfacer 3 or 4
  44. GBCSS1:    EQU    NO        ;yes= CompuPro System Support 1
  45. ;
  46. ;
  47. ; The following define the port address and USART number to use.
  48. ;
  49.      IF    GBCINT3
  50. BASEP:    EQU    010H        ;Base port for I3/4 boards
  51. USART:    EQU    6        ;USART number to use
  52.      ENDIF
  53. ;
  54.      IF    GBCSS1
  55. BASEP:    EQU    05CH        ;Base port for System Support 1
  56.      ENDIF
  57. ;
  58. ;***********************************************************************
  59. ;
  60. ; Modem port equates
  61. ;
  62. DPORT:    EQU    BASEP        ;Modem data port
  63. SPORT:    EQU    BASEP+1        ;Modem status port
  64. MPORT    EQU    BASEP+2        ;Modem mode select port
  65. CPORT:    EQU    BASEP+3        ;Modem control port
  66. ;
  67.      IF    GBCINT3
  68. UPORT:    EQU    BASEP+7        ;Modem USART select port
  69.      ENDIF            ;GBCINT3
  70. ;
  71. ;
  72. ; Modem status port equates
  73. ;
  74. TBMT:    EQU    00000001B        ;Transmit buffer empty
  75. DAV:    EQU    00000010B        ;Data available
  76. PE:    EQU    00001000B        ;Parity error
  77. OE:    EQU    00010000B        ;Overrun error
  78. FE:    EQU    00100000B        ;Framing error
  79. DCD:    EQU    01000000B        ;Carrier detect
  80. RDET:    EQU    10000000B        ;Ring detect (tied to I3 DSR line)
  81. ;
  82. ;
  83. ;Mode port equates
  84. ;
  85. E8NO1:    EQU    01001110B        ;8 data bits, no parity, 1 stop bit
  86. EBASE:    EQU    01110000B        ;Mode register 2 base
  87. B110:    EQU    EBASE+2            ;110 bps
  88. B300:    EQU    EBASE+5            ;300 bps
  89. B600:    EQU    EBASE+6            ;600 bps (not implemented)
  90. B1200:    EQU    EBASE+7            ;1200 bps
  91. ;
  92. ;
  93. ; Command port equates
  94. ;
  95. CBASE:    EQU    00000101B        ;Command base
  96. RESET:    EQU    00010000B        ;Reset errors
  97. DTR:    EQU    00000010B        ;Turn on DTR
  98. RTS:    EQU    00100000B        ;Turn on RTS
  99. ;
  100. ;***********************************************************************
  101. ;
  102. ; If any of your routines zaps anything other than the Accumulator, then
  103. ; you must preserve all other registers.
  104. ;
  105. ;***********************************************************************
  106. ;
  107. ; This routine should turn off everything on the modem,  but set baud-
  108. ; rate to 300 bps, and get it ready to wait for a ring.  (Also hang it
  109. ; up)
  110. ;
  111. MDINIT:
  112.      IF    GBCINT3
  113.     MVI    A,USART        ;Select proper chip
  114.     OUT    UPORT
  115.      ENDIF
  116.     CALL    SET300        ;Set 300 bps
  117.     MVI    A,CBASE        ;Xmit on, Recv on, DTR off, RTS off  
  118.     OUT    CPORT
  119.     RET
  120. ;
  121. ; The following is a routine to determine if there is a character wait-
  122. ; ing to be received.  If none are there, the Zero flag will be set,
  123. ; otherwise, 255 will be returned in register A.  Remember that the
  124. ; system will like you a little more if you also mask out framing,
  125. ; parity, and overrun errors.
  126. ;
  127. MDINST:     IF    GBCINT3
  128.     MVI    A,USART        ;Select proper chip
  129.     OUT    UPORT
  130.      ENDIF
  131. ;
  132.      IN    SPORT        ;read port
  133.     ANI    DAV        ;mask crap
  134.     RZ            ;nope, nothing there
  135.     ORI    0FFH        ;we got something...
  136.     RET
  137. ;
  138. ; The following is a routine to determine if the transmit buffer is
  139. ; empty.  If it is empty, it will return with the Zero flag clear.  If
  140. ; the transmitter is busy, then it will return with the Zero flag set.
  141. ;
  142. MDOUTST: IF    GBCINT3
  143.     MVI    A,USART        ;Select proper chip
  144.     OUT    UPORT
  145.      ENDIF
  146. ;
  147.     IN    SPORT        ;read port
  148.     ANI    TBMT        ;mask crap
  149.     RET
  150. ;
  151. ; The following is a routine that will check to make sure we still have
  152. ; carrier.  If there is no carrier, it will return with the Zero flag
  153. ; set.
  154. ;
  155. MDCARCK: IF    GBCINT3
  156.     MVI    A,USART        ;Select proper chip
  157.     OUT    UPORT
  158.      ENDIF
  159. ;
  160.     IN    SPORT        ;read port
  161.     ANI    DCD        ;yes, that's right, DSR...
  162.     RET
  163. ;
  164. ; The following routine will check to see if the phone is ringing, if
  165. ; it isn't, it will return with Zero set, otherwise Zero will be cleared.
  166. ;
  167. MDRING:     IF    GBCINT3
  168.     MVI    A,USART        ;Select proper chip
  169.     OUT    UPORT
  170.      ENDIF
  171. ;
  172.     IN    SPORT        ;read status
  173.     ANI    RDET        ;yes, use DSR, and nothing else...sigh
  174.     RET
  175. ;
  176. ; The following is a routine that will input one character from the
  177. ; modem port.  If there is nothing there, it will return garbage... so
  178. ; use the MDINST routine first.
  179. ;
  180. MDINP:     IF    GBCINT3
  181.     MVI    A,USART        ;Select proper chip
  182.     OUT    UPORT
  183.      ENDIF
  184. ;
  185.     IN    DPORT        ;get character
  186.     ANI    7FH        ;strip parity and other garbage
  187.     RET
  188. ;
  189. ; The following is a routine that will output one character in register
  190. ; A to the modem.  REMEMBER, that is register A, not register C.
  191. ;
  192. ; **** Use MDOUTST first to see if buffer is empty ****
  193. ;
  194. MDOUTP:     IF    GBCINT3
  195.     PUSH    PSW
  196.     MVI    A,USART        ;Select proper chip
  197.     OUT    UPORT
  198.     POP    PSW
  199.      ENDIF
  200. ;
  201.     OUT    DPORT        ;send it
  202.     RET
  203. ;
  204. ; The following routine will make the modem answer the phone.
  205. ;
  206. MDANSW:    CALL    SET300        ;set modem for 300 baud, selects chip
  207.     MVI    A,CBASE+DTR+RTS    ;turn on DTR and RTS which will allow
  208.     OUT    CPORT        ;..the external modem to answer on the
  209.     RET            ;..next ring.
  210. ;
  211. ; These next routines set the proper baud rates for the modem.  If you
  212. ; do not support the particular rate, then simply put the pointer for
  213. ; that rate in front of the SETINV routine.  If the baud rate change
  214. ; was successful, make SURE the Zero flag is set.
  215. ;
  216. ; The following routine returns a 255 because we were not able to set to
  217. ; the proper baud rate because either the serial port or the modem can't
  218. ; handle it.
  219. ;
  220. SET110:        
  221. SET450:                ;2651 cannot handle 450 baud
  222. SET600:                ;J1259 is not very reliable at 600bps
  223. SET710:                ;only PMMI's are crazy enough to do 710
  224. ;
  225. SETINV:    ORI    0FFH        ;make sure the Zero flag isn't set
  226.     RET
  227. ;
  228. ; Set up for 110 bps
  229. ;
  230. SET110:  IF    GBCINT3
  231.     MVI    A,USART        ;Select proper chip
  232.     OUT    UPORT
  233.      ENDIF
  234.  
  235.     MVI    A,E8NO1+128    ;set default formats EXCEPT 2 STOP BITS
  236.     OUT    MPORT
  237.     MVI    A,B110
  238.     OUT    MPORT
  239.     XRA    A
  240.     RET
  241. ;
  242. ; Set up for 300 bps
  243. ;
  244. SET300:     IF    GBCINT3
  245.     MVI    A,USART        ;Select proper chip
  246.     OUT    UPORT
  247.      ENDIF
  248. ;
  249.     MVI    A,E8NO1        ;set default formats
  250.     OUT    MPORT
  251.     MVI    A,B300        ;set baud rate
  252.     OUT    MPORT
  253.     XRA    A
  254.     RET
  255. ;
  256. ; Set up for 600 bps (some modems can handle 600 bps, if yours can, then
  257. ; delete the previous pointer and un-comment this routine.
  258. ;
  259. SET600:  IF    GBCINT3
  260.     MVI    A,USART        ;Select proper chip
  261.     OUT    UPORT
  262.      ENDIF
  263. ;
  264.     MVI    A,E8NO1        ;set default formats
  265.     OUT    MPORT
  266.     MVI    A,B600        ;set baud rate
  267.     OUT    MPORT
  268.     XRA    A
  269.     RET
  270. ;
  271. ; Set up for 1200 bps
  272. ;
  273. SET1200: IF    GBCINT3
  274.     MVI    A,USART        ;Select proper chip
  275.     OUT    UPORT
  276.      ENDIF
  277. ;
  278.     MVI    A,E8NO1        ;set default formats
  279.     OUT    MPORT
  280.     MVI    A,B1200        ;set baud rate
  281.     OUT    MPORT
  282.     XRA    A
  283.     RET
  284. ;
  285. ; Ok, that's all of the modem dependent routines that MBYE uses, so if
  286. ; you patch this file into your copy of MBYE, then it should work out
  287. ; well.
  288. ;
  289. ;**********************************************************************
  290. ;
  291.