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 / NUBYE / NUBY-INS.LBR / NUUS-1.IQS / nuus-1.ins
Text File  |  1986-04-26  |  4KB  |  158 lines

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