home *** CD-ROM | disk | FTP | other *** search
- ;**************************************************************************
- ;*:*********************************************************************
- ;*:
- ;*: Program: MODEM.ASM
- ;*:
- ;*: System: Clipdial Intelligent Phone Dialer V#1.0
- ;*: Author: Glendon Todd / Vega Group
- ;*: Copyright (c) 1987, Public Domain by Glendon Todd
- ;*:
- ;*:
- ;*: Documented: 11/26/87 12:20 SNAP! version 2.01
- ;*:*********************************************************************
-
- ; This source file contains the assembly language routines that Clipdial
- ; uses to control and to communicate with the PC serial ports. Included
- ; are serial port initialization code, a routine that returns the status of
- ; the serial port's DSR status line, and a routine which transmits modem
- ; command strings (AT-prefixed) to a Hayes-compatible modem and which
- ; controls the serial port's DTR line appropriately.
- ;
- ; The DTR control and command transmission code are based on the DOSMODEM
- ; utilities written by Donovan Kuhn and John Niedfeldt.
-
- ; For support, comments, questions or whatever, contact :
- ;
- ; Glendon Todd
- ; 312 Van Buren St.
- ; Falls Church, VA 22046
- ; Compuserve 71121,352
- ; Voice (703) 532-8191
-
-
- upcase macro char
- local nocvt
-
- ifb <char>
-
- upcase al
-
- else
-
- cmp char,'a'
- jb nocvt
- cmp char,'z'
- ja nocvt
- sub char,32
- nocvt:
- endif
- endm
-
-
-
- page 66,132
- extrn _retl:far ; return logical true or false
-
- prog segment byte public 'PROG'
- assume CS:prog, DS:prog
-
- arg_str equ byte ptr es:[si]
-
- public auxout
-
- auxout proc far
- push ax
- mov dx,base
- add dx,5
-
- txlp:
- in al,dx
- and al,20h
- jz txlp
-
- pop ax
- sub dx,5
- out dx,al
- ret
- auxout endp
-
- ; DSR - Procedure returns value of DSR line from modem.
- ; Currently works for Com1 only.
- ; Input arguments - none.
- ; Returns status as logical True/False.
- public dsr
- dsr proc far
- mov dx,03FEh
- in al,dx
- and ax,0030h
-
- push ax ; put return value on the stack
- call _retl ; return logical value to clipper
- pop ax ; restore the stack
- ret
-
- dsr endp
-
- ; MODEMCMD - Transmits a command string to a Hayes-compatible modem.
- ; Input arguments - Pointer to string - command to be transmitted.
- ; Modemcmd will initialize the comm. port, control DTR as necessary,
- ; prefix the command with "AT", and terminate it with a CR (0Dh).
- public modemcmd
- modemcmd proc far
- jmp modemcmd1
-
- base dw 0
-
- modemcmd1:
- push bp
- mov bp,sp
- push es
- mov es,[bp+8]
- mov bx,[bp+6]
- mov ch,0 ;default com port (COM1:)
- mov si,bx
- modemcmd2:
- mov cl,[arg_str] ;space off leading spaces
- cmp cl,' '
- jz modemcmd2
-
- cmp cl,'?'
- jz errexit
-
- upcase cl ;using UPCASE without a parameter
- cmp cl,'C' ;(defaults to AL)
- jnz nocom
-
- mov cl,[arg_str][1]
- upcase cl ;using UPCASE using another register
- cmp cl,'O'
- jnz nocom
-
-
- mov cl,[arg_str][2]
- upcase cl ;using UPCASE with cl as the parm
- cmp cl,'M'
- jnz nocom
-
- cmp byte ptr [arg_str][4],':'
- jz check_port
-
- errexit:
- lea dx,errmsg
- errexit1:
- mov ah,9
- int 21h
- jmp exit
-
- check_port:
- mov al,[arg_str][3] ;get the com number
- sub al,'1' ;convert to binary
- cmp al,3 ;greater than com4?
- ja errexit
-
- add si,5
-
- mov ch,al
- nocom:
- xor bh,bh
- shl ch,1 ;ch holds comm. port number
-
- mov ah,0 ;service 0 - initialize comm. port
- mov al,83h ;sets port to 1200,N,8,1
- ;change 83h to 43h for 300 baud,
- ;0A3h for 2400 baud
- mov dh,0
- mov dl,ch ;serial port number from ch
- int 14h
-
- mov ax,40h
- mov ds,ax
- push bx
- mov bh,0
- mov bl,ch
- mov ax,ds:[bx]
- pop bx
- push cs
- pop ds
-
- cmp ax,0
- jnz comok
-
- lea dx,ncstr
- jmp errexit1
-
-
- comok:
- mov base,ax ;comm port base address
-
- mov dx,ax
- add dx,4
- in al,dx ;get comm port status
- or al,3 ;set dtr bit
- out dx,al
- push dx
-
- mov al,'A'
- call auxout
- mov al,'T'
- call auxout
-
- outlp:
- mov al,[arg_str]
- inc si
- cmp al,0
- jz atdone
- call auxout
- jmp outlp
- atdone:
- mov al,0Dh ;CR
- call auxout
- pop dx
- in al,dx
- and al,0fch
- out dx,al
- exit:
- pop es
- pop bp
- ret
- modemcmd endp
-
-
- errmsg db 'Usage: AT [COM1:|COM2:|COM3:|COM4:] command string',13,10,'$'
- ncstr db 'COM port not found',13,10,'$'
-
-
- prog ends
- end