home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / cpm / bye3 / b3zb-3.ins < prev    next >
Text File  |  1994-07-13  |  5KB  |  165 lines

  1. ; B3ZB-3.INS    - Bye3 / Zorba routines for BYE     - 08/06/85
  2. ;
  3. ;    This version is for a 8251a i/o with ctc timer to set speed
  4. ;
  5. ;    These routines will allow the easy patching of bye3 for any
  6. ; type of modem/serial port combination.  certain routines must return
  7. ; status flags, so please be careful to set the flags as directed.
  8. ;
  9. ; This version is for the intel 8251 chip that is hooked up to an
  10. ; external modem.
  11. ;
  12. ;=======================================================================
  13. ;
  14. ; 08/06/85  Upgraded for bye337             - pst
  15. ; 07/09/85  Modified to work with bye335        - f.e. clayton
  16. ; 10/04/82  Routines added, no fuss, mess, or frills.    - pst
  17. ;
  18. ;=======================================================================
  19. ;
  20. ; The following define the port address to use.
  21. ;
  22. BASEP    EQU    20H        ; Modem base port
  23. DPORT    EQU    BASEP        ; Data port
  24. SPORT    EQU    BASEP+1        ; Status/Control port
  25. CTCCMD    EQU    003H        ; Timer control/status port
  26. CTC0    EQU    000H        ; Timer 0 (port A)
  27. LSB1200    EQU    0D0H
  28. MSB1200    EQU    000H
  29. ;
  30. ; the following are sport commands (output these to sport)
  31. ;
  32. MODINS    EQU    01001110B    ; 8 bits, no parity, 1 stop bit, 16x
  33. OFFINS    EQU    00010000B    ; Drop DTR and disable RCV/XMT
  34. ONINS    EQU    00010111B    ; Reset flags, send DTR, enable rx & tx
  35. RSTINS    EQU    01000010B    ; Reset USART and send DTR
  36. ;
  37. ; the following are sport status masks
  38. ;
  39. TBMT    EQU    00000001B    ; Transmitt buffer empty
  40. DAV    EQU    00000010B    ; Data available
  41. DCD    EQU    10000000B    ; Data carrier detect
  42. FE    EQU    00100000B    ; Framing error
  43. OE    EQU    00010000B    ; Overrun error
  44. PE    EQU    00001000B    ; Parity error
  45. ERR    EQU    00111000B    ; Overrun and framing error
  46. ;
  47. BD300    EQU    0683H        ; 300 baud
  48. BD1200    EQU    01A1H        ; 1200 baud
  49. BD2400    EQU    00D0H        ; 2400 baud
  50. ;
  51. ;----------------------------------------------------------------
  52. ;
  53. ; Initialize modem
  54. ;
  55. MDINIT:    MVI    A,OFFINS    ; Clear DTR
  56.     OUT    SPORT        ; Causing hangup
  57. ;
  58.     PUSH    B        ; Preserve in case we need it
  59.     MVI    B,20
  60. OFFTI:    CALL    DELAY        ; 0.1 second delay
  61.     DCR    B
  62.     JNZ    OFFTI        ; Keep looping until finnished
  63.     POP    B        ; Restore BC
  64. ;
  65.     MVI    A,ONINS        ; DTR so that modem can answer phone
  66.     OUT    SPORT
  67.     CALL    SET1200
  68. ;
  69.      IF    IMODEM
  70.     CALL    IMINIT        ; Init modem
  71.      ENDIF
  72. ;
  73.     RET
  74. ;
  75. ; The following routine sets dtr low to turn off the modem when done.
  76. ;
  77. MDQUIT:
  78.      IF    IMODEM
  79.     CALL    IMQUIT
  80.     RET
  81.      ENDIF
  82. ;
  83. MDSTOP:    MVI    A,10H
  84.     OUT    SPORT        ; Turn off DTR to hang up the phone
  85.     RET
  86. ;
  87. ; The following is a routine to determine if there is a character wait-
  88. ; ing to be received,  if none, the zero flag will be set, otherwise it
  89. ; returns with 255 in register A.  Remember that the system will like you
  90. ; a little more if you also mask out framing, parity, and overrun errors.
  91. ;
  92. MDINST:    IN    SPORT        ; Get status
  93.     ANI    DAV        ; Got a character?
  94.     RZ            ; Return if none
  95.     IN    SPORT        ; Get status again
  96.     ANI    ERR        ; Check for framing and overrun
  97.     JZ    MDINST1        ; No errors
  98.     MVI    A,ONINS        ; Reset error flags
  99.     OUT    SPORT
  100.     XRA    A        ; Return false
  101.     RET
  102. ;
  103. MDINST1:ORI    255        ; We have a character
  104.     RET
  105. ;
  106. ; The following is a routine to determine if the transmit buffer is
  107. ; empty.  If it is, it will return with the zero flag clear.  If the
  108. ; transmitter is busy, then it will return with the zero flag set.
  109. ;
  110. MDOUTST:IN    SPORT
  111.     ANI    TBMT
  112.     RZ
  113.     ORI    255
  114.     RET
  115. ;
  116. ; The following is a routine that will check to make sure we still have
  117. ; carrier.  If there is no carrier, it will return with the zero flag
  118. ; set.
  119. ;
  120. MDCARCK:IN    SPORT        ; Get status
  121.     ANI    DCD        ; Check if carrier is on
  122.     RZ
  123.     ORI    255
  124.     RET
  125. ;
  126. ; The following is a routine that will input one character from the
  127. ; modem port.  If there is nothing there, it will return garbage...
  128. ; So use the mdinst routine first.
  129. ;
  130. MDINP:    IN    DPORT        ; Get character
  131.     RET
  132. ;
  133. ; The following is a routine that will output one character in register
  134. ; a to the modem.  Remember, that is register A, not register C.
  135. ;
  136. ; ** use MDOUTST first to see if buffer is empty **
  137. ;
  138. MDOUTP:    OUT    DPORT        ; Send it
  139.     RET
  140. ;
  141. ; These next routines set the proper baud rates for the modem.
  142. ;
  143. SET300:    LXI    H,BD300        ; Set 300 baud
  144.     JMP    LOADBD
  145. ;
  146. SET1200:LXI    H,BD1200    ; Set 1200 baud
  147.     JMP    LOADBD
  148. ;
  149. SET2400:LXI    H,BD2400    ; Set 2400 baud
  150.     JMP    LOADBD
  151. ;
  152. LOADBD:    MVI    A,36H        ; Set command mode
  153.     OUT    CTCCMD
  154.     NOP    ! NOP !    NOP
  155.     MOV    A,L        ; Send LSB of baud
  156.     OUT    CTC0
  157.     NOP    ! NOP !    NOP
  158.     MOV    A,H        ; Send MSB of baud
  159.     OUT    CTC1
  160.     NOP    ! NOP !    NOP
  161.     XRA    A        ; Return saying we're ok
  162.     RET
  163. ;
  164. ;***********************************************************************
  165.