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 / B5ZB-4.INS < prev    next >
Text File  |  2000-06-30  |  4KB  |  194 lines

  1. ;----------------------------------------------------------------------
  2. ; B5ZB-4.INS - BYE5 insert for ZORBA computers - 12/16/85
  3. ;
  4. ;        8251A and Intel 8254-2 timer 3.9936 MHz
  5. ;
  6. ;          Note:  This is an insert, not an overlay
  7. ;
  8. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  9. ;
  10. ; 12/16/85  Removed some redundant code in the 300 baud set routine.
  11. ;          - John Maclean - Instructed and
  12. ;            greatly helped by   - Irv Hoff
  13. ;                 
  14. ; 12/15/85  Rewrote baudrate selectin area to better handle 300 baud.
  15. ;                    - Irv Hoff
  16. ;
  17. ; 12/11/85  Corrected a MVI to a MOV which ASM.COM and MAC.COM missed
  18. ;        reporting as an error.    - Irv Hoff
  19. ;
  20. ; 07/17/85  Written to work with BYE5    - Irv Hoff
  21. ;
  22. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  23. ;
  24. ;
  25. ; The following define the port addresses to use
  26. ;
  27. PORT    EQU    20H        ; Modem base port
  28. MDCTL1    EQU    PORT+1        ; Modem control port
  29. RCVPORT    EQU    20H        ; Receive speed 8254 port
  30. XMTPORT    EQU    1AH        ; Transmit speed 8254 port
  31. ;
  32. MDRCV    EQU    2        ; Modem receive ready bit
  33. MDSND    EQU    1        ; Modem send ready bit
  34. RESET    EQU    38H        ; Framing, overrun and parity errors
  35. ;
  36. MDMODE    EQU    82H        ; Insures 8251 is out of mode, DTR high
  37. MDRSET    EQU    42H        ; Resets USART for additional commands
  38. MDSET1    EQU    4EH        ; 1 stop bit, no parity, 8 bits, x16
  39. MDSET2    EQU    0CEH        ; 2 stop bits, no parity, 8 bits, x16
  40. COMMND    EQU    03H        ; 8254 Timer control/status
  41. BRPORT    EQU    00H        ; Baudrate generator timer 0 (port A)
  42. LSB300    EQU    83H
  43. MSB300    EQU    06H
  44. ;
  45. ;
  46. ; Baudrate table
  47. ;
  48. BD300:    DW    1667        ; 300 baud
  49. BD1200:    DW    417        ; 1200 bps
  50. BD2400:    DW    208        ; 2400 bps
  51. BD9600:    DW    52        ; 9600 bps
  52. ;
  53. ;
  54. ;-----------------------------------------------------------------------
  55. ;
  56. ; See if we still have a carrier - if not, return with the zero flag set
  57. ;
  58. MDCARCK:IN    MDCTL1        ; Get status
  59.     ANI    80H        ; Check DSR for carrier from modem
  60.     RET
  61. ;.....
  62. ;
  63. ;
  64. ; Disconnect and wait for an incoming call.
  65. ;
  66. MDINIT:    MVI    A,10H        ; Clear DTR
  67.     OUT    MDCTL1        ; Causing hangup
  68.     PUSH    B        ; Preserve in case we need it
  69.     MVI    B,20        ; 2 seconds to drop DTR
  70.  
  71. OFFTI:    CALL    DELAY        ; 0.1 second delay
  72.     DCR    B
  73.     JNZ    OFFTI        ; Keep waiting until carrier drops
  74.     POP    B        ; Restore BC
  75.     MVI    A,MDMODE    ; Insure 8251 is out of mode
  76.     OUT    MDCTL1
  77.     XTHL            ; Delay a little
  78.     XTHL            ; Delay a little
  79.     MVI    A,MDRSET    ; Reset the 8251A for new command
  80.     OUT    MDCTL1
  81.     XTHL
  82.     XTHL
  83.     MVI    A,MDSET1    ; Set stop pulse, no parity 8 bits, x16
  84.     OUT    MDCTL1
  85.     XTHL
  86.     XTHL
  87.     MVI    A,17H        ; Reset error flags, RCV, DTR, TX ready
  88.     OUT    MDCTL1
  89.     XTHL
  90.     XTHL
  91. ;
  92.      IF    IMODEM
  93.     CALL    IMINIT        ; Initialize smartmodem
  94.      ENDIF            ; IMODEM
  95. ;
  96.     RET
  97. ;.....
  98. ;
  99. ;
  100. ; Input a character from the modem port
  101. ;
  102. MDINP:    IN    PORT        ; Get character
  103.     RET
  104. ;.....
  105. ;
  106. ;
  107. ; Check the status to see if a character is available.    if not, return
  108. ; with the zero flag set.  If yes, use 0FFH to clear the flag.
  109. ;
  110. MDINST:    IN    MDCTL1        ; Get status
  111.     ANI    MDRCV        ; Got a character?
  112.     RZ            ; Return if none
  113.     IN    MDCTL1        ; Get status again
  114.     ANI    RESET        ; Check for framing and overrun
  115.     JZ    MDINST1        ; No errors
  116.     MVI    A,17H        ; Reset error flags
  117.     OUT    MDCTL1
  118.     XRA    A        ; Return false
  119.     RET
  120. ;...
  121. ;
  122. ;
  123. MDINST1:ORI    0FFH        ; We have a character
  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    MDCTL1
  138.     ANI    MDSND
  139.     RET
  140. ;.....
  141. ;
  142. ;
  143. ; Renitialize the modem and hang up the phone by dropping DTR and
  144. ; leaving it inactive.
  145. ;
  146. MDQUIT:     IF    IMODEM
  147.     CALL    IMQUIT
  148.      ENDIF            ; IMODEM
  149. ;
  150. ;
  151. ; Called by the main program after caller types BYE
  152. ;
  153. MDSTOP:    MVI    A,10H        ; DTR low hangs up phone, keep DTR low
  154.     OUT    MDCTL1        ; So will not auto-answer at any time
  155.     RET
  156. ;.....
  157. ;
  158. ;
  159. ; The following routine sets the baudrate.  BYE-3 asks for the maximum
  160. ; speed you have available.
  161. ;
  162. SETINV:    MVI    A,0FFH
  163.     ORA    A        ; Make sure the Zero flag isn't set
  164.     RET
  165. ;...
  166. ;
  167. ;
  168. SET300:    LHLD    BD300          ; Get value for 300 bps
  169.     JMP     LOADBD        ; Load it
  170. ;
  171. SET1200:LHLD    BD1200        ; Get value for 1200 bps
  172.     JMP    LOADBD        ; Load it
  173. ;
  174. SET2400:LHLD    BD2400        ; Get value for 1200 bps
  175.     JMP    LOADBD        
  176. ;
  177. LOADBD:    MOV    A,L
  178.     STA    LSBD+1
  179.     MOV    A,H
  180.     STA    MSBD+1
  181.     MVI    A,36H
  182.     OUT    COMMND
  183. ;
  184. LSBD:    MVI    A,LSB300
  185.     OUT    BRPORT
  186. ;
  187. MSBD:    MVI    A,MSB300
  188.     OUT    BRPORT
  189.     EI            ; Enable interrupts
  190.     RET
  191. ;.....
  192. ;
  193. ;                   end 
  194. ;-----------------------------------------------------------------------