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 / BYE5 / B5MD-1.IQS / B5MD-1.INS
Text File  |  2000-06-30  |  5KB  |  232 lines

  1.  
  2. ; B5MD-1.INS - BYE5 insert for Morrow Micro Decision Computers    07/17/85
  3. ;
  4. ;        8251A and Intel 8253 timer for Rev 2.x only
  5. ;
  6. ; Pin 8 (DCD) from the modem must be connected to the USART's DSR input,
  7. ; either on the internal jumper block or in the modem connecting cable.
  8. ;
  9. ;         Note:  This is an insert, not an overlay.
  10. ;
  11. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  12. ;
  13. ; 07/17/85  Written to work with BYE5            - Irv Hoff
  14. ; 03/30/85  Written for Rev 1.x and Rev 2.x boards    - Jim Sinning
  15. ;
  16. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  17. ;
  18. ;
  19. ; The following equate will be YES if using a later Micr Decision with
  20. ; Intel 8253 timer chip and Centronics Port.  Set NO for rev 1.x board.
  21. ;
  22. REV2X    EQU    YES        ; Yes if Centronix port and 8253 chip
  23.                 ; No if Rev 1.x board
  24. ;
  25. ;The following define the port address to use
  26. ;
  27. PORT    EQU    0FEH        ; Data port
  28. MDCTL1    EQU    PORT+1        ; Status/control port
  29. ;
  30. ;
  31. ; NOTE: The DIP switches for Serial 2 Port must be set for 1200 baud for
  32. ; this to work.
  33. ;
  34.      IF    REV2X
  35. BPORT    EQU    0F2H        ; Serial 2 Port on Intel 8253 timer
  36. CPORT    EQU    0F3H        ; 8253 control port
  37. MODINS1    EQU    4EH        ; 8 bits, 1 stop, 16x, no parity
  38.      ENDIF            ; REV2X
  39. ;
  40.      IF    NOT REV2X
  41. BPORT    EQU    MDCTL1        ; Baud rate port=8251 control
  42. CPORT    EQU    MDCTL1        ; Control port=8251 control
  43. MODINS1    EQU    4FH        ; 8 bits, 1 stop, 64x, no parity
  44.      ENDIF            ; NOT REV2X
  45. ;
  46. ;
  47. ; The following byte selects the proper mode for the Intel 8253 timer.
  48. ; Selects counter 2, reads least significant byte then most significant
  49. ; byte, sets the square wave generator and count is binary.
  50. ;
  51.      IF    REV2X
  52. CNTR2    EQU    0BEH
  53.      ENDIF            ; REV2X
  54. ;
  55. ;
  56. ;-----------------------------------------------------------------------
  57. ;
  58. ;
  59. ; See if we still have a carrier - if not, return with the zero flag set
  60. ;
  61. MDCARCK:IN    MDCTL1        ; Get status
  62.     ANI    80H        ; Check DSR bit for a carrier
  63.     RET
  64. ;.....
  65. ;
  66. ;
  67. ; Disconnect and wait for an incoming call
  68. ;
  69. MDINIT:    MVI    A,10H        ; Clear DTR
  70.     OUT    MDCTL1        ; Causing hangup
  71.     PUSH    B        ; Preserve in case we need it
  72.     MVI    B,20        ; 2 second delay
  73. ;
  74. OFFTI:    CALL    DELAY        ; 0.1 second delay
  75.     DCR    B
  76.     JNZ    OFFTI        ; Keep looping until finnished
  77.     POP    B        ; Restore BC
  78.     MVI    A,17H        ; Assert DTR so that modem
  79.     OUT    MDCTL1        ; Can answer phone
  80.     CALL    UDELAY        ; Added to be safe
  81. ;
  82.      IF    IMODEM
  83.     CALL    IMINIT
  84.      ENDIF            ; IMODEM
  85. ;
  86.     RET
  87. ;.....
  88. ;
  89. ;
  90. ; Input a character from the modem port
  91. ;
  92. MDINP:    IN    PORT        ; Get character
  93.     RET
  94. ;.....
  95. ;
  96. ;
  97. ; Check the status to see if a character is available.    If not, return
  98. ; with the zero flag set.  If yes, use 0FFH to clear the flag.
  99. ;
  100. MDINST:    IN    MDCTL1        ; Get status
  101.     ANI    02H        ; Check the receive ready bit
  102.     RZ            ; Return if none
  103.     ORI    0FFH        ; We have a character
  104.     RET
  105. ;.....
  106. ;
  107. ;
  108. ; Send a character to the modem
  109. ;
  110. MDOUTP:    OUT    PORT        ; Send it
  111.     RET
  112. ;.....
  113. ;
  114. ;
  115. ; See if the output is ready for another character
  116. ;
  117. MDOUTST:IN    MDCTL1
  118.     ANI    01H        ; Check the transmit ready bit
  119.     RET
  120. ;.....
  121. ;
  122. ;
  123. ; Reinitialize the modem and hang up the phone by dropping DTR and
  124. ; leaving it inactive.
  125. ;
  126. MDQUIT:     IF    IMODEM
  127.     CALL    IMQUIT        ; Tell smartmodem to quit
  128.      ENDIF            ; IMODEM
  129. ;
  130. ;
  131. ; Called by the main program after caller types BYE
  132. ;
  133. MDSTOP:    MVI    A,10H        ; Turn off DTR
  134.     OUT    MDCTL1
  135.     RET
  136. ;.....
  137. ;
  138. ;
  139. ;-----------------------------------------------------------------------
  140. ;             Start of rev 1.x speeds
  141. ;
  142. ; The following routine sets the baudrate.  BYE5 asks for the maximum
  143. ; speed you have available.
  144. ;
  145.      IF    NOT REV2X
  146. SET2400    EQU    $        ; Only supports 300/1200
  147. ;
  148. SETINV:    ORI    0FFH        ; Make sure zero flag not set
  149.     RET
  150. ;.....
  151. ;
  152. ;
  153. SET300:    MVI    B,BD300
  154.     JMP    SETBAUD
  155. ;
  156. SET1200:MVI    B,BD1200
  157. ;
  158. SETBAUD:MVI    A,47H        ; Reset, enable Rx, DTR, Tx
  159.     OUT    MDCTL1        ; Rx,Tx enabled
  160.     CALL    UDELAY
  161.     MOV    A,B        ; Recover Baud Rate Word
  162.     OUT    BPORT
  163.     CALL    UDELAY        ; Wait for USART
  164.     MVI    A,17H        ; ERR reset, DTR, Rx, Tx all on
  165.     OUT    MDCTL1
  166.     CALL    UDELAY
  167.     XRA    A        ; Say rate OK
  168.     RET
  169. ;.....
  170. ;
  171. ;
  172. ; Values to switch the 8251 between x16 and x64 for rev 1.x boards
  173. ;
  174. BD300    EQU    4FH        ; 300 baud
  175. BD1200    EQU    4EH        ; 1200 bps
  176.      ENDIF            ; NOT REV2X
  177. ;
  178. ;              End of rev 1.x speeds
  179. ;-----------------------------------------------------------------------
  180. ;             Start of rev 2.x speeds
  181. ;
  182.      IF    REV2X        ; 300/1200/2400 baud supported
  183. SET300:    PUSH    H        ; Save HL just in case
  184.     LXI    H,BD300        ; Point Divisor word
  185.     JMP    SETBAUD
  186. ;
  187. SET1200:PUSH    H
  188.     LXI    H,BD1200
  189.     JMP    SETBAUD
  190. ;
  191. SET2400:PUSH    H
  192.     LXI    H,BD2400
  193. ;
  194. SETBAUD:MVI    A,CNTR2        ; Select Serial 2 Counter
  195.     OUT    CPORT
  196.     CALL    UDELAY
  197.     MOV    A,L        ; Send Least significant byte
  198.     OUT    BPORT
  199.     CALL    UDELAY
  200.     MOV    A,H
  201.     OUT    BPORT
  202.     CALL    UDELAY
  203.     MVI    A,17H        ; ERR reset, Rx, DTR, Tx all on
  204.     OUT    MDCTL1
  205.     CALL    UDELAY
  206.     XRA    A        ; Say baud rate is OK
  207.     POP    H        ; Recover HL
  208.     RET
  209. ;.....
  210. ;
  211. ;
  212. ; The following data words are the Intel 8253 divisors for BPORT
  213. ;
  214. BD300    EQU    416        ; 300 baud
  215. BD1200    EQU    104        ; 1200 bps
  216. BD2400    EQU    52        ; 2400 bps
  217. BD9600    EQU    13        ; 9600 bps
  218.      ENDIF            ; REV2X
  219. ;.....
  220. ;
  221. ;
  222. ; IN8251 specific USART delay
  223. ;
  224. UDELAY:    NOP
  225.     NOP
  226.     NOP
  227.     RET
  228. ;.....
  229. ;
  230. ;                   end
  231. ;------------------------------------------------------
  232.