home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / sigm / vol218 / mxo-sm14.aqm / MXO-SM14.ASM
Encoding:
Assembly Source File  |  1986-02-09  |  9.3 KB  |  303 lines

  1.     TITLE    'MEX SMARTMODEM OVERLAY V1.3'
  2. ;
  3. ; (DELETE ABOVE TITLE LINE IF ASSEMBLING WITH ASM)
  4. ;
  5. ; Smartmodem overlay for MEX: revision 1.3
  6. ; Written 04/16/84 by Ronald G. Fowler (V1.0)
  7. ;
  8. ; 09/05/84: Added option to check DCD to determine if a connection has
  9. ;           been made. THIS IS MACHINE SPECIFIC. Also, Switch 6 on the
  10. ;           Smartmodem should be UP. (David Jewett)
  11. ;
  12. ; 07/16/84: Added equate NUMRES to enable/disable numeric result code 
  13. ;        interpretation.  Under TurboDos, the first digit of the 
  14. ;        phone number was being interpreted as a result code as it 
  15. ;        was echoed by the Anchor modem as it dialed.  Set NUMRES false
  16. ;        to disable numeric results. (Bob Puckett)
  17. ;
  18. ; 06/06/84: Fixed problem for Anchor users, where, when the modem returned
  19. ;        "DIAL TONE", the "N" in "TONE" was being regarded as a NO-CONNECT
  20. ;        code.  Now we flush the entire result line before reading another.
  21. ;        Also added code for numeric version of "CONNECT 1200".  --RGF
  22. ;
  23. ; Small bug repaired: (V1.1) 05/14/84 (Steve Grandi): Smartmodem was not being 
  24. ;    flushed after a dial string so that last digit of the phone number 
  25. ;    was being interpreted as a numeric result code causing the program, 
  26. ;    for certain numbers, to give up even as the modem merrily dialed away.
  27. ;
  28. ; This modules adapts MEX for the DC Hayes Smartmodem (as well
  29. ; as many others -- including US Robotics -- that use a similar
  30. ; command language). The main function of this module is to pro-
  31. ; vide dialing capability; the disconnect vector is ancillary.
  32. ; You may use this module as a model to develop dialing routines
  33. ; for non-standard modems (e.g., the Racal-Vadic).  The only
  34. ; pertinent entry point is the DIAL routine; you'll find entry
  35. ; specs for that below.
  36. ;
  37. ; The only conditional you might want to change in this
  38. ; module is the DISC equate below -- if left on, MEX will
  39. ; use the Smartmodem's disconnect code.  If you prefer to
  40. ; provide your own in your overlay's DISCV vector (e.g.,
  41. ; by dropping DTR), then set DISC to FALSE and re-assemble.
  42. ; (If you don't understand this, then play it safe, and
  43. ; leave the equate set as it is).
  44. ;
  45. ; This overlay will work with any modem overlay that terminates
  46. ; prior to 0B00H
  47. ;
  48. FALSE    EQU    0
  49. TRUE    EQU    NOT FALSE
  50. ;
  51. ;
  52. NUMRES    EQU    FALSE        ; TRUE = INTERPRET NUMERIC RESULT CODES
  53.                 ; FALSE = IGNORE NUMERIC RESULT CODES
  54.  
  55. DCD    EQU    FALSE        ; TRUE = CHECK DCD FOR CARRIER
  56.     IF    DCD        ; if using DCD, we must know the following:
  57. STPORT    EQU    0EDH        ; ... Status Port assignment to get DCD
  58. DCDBIT    EQU    0100$0000b    ; ... Bit HIGH to test for DCD
  59.     ENDIF    ; DCD
  60. ;
  61. DISC    EQU    TRUE        ;<<== CHANGE TO FALSE IF YOU DISC. WITH DTR
  62. ;
  63. ; SYSTEM CONSTANTS
  64. ;
  65. TPULSE    EQU    0105H        ;TONE/PULSE FLAG IN MODEM OVERLAY
  66. DIALV    EQU    0162H        ;LOCATION OF DIAL VECTOR IN OVERLAY
  67. DISCV    EQU    0165H        ;LOCATION OF DISCONNECT VECTOR IN OVERLAY
  68. DIALOC    EQU    0B00H        ;DIALING CODE GOES HERE
  69. MEX    EQU    0D00H        ;"CALL MEX"
  70. ;
  71. ; FOLLOWING ARE FUNCTION CODES FOR THE MEX SERVICE CALL PROCESSOR
  72. ;
  73. INMDM    EQU    255        ;RETURN CHAR FROM MDM IN A, CY=NO CHR IN 100MS
  74. TIMER    EQU    254
  75. TMDINP    EQU    253        ;B=# SECS TO WAIT FOR CHAR, CY=NO CHAR
  76. CHEKCC    EQU    252        ;CHECK FOR ^C FROM KBD, Z=PRESENT
  77. SNDRDY    EQU    251        ;TEST FOR MODEM-SEND READY
  78. RCVRDY    EQU    250        ;TEST FOR MODEM-RECEIVE READY
  79. SNDCHR    EQU    249        ;SEND A CHARACTER TO THE MODEM (AFTER SNDRDY)
  80. RCVCHR    EQU    248        ;RECV A CHAR FROM MODEM (AFTER RCVRDY)
  81. ;
  82. CR    EQU    13
  83. LF    EQU    10
  84. ;
  85. ;
  86. ;
  87.     ORG    DIALV        ;OVERLAY THE DIALING VECTOR
  88.     JMP    DIAL
  89. ;    
  90.     IF    DISC        ;IF PROVIDING DISCONNECT CODE
  91.     ORG    DISCV        ;OVERLAY THE VECTOR
  92.     JMP    DISCON
  93.     ENDIF
  94. ;
  95. ; This is the DIAL routine called by MEX to dial a digit. The digit
  96. ; to be dialed is passed in the A register.  Note that two special
  97. ; codes must be intercepted as non-digits: 254 (start dial sequence)
  98. ; and 255 (end-dial sequence).  Mex will always call DIAL with 254
  99. ; in the accumulator prior to dialing a number.  Mex will also call
  100. ; dial with 255 in A as an indication that dialing is complete. Thus,
  101. ; the overlay may use these values to "block" the number, holding it
  102. ; in a buffer until it is completely assembled (in fact, that's the
  103. ; scheme employed here for the Smartmodem).
  104. ;
  105. ; After the 254-start-dial sequence, MEX will call the overlay with
  106. ; digits, one-at-a-time.  MEX will make no assumptions about the dig-
  107. ; its, and will send each to the DIAL routine un-inspected (some modems,
  108. ; like the Smartmodem, allow special non-numeric characters in the
  109. ; phone number, and MEX may make no assumptions about these).
  110. ;
  111. ; After receiving the end-dial sequence (255) the overlay must take
  112. ; whatever end-of-dial actions are necessary *including* waiting for
  113. ; carrier at the distant end.  The overlay should monitor the keyboard
  114. ; during this wait (using the MEX keystat service call), and return
  115. ; an exit code to MEX in the A register, as follows:
  116. ;
  117. ;    0 - Carrier detected, connection established
  118. ;    1 - Far end busy (only for modems that can detect this condition)
  119. ;    2 - No answer (or timed out waiting for modem response)
  120. ;    3 - Keyboard abort (^C only: all others should be ignored)
  121. ;    4 - Error reported by modem
  122. ;
  123. ; <No other codes should be returned after an end-dial sequence>
  124. ;
  125. ; The overlay should not loop forever in the carrier-wait routine, but
  126. ; instead use either the overlay timer vector, or the INMDMV (timed 100
  127. ; ms character wait) service call routine.
  128. ;
  129. ; The DIAL routine is free to use any of the registers, but must return
  130. ; the above code after an end-dial sequence
  131. ;
  132.     ORG    DIALOC
  133. ;
  134. DIAL:    LHLD    DIALPT        ;FETCH POINTER
  135.     CPI    254        ;START DIAL?
  136.     JZ    STDIAL        ;JUMP IF SO
  137.     CPI    255        ;END DIAL?
  138.     JZ    ENDIAL        ;JUMP IF SO
  139. ;
  140. ; Not start or end sequence, must be a digit to be sent to the modem
  141. ;
  142.     MOV    M,A        ;PUT CHAR IN BUFFER
  143.     INX    H        ;ADVANCE POINTER
  144.     SHLD    DIALPT        ;STUFF PNTR
  145.     RET            ;ALL DONE
  146. ;
  147. ; Here on a start-dial sequence
  148. ;
  149. STDIAL:    LXI    H,DIALBF    ;SET UP BUFFER POINTER
  150.     SHLD    DIALPT
  151.     RET
  152. ;
  153. ; Here on an end-dial sequence
  154. ;
  155. ENDIAL:    MVI    M,CR        ;STUFF END-OF-LINE INTO BUFFER
  156.     INX    H        ;FOLLOWED BY TERMINATOR
  157.     MVI    M,0
  158.     LDA    TPULSE        ;GET OVERLAY'S TOUCH-TONE FLAG
  159.     STA    SMDIAL+3    ;PUT INTO STRING
  160.     LXI    H,SMDIAL    ;POINT TO DIALING STRING
  161.     CALL    SMSEND        ;SEND IT
  162. WAITSM:    MVI    C,INMDM
  163.     CALL    MEX        ;CATCH ANY OUTPUT FROM THE MODEM
  164.     JNC    WAITSM        ;LOOP UNTIL NO MORE CHARACTERS
  165. ;
  166. ; THE FOLLOWING LOOP WAITS FOR A RESULT FROM THE MODEM (UP TO
  167. ; 60 SECONDS: YOU MAY CHANGE THIS VALUE IN THE FOLLOWING LINE).
  168. ; NOTE THAT THE SMARTMODEM HAS AN INTERNAL 30 SECOND TIMEOUT WHILE
  169. ; FOR A CARRIER ON THE OTHER END.  YOU CAN CHANGE BY PLAYING WITH THE
  170. ; S7 VARIABLE (I.E. SEND THE SMARTMODEM "AT S7=20" TO LOWER THE 30 SECOND
  171. ; WAIT TO 20 SECONDS).
  172. ;
  173. RESULT:    MVI    C,60        ;<<== MAXIMUM TIME TO WAIT FOR RESULT
  174. SMWLP:    PUSH    B
  175.     MVI    B,1        ;CHECK FOR A CHAR, UP TO 1 SEC WAIT
  176.     MVI    C,TMDINP    ;DO TIMED INPUT
  177.     CALL    MEX
  178.     POP    B
  179.     JNC    SMTEST        ;JUMP IF MODEM HAD A CHAR
  180. ;
  181.     IF    DCD        ;if DCD is available, take a look at it
  182.     IN    STPORT        ;   get the status byte
  183.     ANI    DCDBIT        ;   and test the DCD flag
  184.     XRI    DCDBIT        ;   return with A=0 if found,
  185.     RZ            ;but otherwise ...
  186.     ENDIF    ;DCD
  187. ;
  188.     PUSH    B        ; TEST FOR CONTROL-C FROM CONSOLE
  189.     MVI    C,CHEKCC
  190.     CALL    MEX
  191.     POP    B
  192.     JNZ    SMNEXT        ;IF NOT, JUMP
  193.     MVI    B,CR        ;YES, SHUT DOWN THE MODEM
  194.     MVI    C,SNDCHR
  195.     CALL    MEX
  196.     MVI    A,3        ;RETURN ABORT CODE
  197.     RET
  198. SMNEXT:    DCR    C        ;NO
  199.     JNZ    SMWLP        ;CONTINUE
  200. ;
  201. ; ONE MINUTE WITH NO MODEM RESPONSE (OR NO CONNECTION)
  202. ;
  203. SMTIMO:    MVI    A,2        ;RETURN TIMEOUT CODE
  204.     RET
  205. ;
  206. ; MODEM GAVE US A RESULT, CHECK IT
  207. ;
  208. SMTEST:    ANI    7FH        ;IGNORE ANY PARITY
  209.     CALL    SMANAL        ;TEST THE RESULT
  210.     MOV    A,B        ;A=RESULT (CY SIGNIFICANT HERE TOO)
  211.     PUSH    PSW        ;SAVE IT
  212. SMTLP:    MVI    C,INMDM        ;FLUSH ANY REMAINING COMMAND LINE
  213.     CALL    MEX
  214.     JC    SMCHEK        ;JUMP IF NO INPUT
  215.     CPI    LF        ;GOT SOME ... WAITING FOR EOL
  216.     JNZ    SMTLP        ;EAT ANY IN-BETWEEN
  217. SMCHEK:    POP    PSW        ;A HAS MEX RETURN-CODE, CY=1 IF UNKNOWN
  218.     JC    RESULT        ;IF RESULT UNKNOWN, IGNORE IT
  219.     RET
  220. ;
  221. SMANAL:    MVI    B,0        ;PREP CONNECT CODE
  222.     CPI    'C'        ;"CONNECT"?
  223.     RZ
  224.  
  225.     IF     NUMRES
  226.     CPI    '1'        ;NUMERIC VERSION OF "CONNECT"
  227.     RZ
  228.     CPI    '5'        ;NUMERIC VERSION OF "CONNECT 1200"
  229.     RZ
  230.     ENDIF
  231.  
  232.     INR    B        ;PREP BUSY CODE B=1
  233.     CPI    'B'
  234.     RZ
  235.     INR    B        ;PREP NO CONNECT MSG B=2
  236.     CPI    'N'        ;N=NO CONNECT
  237.     RZ
  238.  
  239.     IF     NUMRES
  240.     CPI    '3'        ;NUMERIC VERSION OF "NO CONNECT"
  241.     RZ
  242.     ENDIF
  243.  
  244.     MVI    B,4        ;PREP MODEM ERROR
  245.     CPI    'E'        ;E=ERROR
  246.     RZ
  247.  
  248.     IF    NUMRES
  249.     CPI    '4'        ;NUMERIC VERSION OF "ERROR"
  250.     RZ
  251.     ENDIF
  252.  
  253.     STC            ;UNKNOWN...
  254.     RET
  255. ;
  256. ; FOLLOWING ROUTINE DISCONNECTS THE MODEM USING SMARTMODEM
  257. ; CODES. ALL REGISTERS ARE AVAILABLE FOR THIS FUNCTION.
  258. ; NOTHING RETURNED TO CALLER.
  259. ;
  260.     IF    DISC
  261. ;
  262. DISCON:    MVI    B,20
  263.     MVI    C,TIMER        ;WAIT 2 SECONDS
  264.     CALL    MEX
  265.     LXI    H,SMATN        ;SEND '+++'
  266.     CALL    SMSEND
  267.     MVI    B,20        ;WAIT 2 MORE SECONDS
  268.     MVI    C,TIMER
  269.     CALL    MEX
  270.     LXI    H,SMDISC    ;SEND 'ATH'
  271.     CALL    SMSEND
  272.     MVI    B,1        ;WAIT 1 SECOND
  273.     MVI    C,TIMER
  274.     CALL    MEX
  275.     RET
  276. ;
  277. SMATN:    DB    '+++',0
  278. SMDISC:    DB    'ATH',CR,0
  279. ;
  280.     ENDIF
  281. ;
  282. ; SMARTMODEM UTILITY ROUTINE: SEND STRING TO MODEM
  283. ;
  284. SMSEND:    MVI    C,SNDRDY    ;WAIT FOR MODEM READY
  285.     CALL    MEX
  286.     JNZ    SMSEND
  287.     MOV    A,M        ;FETCH NEXT CHARACTER
  288.     INX    H
  289.     ORA    A        ;END?
  290.     RZ            ;DONE IF SO
  291.     MOV    B,A        ;NO, POSITION FOR SENDING
  292.     MVI    C,SNDCHR    ;NOPE, SEND THE CHARACTER
  293.     CALL    MEX
  294.     JMP    SMSEND
  295. ;
  296. ; DATA AREA
  297. ;
  298. SMDIAL:    DB    'ATDT '
  299. DIALBF:    DS    52        ;2* 24 CHAR MAX, + CR + NULL + SLOP
  300. DIALPT:    DS    2        ;DIAL POSITION POINTER
  301. ;
  302.     END
  303.