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 / B5US-1.INS < prev    next >
Text File  |  2000-06-30  |  4KB  |  186 lines

  1.  
  2. ; B5US-1.INS - US Robotics S100 modem insert for BYE5 - 07/17/85
  3. ;
  4. ;         US Robotics S100 modem Interface routines
  5. ;
  6. ;         Note:  This is an insert, not an overlay.
  7. ;
  8. ;        *********************************
  9. ;        *                *
  10. ;        *   DOES NOT SUPPORT 2400 BPS    *
  11. ;        *                *
  12. ;        *********************************
  13. ;
  14. ;
  15. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  16. ;
  17. ; 07/17/85  Modified for use with BYE5        - Irv Hoff
  18. ; 03/11/85  Adapted to BYE331            - Joe Wright
  19. ;
  20. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  21. ;
  22. ; Port equates
  23. ;
  24. PORT    EQU    0C0H        ; Modem data port
  25. MDCTL1    EQU    PORT+1        ; Status port and control port #1
  26. ;
  27. ;
  28. ; Bit functions
  29. ;
  30. BDIV64    EQU    04FH        ; 8 data bits, no parity, 1 stop, div 64
  31. BDIV16    EQU    04EH        ; 8 data bits, no parity, 1 stop, div 16
  32. BRESET    EQU    040H        ; Reset 8251A
  33. ;
  34. BANHI    EQU    035H        ; Answer phone, RTS high (300/1200 baud)
  35. BANLOW    EQU    015H        ; Answer phone, RTS low  (110/600 baud)
  36. DTR    EQU    002H        ; DTR bit in command word for off-hook
  37.                 ;   control
  38. ;
  39. ;-----------------------------------------------------------------------
  40. ;
  41. ;
  42. ; See if we still have a carrier - if not, return with the zero flag set
  43. ;
  44. MDCARCK:IN    MDCTL1        ; Read port
  45.     ANI    80H        ; Check DSR for carrier detect
  46.     STA    CARFLG+1    ; Remember it
  47.     RET
  48. ;.....
  49. ;
  50. ;
  51. ; Return previous carrier status
  52. ;
  53. CARFLG:    MVI    A,0        ; Immediate value set by MDCARCK
  54.     ORA    A        ; Set the flags
  55.     RET
  56. ;.....
  57. ;
  58. ;
  59. ; Disconnect and wait for an incoming call
  60. ;
  61. MDINIT:    CALL    MDCARCK        ; Do we have a carrier?
  62.     JZ    IMINIT        ; No carrier, initialize the modem
  63.     CALL    MDRESET        ; Hang up
  64.     JMP    MDINIT        ; Try it again
  65. ;.....
  66. ;
  67. ;
  68. ;Input a character from the modem port
  69. ;
  70. MDINP:    IN    PORT        ; Get character
  71.     RET
  72. ;.....
  73. ;
  74. ;
  75. ; Check the status to see if a character is available.    If not, return
  76. ; with the zero flag set.  If yes, use 0FFH to clear the flag.
  77. ;
  78. MDINST:    IN    MDCTL1        ; Read port
  79.     ANI    02H        ; Check receive ready bit
  80.     RZ            ; Return if no character
  81.     ORI    0FFH
  82.     RET
  83. ;.....
  84. ;
  85. ;
  86. ; Send a character to the modem
  87. ;
  88. MDOUTP:    OUT    PORT        ; Send it
  89.     RET
  90. ;.....
  91. ;
  92. ;
  93. ; See if the output is ready for another character
  94. ;
  95. MDOUTST:IN    MDCTL1        ; Read port
  96.     ANI    01H        ; Check transmit ready bit
  97.     RET
  98. ;.....
  99. ;
  100. ;
  101. ; Reinitialize the modem and hang up the phone by dropping DTR and
  102. ; leaving it inactive.
  103. ;
  104. MDQUIT:    CALL    IMQUIT        ; Tell modem to shut down
  105. ;
  106. MDSTOP:    RET
  107. ;.....
  108. ;
  109. ;
  110. ; The following routine sets the baudrate.  BYE5 asks for the maximum
  111. ; speed you have available.
  112. ;
  113. SET2400    EQU    $
  114. ;
  115. SETINV:    ORI    0FFH        ; Make sure the zero flag isn't set
  116.     RET
  117. ;.....
  118. ;
  119. ;
  120. ; The pairs of XCHG instructions in the following code are to allow
  121. ; for the reported slowness of the 8251a command/status port.
  122. ;
  123. ; Note:  Asserting DTR during 8251 initialization will hang up the phone.
  124. ; To keep the phone off-hook if carrier is present, DTR is asserted or
  125. ; not, depending on the last condition of the carrier detect flag.
  126. ;
  127. MDRESET:CALL    INITUSR        ; Initialize the modem and hang up
  128.     MVI    A,BDIV16    ; 1200 bps
  129.     OUT    MDCTL1
  130.     XCHG
  131.     XCHG
  132.     MVI    A,BANHI+DTR    ; Put phone on-hook
  133.     JMP    SENBAUD
  134. ;
  135. SET300:    CALL    INITUSR        ; Initialize Robotics
  136.     MVI    A,BDIV64    ; Set mode and divide by 64 (300 baud)
  137.     OUT    MDCTL1
  138.     XCHG
  139.     XCHG
  140.     CALL    CARFLG        ; Data carrier detect
  141.     MVI    A,BANHI        ; Set RTS high (300 baud)
  142.     JNZ    ST3        ; If carrier, leave phone off-hook
  143.     ORI    DTR        ; Otherwise leave it on-hook
  144. ;
  145. ST3:    JMP    SENBAUD
  146. ;
  147. SET1200:CALL    INITUSR        ; Initialize Robotics
  148.     MVI    A,BDIV16    ; Set mode and divide by 16 (1200 bps)
  149.     OUT    MDCTL1
  150.     XCHG
  151.     XCHG
  152.     CALL    CARFLG
  153.     MVI    A,BANHI        ; Set RTS high (1200 bps)
  154.     JNZ    SENBAUD
  155.     ORI    DTR
  156. ;
  157. SENBAUD:OUT    MDCTL1        ; Send the command byte
  158.     XCHG
  159.     XCHG
  160.     CALL    DLP        ; Let the modem settle down for 1 second
  161.     XRA    A        ; Clear flags to indicate good baud
  162.     RET            ;   change
  163. ;.....
  164. ;
  165. ;
  166. INITUSR:XRA    A
  167.     OUT    MDCTL1
  168.     XCHG
  169.     XCHG
  170.     OUT    MDCTL1
  171.     XCHG
  172.     XCHG
  173.     OUT    MDCTL1
  174.     XCHG
  175.     XCHG
  176.     MVI    A,BRESET    ; Send reset code to 8251
  177.     OUT    MDCTL1
  178.     XCHG
  179.     XCHG
  180.     XRA    A        ; Says baudrate change was ok
  181.     RET
  182. ;....
  183. ;
  184. ;                   end
  185. ;-----------------------------------------------------------------------
  186.