home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / cpm / bye3 / b3md-2.ins < prev    next >
Text File  |  1994-07-13  |  5KB  |  204 lines

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