home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / cpm / bye3 / b3dp-2.iqs / B3DP-2.INS
Text File  |  1985-11-17  |  4KB  |  151 lines

  1.  
  2. ; B3DP-2.INS  -  BYE3 insert for Datapoint 1560  -  07/30/85
  3. ;
  4. ;        8251A and 8430 CTC timer 3.6864 MHz
  5. ;
  6. ;          Note:  This is an insert, not an overlay
  7. ;
  8. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  9. ;
  10. ; 07/30/85 Restored to original format        - pst
  11. ; 11/25/84 Created                - Irv Hoff
  12. ;
  13. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  14. ;
  15. ; The following define the port addresses to use
  16. ;
  17. DPORT    EQU    28H        ; Modem base port
  18. SPORT    EQU    DPORT+1        ; Modem control port
  19. RBPORT    EQU    20H        ; Receive speed CTC port
  20. TBPORT    EQU    1AH        ; Transmit speed CTC port
  21. ;
  22. DAV    EQU    00000010B    ; Data available
  23. TBMT    EQU    00000001B    ; Transmit buffer empty
  24. DCD    EQU    10000000B    ; Data carrier detect
  25. ;
  26. RESET    EQU    00111000H    ; Framing, overrun and parity errors
  27. ;
  28. MDMODE    EQU    10000010H    ; Insures 8251 is out of mode, DTR high
  29. MDRSET    EQU    01000010H    ; Resets USART for additional commands
  30. MDSET1    EQU    01001110H    ; 1 stop bit, no parity, 8 bits, x16
  31. MDSET2    EQU    11001110H    ; 2 stop bits, no parity, 8 bits, x16
  32. ;
  33. ; The following are CTC timer baud rates divisors.
  34. ;
  35. BD300    EQU    32        ; 9600/300  =  300 bps
  36. BD1200    EQU    8        ; 9600/1200 = 1200 bps
  37. BD2400    EQU    4        ; 9600/2400 = 2400 bps
  38. ;
  39. ;-----------------------------------------------------------------------
  40. ;
  41. ; See if we still have a carrier - if not, return with the zero flag set
  42. ;
  43. MDCARCK:IN    SPORT        ; Get status
  44.     ANI    DCD        ; Check DSR for carrier from modem
  45.     RZ
  46.     ORI    255
  47.     RET
  48. ;
  49. ; Disconnect and wait for an incoming call.
  50. ;
  51. MDINIT:    MVI    A,10H        ; Clear DTR
  52.     OUT    SPORT        ; Causing hangup
  53. ;
  54.     PUSH    B        ; Preserve in case we need it
  55.     MVI    B,20        ; 2 seconds to drop DTR
  56. OFFTI:    CALL    DELAY        ; 0.1 second delay
  57.     DCR    B
  58.     JNZ    OFFTI        ; Keep waiting until carrier drops
  59.     POP    B        ; Restore BC
  60. ;
  61.     MVI    A,MDMODE    ; Insure 8251 is out of mode
  62.     OUT    SPORT
  63.     XTHL            ; Delay a little
  64.     XTHL            ; Delay a little
  65.     MVI    A,MDRSET    ; Reset the 8251A for new command
  66.     OUT    SPORT
  67.     XTHL
  68.     XTHL
  69.     MVI    A,MDSET1    ; Set stop pulse, no parity 8 bits, x16
  70.     OUT    SPORT
  71.     XTHL
  72.     XTHL
  73.     MVI    A,17H        ; Reset error flags, RCV, DTR, TX ready
  74.     OUT    SPORT
  75.     XTHL
  76.     XTHL
  77. ;
  78.      IF    IMODEM
  79.     CALL    IMINIT        ; Initialize smartmodem
  80.      ENDIF            ; IMODEM
  81. ;
  82.     RET
  83. ;
  84. ; Input a character from the modem port
  85. ;
  86. MDINP:    IN    DPORT        ; Get character
  87.     RET
  88. ;
  89. ; Check the status to see if a character is available.    if not, return
  90. ; with the zero flag set.  If yes, use 0FFH to clear the flag.
  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    RESET        ; Check for framing and overrun
  97.     JZ    MDINST1        ; No errors
  98.     MVI    A,17H        ; 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. ; Send a character to the modem
  107. ;
  108. MDOUTP:    OUT    DPORT        ; Send it
  109.     RET
  110. ;
  111. ; See if the output is ready for another character
  112. ;
  113. MDOUTST:IN    SPORT
  114.     ANI    TBMT
  115.     RET
  116. ;
  117. ; Renitialize the modem and hang up the phone by dropping DTR and
  118. ; leaving it inactive.
  119. ;
  120. MDQUIT:     IF    IMODEM
  121.     CALL    IMQUIT
  122.      ENDIF            ; IMODEM
  123. ;
  124. ; Called by the main program after caller types BYE
  125. ;
  126. MDSTOP:    MVI    A,10H        ; DTR low hangs up phone, keep DTR low
  127.     OUT    SPORT        ;   so will not auto-answer at any time
  128.     RET
  129. ;
  130. ; The following routine sets the baudrte.  BYE3 asks for the maximum
  131. ; speed you have available.
  132. ;
  133. SET300:    MVI    B,BD300        ; Load 300 baud
  134.     JMP    SETSPD
  135. ;
  136. SET1200:MVI    B,BD1200    ; Load 1200 baud
  137.     JMP    SETSPD
  138. ;
  139. SET2400:MVI    B,BD2400    ; Load 2400 baud
  140. ;
  141. SETSPD:    MVI    A,47H        ; First byte of baudrate
  142.     OUT    RBPORT
  143.     OUT    TBPORT
  144.     MOV    A,B        ; Second byte of baudrate
  145.     OUT    RBPORT
  146.     OUT    TBPORT
  147.     XRA    A        ; Say it is ok
  148.     RET
  149. ;                   end
  150. ;-----------------------------------------------------------------------
  151.