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 / B5KP-1.INS < prev    next >
Text File  |  2000-06-30  |  3KB  |  164 lines

  1. ; B5KP-1.INS  -  Kaypro insert for BYE5  -  07/17/85
  2. ;
  3. ;           Z80-SIO and 8116 baudrate generator
  4. ;              by Irv Hoff
  5. ;
  6. ;
  7. ;        Note:  This is an insert, not an overlay.
  8. ;
  9. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  10. ;
  11. ; 07/17/85  Written for use with BYE5        - Irv Hoff
  12. ;
  13. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  14. ;
  15. ;
  16. PORT    EQU    04H        ; Data port
  17. MDCTL1    EQU    PORT+2        ; Modem control port
  18. BRPORT    EQU    00H        ; Baud rate generator port
  19. ;
  20. MDRCV    EQU    1        ; Modem receive ready bit
  21. MDSND    EQU    4        ; Modem send ready bit
  22. MDDCD    EQU    8        ; Data carrier detect
  23. ;
  24. ;
  25. ; Divisors for the 8116 baudrate generator
  26. ;
  27. BD300    EQU    5        ; 300 baud
  28. BD1200    EQU    7        ; 1200 bps
  29. BD2400    EQU    10        ; 2400 bps
  30. ;
  31. ;
  32. ;-----------------------------------------------------------------------
  33. ;
  34. ; See if we still have a carrier - if not, return with the zero flat set
  35. ;
  36. MDCARCK:MVI    A,10H        ; Reset status
  37.     OUT    MDCTL1
  38.     IN    MDCTL1        ; Get status
  39.     ANI    MDDCD        ; Check for carrier
  40.     RET
  41. ;.....
  42. ;
  43. ;
  44. ; Disconnect and wait for an incoming call
  45. ;
  46. MDINIT:    MVI    A,0        ; Setup to write register 0
  47.     OUT    MDCTL1
  48.     MVI    A,18H        ; Reset channel
  49.     OUT    MDCTL1
  50. ;
  51.     MVI    A,4        ; Setup to write register 4
  52.     OUT    MDCTL1
  53.     MVI    A,44H        ; Set 16x, 1 stop bit, no parity
  54.     OUT    MDCTL1
  55. ;
  56.     MVI    A,3        ; Setup to write register 3
  57.     OUT    MDCTL1
  58.     MVI    A,0C1H        ; 8 bits, Rx enable
  59.     OUT    MDCTL1
  60. ;
  61.     MVI    A,5        ; Setup to write register 5
  62.     OUT    MDCTL1
  63.     MVI    A,68H        ; DTR off
  64.     OUT    MDCTL1
  65. ;
  66.     PUSH    B        ; Save in case it's being used elsewhere
  67.     MVI    B,20        ; 2 second delay to drop any carrier
  68. ;
  69. OFFTI:    CALL    DELAY        ; 1 second delay
  70.     DCR    B
  71.     JNZ    OFFTI        ; Keep looping until finished
  72.     POP    B        ; Restore 'BC'
  73. ;
  74.     MVI    A,5        ; Setup to write register 5
  75.     OUT    MDCTL1
  76.     MVI    A,0E8H        ; Turn DTR back on
  77.     OUT    MDCTL1
  78. ;
  79.      IF    IMODEM        ; If using an intellegent modem
  80.     CALL    IMINIT        ; Go initialize it now
  81.      ENDIF            ; IMODEM
  82. ;
  83.     RET
  84. ;.....
  85. ;
  86. ;
  87. ; Input a character from the modem port
  88. ;
  89. MDINP:    IN    PORT        ; Get character
  90.     RET
  91. ;.....
  92. ;
  93. ;
  94. ; Check the status to see if a character is available.  If not, return
  95. ; with the zero flag set.  If yes, use 0FFH to clear the flag.
  96. ;
  97. MDINST:    IN    MDCTL1        ; Get status
  98.     ANI    MDRCV        ; Got a character
  99.     RZ            ; Return if none
  100.     ORI    0FFH        ; Otherwise set the proper flag
  101.     RET
  102. ;.....
  103. ;
  104. ;
  105. ; Send a character to the modem
  106. ;
  107. MDOUTP:    OUT    PORT        ; Send it
  108.     RET
  109. ;.....
  110. ;
  111. ;
  112. ; See if the output is ready for another character
  113. ;
  114. MDOUTST:IN    MDCTL1        ; Get status
  115.     ANI    MDSND        ; Ready for a character?
  116.     RET
  117. ;.....
  118. ;
  119. ;
  120. ; Reinitialize the modem and hang up the phone by dropping DTR and
  121. ; leaving it inactive.
  122. ;
  123. MDQUIT:     IF    IMODEM
  124.     CALL    IMQUIT
  125.      ENDIF            ; IMODEM
  126. ;
  127. ;
  128. ; Called by the main program after caller types BYE
  129. ;
  130. MDSTOP:    MVI    A,5        ; Setup to write register 5
  131.     OUT    MDCTL1
  132.     MVI    A,68H        ; Turn off DTR until next time
  133.     OUT    MDCTL1
  134.     RET
  135. ;.....
  136. ;
  137. ;
  138. ; The following routine sets the baud rate.  BYE5 asks for the maximum
  139. ; speed you have available.
  140. ;
  141. SETINV:    ORI    0FFH        ; Make sure zero flag is not set
  142.     RET
  143. ;.....
  144. ;
  145. ;
  146. SET300:    MVI    A,BD300
  147.     JMP    SETBAUD
  148. ;
  149. SET1200:MVI    A,BD1200
  150.     JMP    SETBAUD
  151. ;
  152. SET2400:MVI    A,BD2400
  153. ;
  154. ;
  155. ; Sets the baudrate
  156. ;
  157. SETBAUD:OUT    BRPORT
  158.     XRA    A        ; Say baudrate is ok
  159.     RET
  160. ;.....
  161. ;
  162. ;                   end
  163. ------------------------------------------------------------------------
  164.