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 / B5TVH-2.INS < prev    next >
Text File  |  2000-06-30  |  5KB  |  213 lines

  1.  
  2. ; B5TVH-2.INS  -  BYE5 insert for TeleVideo 803H computers  -  03/27/86
  3. ;
  4. ;        Mostek 3801 and CTC timer (3.6864 MHz)
  5. ;
  6. ;        Note: This is an insert, not an overlay.
  7. ;
  8. ; This version is for a TeleVideo 803H using an interrupt-driven Mostek
  9. ; Mostek 3801 STI.
  10. ;
  11. ; These routines will allow the easy patching of BYE5xx for any type of
  12. ; of modem/serial port combination.  Certain routines must return status
  13. ; flags, so please be careful to set the flags as directed.
  14. ;
  15. ; This version is for the TeleVideo 803H that is hooked up to an exter-
  16. ; nal modem.
  17. ;
  18. ;-----------------------------------------------------------------------
  19. ;
  20. ; 06/11/86  Added 2400 bps capability, changed to BYE5 format from MBYE.
  21. ;                    - Irv Hoff
  22. ;
  23. ; 03/27/86  Created from MBTV-10.ASM    - Ian Cottrell
  24. ;
  25. ;-----------------------------------------------------------------------
  26. ;
  27. ; Change the following information to match your equipment
  28. ;
  29. PORT    EQU    2FH        ; Modem data port
  30. MDSND    EQU    PORT-1        ; Modem send status register
  31. MDRCV    EQU    PORT-2        ; Modem receive status register
  32. MDCTL    EQU    PORT-3        ; MOdem control register
  33. IOPORT    EQU    20H        ; Modem general purpose I/O port
  34. INTREG    EQU    27H        ; Modem interrupt register
  35. MDPVR    EQU    28H        ; Modem pointer/vector register
  36. TIMER    EQU    29H        ; Modem timer A & B control register
  37. BDPORT    EQU    2BH        ; CTC port for baud rate
  38. ;
  39. MDRDY    EQU    80H        ; Value for receive/send ready
  40. SPSTAT    EQU    21H        ; Parameter status register
  41. ;
  42. BD300    EQU    32        ; 300 baud (9600/300 converted to hex)
  43. BD1200    EQU    8        ; 1200 baud (9600/1200 converted to hex)
  44. BD2400    EQU    4        ; 2400 baud (9600/2400 converted to hex)
  45. ;
  46. ;-----------------------------------------------------------------------
  47. ;
  48. ; See if we still have a carrier - if not, return with the zero flag set
  49. ; Reg A is zero if no carrier, non-zero if carrier
  50. ;
  51. MDCARCK:IN    SPSTAT        ; Read status register
  52.     ANI    01H        ; Check for carrier detect
  53.     XRI    01H        ; Ready if bit 0 = 0
  54.     RET
  55. ;.....
  56. ;
  57. ;
  58. ; Disconnect and wait for an incoming call
  59. ;
  60. MDINIT:    PUSH    H        ; Save regs
  61.     PUSH    D
  62.     PUSH    B
  63.     IN    TIMER        ; Read current timer value
  64.     STA    TABD
  65.     IN    MDPVR        ; Get STI interrupt vector
  66.     ANI    0E0H        ; And mask off don't care bits
  67.     MOV    B,A        ; Save it in B
  68.     ORI    6        ; Point to indirect reg # 6
  69.     OUT    MDPVR
  70.     MVI    A,04H        ; Set RTS
  71.     OUT    IOPORT
  72.     XRA    A        ; Set handshake lines
  73.     OUT    SPSTAT
  74.     MOV    A,B        ; Restore STI interrupt vector
  75.     ORI    7        ; Point to indirect reg # 7
  76.     OUT    MDPVR
  77.     IN    IOPORT        ; Read timer C and D regs
  78.     ORI    88H        ; A & B reset; C & D unchanged
  79.     OUT    IOPORT        ; Go do it
  80.     XRA    A        ; Stop timers
  81.     OUT    TIMER
  82. ;
  83. INITBD:    OUT    BDPORT
  84.     LDA    TABD        ; Restart timers
  85.     OUT    TIMER
  86.     MVI    A,88H        ; No parity, 8 bits, 1 stop, x16
  87.     OUT    MDCTL
  88.     MVI    A,1        ; Turn on RXD
  89.     OUT    MDRCV
  90.     MVI    A,5        ; Turn on TXD
  91.     OUT    MDSND
  92.     MVI    A,0FH        ; Turn off interrupts
  93.     OUT    INTREG
  94.     IN    MDPVR        ; Read pointer/vector register
  95.     ANI    0E0H        ; Mask don't care bits
  96.     ORI    6        ; Select indirect register 6
  97.     OUT    MDPVR
  98.     MVI    A,24H        ; Set DTR and RTS
  99.     OUT    IOPORT
  100.     IN    PORT        ; Clear any incoming chars
  101.     IN    PORT        ; Try again
  102.     XRA    A        ; Clear 'A' reg
  103.     POP    B        ; Restore regs
  104.     POP    D
  105.     POP    H
  106.     RET
  107. ;
  108. TABD:    DB    0
  109. ;.....
  110. ;
  111. ;
  112. ; Input a character from the modem port
  113. ;
  114. MDINP:    IN    PORT        ; Get character
  115.     RET
  116. ;.....
  117. ;
  118. ;
  119. ; Check the staus to see if a character is available.  If not, return
  120. ; with the zero flag set.  If yes, use 0FFH to clear the flag.
  121. ;
  122. MDINST:    IN    MDRCV        ; Get status
  123.     ANI    MDRDY        ; Check receive ready bit
  124.     RET
  125. ;.....
  126. ;
  127. ;
  128. ; Send a character to the modem
  129. ;
  130. MDOUTP:    OUT    PORT        ; Send it
  131.     RET
  132. ;.....
  133. ;
  134. ;
  135. ; See if the output is ready for another character
  136. ;
  137. MDOUTST:IN    MDSND
  138.     ANI    MDRDY
  139.     RET
  140. ;.....
  141. ;
  142. ;
  143. ; Reinitialize the modem and hang up the phone by dropping DTR and
  144. ; leaving it inactive
  145. ;
  146. MDQUIT:     IF    IMODEM
  147.     CALL    IMQUIT        ; If a smartmodem, tell it to shut down
  148.      ENDIF            ; IMODEM
  149. ;
  150. ;
  151. ; Called by the main program after caller types BYE
  152. ;
  153. MDSTOP:    IN    MDPVR        ; Read pointer/vector register
  154.     ANI    0E0H        ; Mask don't care bits
  155.     ORI    6        ; Select indirect register 6
  156.     OUT    MDPVR
  157.     MVI    A,04H        ; DTR off; RTS on
  158.     OUT    IOPORT
  159.     RET
  160. ;.....
  161. ;
  162. ;
  163. ; The following routine sets the baudrate.  BYE5 asks for the maximum
  164. ; speed you have available.
  165. ;
  166. SETINV:    ORI    0FFH        ; Make surae trhe flag is not set
  167.     RET
  168. ;
  169. SET300:    MVI    A,BD300        ; 300 baud
  170.     JMP    STBAUD
  171. ;
  172. SET1200:MVI    A,BD1200    ; 1200 bps
  173.     JMP    STBAUD
  174. ;
  175. SET2400:MVI    A,BD2400    ; 2400 bps
  176. ;
  177. STBAUD:    PUSH    PSW        ; Save baud rate
  178.     IN    TIMER        ; Read current timer value
  179.     STA    TABD
  180.     IN    MDPVR        ; Get STI interrupt vector
  181.     ANI    0E0H        ; And mask off don't care bits
  182.     MOV    B,A        ; Save it in B
  183.     ORI    6        ; Point to indirect reg # 6
  184.     OUT    MDPVR
  185.     MVI    A,24H        ; Set DTR and RTS
  186.     OUT    IOPORT
  187.     XRA    A        ; Set handshake lines
  188.     OUT    SPSTAT
  189.     MOV    A,B        ; Restore STI interrupt vector
  190.     ORI    7        ; Point to indirect reg # 7
  191.     OUT    MDPVR
  192.     IN    IOPORT        ; Read timer C and D regs
  193.     ORI    88H        ; A & B reset; C & D unchanged
  194.     OUT    IOPORT        ; Go do it
  195.     XRA    A        ; Stop timers
  196.     OUT    TIMER
  197.     POP    PSW        ; Restore baud rate
  198.     OUT    BDPORT        ; And set it
  199.     LDA    TABD        ; Restart timers
  200.     OUT    TIMER
  201.     MVI    A,88H        ; No parity, 8 bits, 1 stop, x16
  202.     OUT    MDCTL
  203.     MVI    A,1        ; Turn on RXD
  204.     OUT    MDRCV
  205.     MVI    A,5        ; Turn on TXD
  206.     OUT    MDSND
  207.     XRA    A        ; Set zero flag
  208.     RET
  209. ;.....
  210. ;
  211. ;                   end
  212. ;-----------------------------------------------------------------------
  213.