home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a013 / 1.ddi / SOURCE.EXE / DIAL.ASM < prev    next >
Encoding:
Assembly Source File  |  1991-01-25  |  7.4 KB  |  184 lines

  1. ; ----------------------------------------------------------------
  2. ; FILENAME:   DIAL.ASM
  3. ;
  4. ; FUNCTIONS:
  5. ;
  6. ; DIAL  ---- Transmits passed phone number to modem for dialing
  7. ; DIALCLR -- Clears and resets communications port
  8. ; ----------------------------------------------------------------
  9. ; Copyright(c) 1991 - James Occhiogrosso
  10.  
  11. INCLUDE DEVELOP.MAC      ; Include Developer's Library Macro file
  12.  
  13. PUBLIC   DIAL            ; Declare dialer function
  14. PUBLIC   DIALCLR         ; Declare dialer clear function
  15.  
  16. EXTRN    __PARINFO:FAR   ; Get parameter information
  17. EXTRN    __PARNI:FAR     ; Get numeric integer parameter
  18. EXTRN    __PARL:FAR      ; Get logical parameter
  19. EXTRN    __PARC:FAR      ; Get string parameter
  20. EXTRN    __RETL:FAR      ; Return logic value to Clipper
  21. EXTRN    __RET:FAR       ; Return logic value to Clipper
  22.  
  23.  
  24. DGROUP   GROUP  DATASEG                  ; Clipper's data segment
  25. DATASEG  SEGMENT   PUBLIC '_DATA'
  26.  
  27.          DIAL_STRING  DB  'AT S7=30 D'   ; Dial string
  28.          PULSE_TONE   DB  'T', 0         ; Default to tone dial
  29.          PORT_WORD    DB  83h            ; Default to 1200,N,8,1
  30.          PORT_NUM     DB  0              ; Default port is COM1
  31.          CR_STRING    DB  0Dh, 0         ; End modem command
  32.  
  33.          HANG_UP DB  '~~~+++~~~ATH0', 0Dh, 0  ; Hang-up string
  34.  
  35. DATASEG  ENDS
  36.  
  37. CODESEG  SEGMENT   PUBLIC 'CODE'
  38.          ASSUME CS:CODESEG,DS:DGROUP,ES:DGROUP
  39.  
  40.  
  41. ; ---------------------------------------------------------------
  42. DIAL PROC  FAR                   ; Dial passed telephone number
  43. ; ---------------------------------------------------------------
  44.  
  45. START:
  46.          PUSH_REGS                 ; Save Clipper's registers
  47.  
  48.          P_COUNT                   ; Get number of parameters
  49.          CMP       AX, 0           ; Any parameters passed?
  50.          JE        ERROR           ; No! Return to Clipper
  51.          CMP       AX, 3           ; Yes! Jump to parameter
  52.          JE        SETUP3          ;  handler based on PCOUNT
  53.          CMP       AX, 2           ;
  54.          JE        SETUP2          ;
  55.          JMP       SETUP1          ; Minimum is 1 parameter
  56.  
  57. ERROR:   SUB       AX, AX          ; Clear AX (return false)
  58.          JMP       DONE            ;   and return to Clipper
  59.  
  60. SETUP3:                            ; Parameter 3 - Tone/Pulse
  61.          P_TYPE    3               ; Get its type
  62.          CMP       AX, 4           ; Is it logical?
  63.          JNE       ERROR           ; No!  Return to Clipper
  64.          GET_PARL  3               ; Yes! Get its value
  65.          CMP       AX, 1           ; Is it true?
  66.          MOV       PULSE_TONE, 54h ; Yes! Set for tone dial
  67.          JE        SETUP2          ;        and continue
  68.          MOV       PULSE_TONE, 50h ; No! Set for pulse dial
  69.  
  70. SETUP2:                            ; Parameter 2 - COM port
  71.          P_TYPE    2               ; Get its type
  72.          CMP       AX, 2           ; Is it numeric?
  73.          JNE       ERROR           ; No!  Return to Clipper
  74.          GET_PARNI 2               ; Yes! Get its value
  75.          CMP       AX, 5           ; Is it greater than 5
  76.          JGE       ERROR           ; Yes! DOS only supports
  77.                                    ;      COM1-4. Return error
  78.          SUB       AX, 1           ; DOS port is biased to zero
  79.          MOV       PORT_NUM, AL    ; Save port number
  80.  
  81.  
  82. SETUP1:                            ; Parameter 1 - Telephone no.
  83.          P_TYPE    1               ; Get its type
  84.          CMP       AX, 1           ; Is it a string?
  85.          JE        NEXT1           ; Yes! Continue
  86.          JMP       ERROR           ; No! Return to Clipper
  87.  
  88. NEXT1:
  89.          CALL INIT_COMM            ; Initialize COM port
  90.          CMP       AL, 0           ; Did modem respond?
  91.          JE        ERROR           ; No! Return to Clipper
  92.          CMP       AH, 0           ; Does port exist?
  93.          JE        ERROR           ; No! Return to Clipper
  94.  
  95.          MOV DI, OFFSET DS:DIAL_STRING ; Get dial string address
  96.          CALL COMM_OUT                 ;      and send to modem
  97.          CALL WRIT_CHAR                ;
  98.  
  99.          GET_PARC  1               ; Get telephone number
  100.          PUSH      DS              ; Save data segment
  101.          PUSH      DX              ; Save passed data address
  102.          PUSH      AX              ;
  103.          CALL      COMM_OUT        ; Set up COM port
  104.          POP       DI              ; Get telephone number
  105.          POP       DS              ;     address to DS:DI
  106.          CALL WRIT_CHAR            ; Send it to modem
  107.          POP       DS              ; Restore data segment
  108.          MOV DI, OFFSET DS:CR_STRING  ; Get modem end string
  109.  
  110.          CALL COMM_OUT
  111.          CALL WRIT_CHAR            ; Send modem CR command string
  112.          MOV       AX, 1           ; Set AX to 1 (Return true)
  113.  
  114. DONE:
  115.          POP_REGS                  ; Restore Clipper registers
  116.          RET_LOGIC                 ; Return logical to Clipper
  117.  
  118.  
  119. DIAL  ENDP                         ; End of procedure
  120.  
  121.  
  122. ; ---------------------------------------------------------------
  123. DIALCLR  PROC  FAR                 ; Clears modem and disconnects
  124. ; ---------------------------------------------------------------
  125.  
  126.          PUSH_REGS                 ; Save Clipper's registers
  127.          CALL      INIT_COMM       ; Test COM port
  128.          TEST      AL, AL          ; Did modem respond?
  129.          JE        CLRERROR        ; No! Return error to Clipper
  130.          TEST      AH, AH          ; Does port exist?
  131.          JE        CLRERROR        ; No! Return error to Clipper
  132.  
  133.          MOV DI, OFFSET DS:HANG_UP ; Get hang-up string address
  134.          CALL      COMM_OUT        ; Set up COM port
  135.          CALL      WRIT_CHAR       ; Disconnect modem
  136.          MOV       AX, 1           ; Set return vlaue to true
  137.          JMP       DONE2           ;   and return to Clipper
  138.  
  139. CLRERROR:
  140.          MOV       AX, 0           ; Error! Set return to false
  141. DONE2:
  142.          POP_REGS                  ; Restore Clipper registers
  143.          RET_LOGIC                 ; Return logical to Clipper
  144. DIALCLR  ENDP
  145.  
  146.  
  147. ; ---------------------------------------------------------------
  148. ; ----------------- Begin subroutines below. --------------------
  149. ; ---------------------------------------------------------------
  150.  
  151. COMM_OUT  PROC NEAR                ; Get COM port
  152.           SUB DH, DH               ; Clear DH
  153.           MOV DL, PORT_NUM         ; Move port number to DL
  154.           SUB CL, CL               ; Clear CL
  155.           RET
  156. COMM_OUT  ENDP
  157.  
  158.  
  159. WRIT_CHAR PROC NEAR
  160. WRIT_IT:
  161.           MOV AH, 01               ; Output character request
  162.           MOV AL, [DI]             ; Get byte to transmit
  163.           INT 14h
  164.           INC DI                   ; Increment to next address
  165.           CMP [DI], CL             ; Is byte value = 0?
  166.           JNE WRIT_IT              ; No! Write next character
  167.           RET                      ; Return to caller
  168. WRIT_CHAR ENDP
  169.  
  170.  
  171. INIT_COMM PROC NEAR                ; Initialize COM port
  172.           SUB AH, AH               ; Clear AX
  173.           MOV AL, PORT_WORD        ; Get initalization word
  174.           SUB DH, DH               ; Clear DH
  175.           MOV DL, PORT_NUM         ; Get port number
  176.           INT 14h                  ; Initialize port
  177.           RET                      ; Return to caller
  178. INIT_COMM ENDP
  179.  
  180. CODESEG   ENDS                     ; End of code segment
  181.           END                      ; End of assembly
  182.  
  183.  
  184.