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 / NUNH-1.IQS / nunh-1.ins
Text File  |  1986-04-26  |  3KB  |  125 lines

  1. ; NUNH-1.INS - NUBYE insert for North Star Horizon computers - 04/21/86
  2. ;
  3. ; 8251A and no baudrate generator
  4. ;
  5. ; Pin 8 (DCD) from the modem must be connected to the USART's DSR input,
  6. ; normally Pin 6.
  7. ;
  8. ; Note:  This is an insert, not an overlay.
  9. ;
  10. ;
  11. ; ========
  12. ;
  13. ; 04/21/86  Modified for NUBYE
  14. ; 10/15/85  Original version for BYE5        - Irv Hoff
  15. ;
  16. ; ========
  17. ;
  18. ;The following define the port address to use
  19. ;
  20. PORT    EQU    4H        ; Data port
  21. MDCTL1    EQU    PORT+1        ; Status/control port
  22. BPORT    EQU    MDCTL1        ; Baud rate port=8251 control
  23. ;
  24. ; See if we still have a carrier - if not, return with the zero flag set
  25. ;
  26. MDCARCK:IN    MDCTL1        ; Get status
  27.     ANI    80H        ; Check DSR bit for a carrier
  28.     RET
  29. ;
  30. ; Disconnect and wait for an incoming call
  31. ;
  32. MDINIT:    MVI    A,10H        ; Clear DTR
  33.     OUT    MDCTL1        ; Causing hangup
  34.     PUSH    B        ; Preserve in case we need it
  35.     MVI    B,20        ; 2 second delay
  36. ;
  37. OFFTI:    CALL    DELAY        ; 0.1 second delay
  38.     DCR    B
  39.     JNZ    OFFTI        ; Keep looping until finnished
  40.     POP    B        ; Restore BC
  41.     MVI    A,17H        ; Assert DTR so that modem
  42.     OUT    MDCTL1        ; Can answer phone
  43.     XCHG            ; Small delay
  44.     XCHG            ; Small delay
  45. ;
  46.      IF    IMODEM
  47.     CALL    IMINIT
  48.      ENDIF            ; IMODEM
  49. ;
  50.     RET
  51. ;
  52. ; Input a character from the modem port
  53. ;
  54. MDINP:    IN    PORT        ; Get character
  55.     RET
  56. ;
  57. ; Check the status to see if a character is available.    If not, return
  58. ; with the zero flag set.  If yes, use 0FFH to clear the flag.
  59. ;
  60. MDINST:    IN    MDCTL1        ; Get status
  61.     ANI    2        ; Check the receive ready bit
  62.     RZ            ; Return if none
  63.     ORI    0FFH        ; We have a character
  64.     RET
  65. ;
  66. ; Send a character to the modem
  67. ;
  68. MDOUTP:    OUT    PORT        ; Send it
  69.     RET
  70. ;
  71. ; See if the output is ready for another character
  72. ;
  73. MDOUTST:IN    MDCTL1
  74.     ANI    1        ; Check the transmit ready bit
  75.     RET
  76. ;
  77. ; Reinitialize the modem and hang up the phone by dropping DTR and
  78. ; leaving it inactive.
  79. ;
  80. MDQUIT:     IF    IMODEM
  81.     CALL    IMQUIT        ; Tell modem to quit
  82.      ENDIF            ; IMODEM
  83. ;
  84. ; Called by the main program after caller types BYE
  85. ;
  86. MDSTOP:    MVI    A,10H        ; Turn off DTR
  87.     OUT    MDCTL1
  88.     RET
  89. ;
  90. ; The following routine sets the baudrate.  NUBYE asks for the maximum
  91. ; speed you have available.
  92. ;
  93. SET2400    EQU    $        ; Only supports 300/1200
  94. ;
  95. SETINV:    ORI    0FFH        ; Make sure zero flag not set
  96.     RET
  97. ;
  98. SET300:    MVI    B,BD300
  99.     JMP    SETBAUD
  100. ;
  101. SET1200:MVI    B,BD1200
  102. ;
  103. SETBAUD:MVI    A,47H        ; Reset, enable Rx, DTR, Tx
  104.     OUT    MDCTL1        ; Rx,Tx enabled
  105.     XCHG            ; Small delay
  106.     XCHG            ; Small delay
  107.     MOV    A,B        ; Recover Baud Rate Word
  108.     OUT    BPORT
  109.     XCHG            ; Small delay
  110.     XCHG            ; Small delay
  111.     MVI    A,17H        ; ERR reset, DTR, Rx, Tx all on
  112.     OUT    MDCTL1
  113.     XCHG            ; Small delay
  114.     XCHG            ; Small delay
  115.     XRA    A        ; Say rate OK
  116.     RET
  117. ;
  118. ; Values to switch the 8251 between x16 and x64 300 or 1200 bps
  119. ;
  120. BD300    EQU    4FH        ; 300 baud
  121. BD1200    EQU    4EH        ; 1200 bps
  122. ;
  123. ; end of insert
  124. ; -------------
  125.