; ; DIAL.ASM - Version 0.1 (August, 1996) ; Command Line Telephone Dialer ; Freeware from Kirk Lawrence ; ; Syntax: DIAL xxx-xxxx ; ...where "xxx-xxxx" is the phone number you want to dial. ; ; Spaces, dashes and parentheses may be used as separator characters ; in the phone number, if you wish, but they aren't necessary. The ; phone number can be any length up to about 122 characters. If ; you're knowledgeable about the various modem control characters ; (such as a comma), you can use them in the phone number to achieve ; specific desired results. ; ; The initialization, dial and hang-up sequences are contained in "db" ; strings, and may be altered, if you so desire. Make sure they're ; null-terminated, and don't forget to include a carriage return (13) ; where appropriate. ; ; This source code is currently set up for COM2. To change it to ; another COM port, comment out the port definitions for COM2, below, ; and uncomment the definitions for the desired port number. ; ; To assemble/compile: ASM86 DIAL $ SZ PZ ; GENCMD DIAL 8080 ; ; cseg ;start of code segment org 100h ;leave room for base page jmp start ;go start the program ; ;--------------- ;COM1 addresses: ;dataprt dw 03F8h ;modem data port address, COM1 ;ctrlprt dw 03FDh ;modem control port address, COM1 ; ;--------------- ;COM2 addresses: dataprt dw 02F8h ;modem data port address, COM2 ctrlprt dw 02FDh ;modem control port address, COM2 ; ;--------------- ;COM3 addresses: ;dataprt dw 03E8h ;modem data port address, COM3 ;ctrlprt dw 03EDh ;modem control port address, COM3 ; ;--------------- ;COM4 addresses: ;dataprt dw 02E8h ;modem data port address, COM4 ;ctrlprt dw 02EDh ;modem control port address, COM4 ; nbr dw 0 ;storage variable for the timer's use msg db 13,10,'DIAL Version 0.1 - Command Line Telephone Dialer' db 13,10,'Freeware from Kirk Lawrence',13,10,'$',26 synt db 13,10,' Syntax: DIAL xxx-xxxx',13,10,07,'$' init db 10,' Initializing... $' dial db 13,' ',13,' Dialing$' istr db 'ATM1L3S11=55',13,0 dstr db 'ATDT ',0 hang db 'ATH0',13,0 done db 13,10,10,'Pick up the telephone handset NOW, then press ' db 'the SPACE BAR. $' crlf db 13,10,'$' ; ;-------------------------------------------------------------- ; Print the sign-on message. ; start: mov cl,9 ;function 9 - print string mov dx,offset msg ;point to the header message int 224 ;call BDOS mov si,81h ;point SI to beginning of command line ;-------------------------------------------------------------- ; Check to see if the user entered a command line argument. ; If not, print the syntax message and quit. parse: lodsb ;load a byte from the command line cmp al,20h ;is it a space? je parse ;yes, go check the next byte jg initialize ;no, so we've got a command line argument mov cl,9 ;function 9 - print string mov dx,offset synt ;point to the 'syntax' message int 224 ;call BDOS jmp exit ;go quit ;--------------------------------------------------------------- ; Here's where we send the initialization sequence to the modem. ; It's contained in the "db" string named "ISTR." ; initialize: mov cl,9 ;function 9 - print string mov dx,offset init ;point to 'initializing' message int 224 ;call BDOS mov dx,offset istr ;point DX to the initialization string call sendstr ;go send the string to the modem mov ax,0010 ;delay factor into AX call timer ;go pause a bit ;---------------------------------------------------------------------- ; Here, we send the 'dial' command to the modem (in "db" string "DSTR"). ; mov cl,9 ;function 9 - print string mov dx,offset dial ;point to 'dialing' message int 224 ;call BDOS mov dx,offset dstr ;point DX to the dialing string call sendstr ;go send the string to the modem mov si,81h ;point SI to the command line ;-------------------------------------------------------------- ; Here's where we send the user-entered telephone number to ; the modem, and also echo it to the screen. ; dialit: lodsb ;load a byte from the command line mov dl,[si] ;move the byte into DL cmp dl,0 ;do we have a hex 0 (end of string)? je enddial ;yes, so go assume it's the end of the string mov al,dl ;DL into AL call send ;go send it jmp dialit ;go get the next byte enddial: call modstatus ;go check modem status mov ax,0001 ;delay factor into AX call timer ;go pause a bit mov al,13 ;carriage return into AL call send ;go send it ;--------------------------------------------------------------- ; Pause to let the modem dial the number. ; mov ax,90 ;delay factor into AX (value is arbitrary) call timer ;go pause a bit ;--------------------------------------------------------------- ; Print the 'press a key' message to the screen, wait for a ; keypress, then disconnect the modem from the phone line ; by sending the "db" string named "HANG" (ATH0 ). ; mov cl,9 ;function 9 - print string mov dx,offset done ;point to the screen message int 224 ;call BDOS keystatus: mov ah,1 ;function 1 - keyboard status int 16h ;call BIOS keyboard services jz keystatus ;no character waiting, go check again mov ah,0 ;function 1 - read keyboard buffer int 16h ;call BIOS keyboard services xor ax,ax ;swallow the keypress mov dx,offset hang ;point DX to the hang-up string call sendstr ;go send the string to the modem ;--------------------------------------------------------------- ; Quit the program. ; exit: mov cl,9 ;function 9 - print string mov dx,offset crlf ;point to carriage return/line feed int 224 ;call BDOS xor cx,cx ;function 0 - reset system int 224 ;call BDOS ; ;=============================================================== ; Following are the program's sub-routines. ;=============================================================== ;------------------------------------------------------------------- ; This routine sends a string, pointed to by offset DX, to the modem ; with no screen echo. ; sendstr: mov bx,dx ;location of 1st char. of message into BX getchr: mov al,[bx] ;move the character into AL cmp al,0 ;is it an ASCII zero? je alldone ;yes, so we're all through -- return call send2 ;no, so go send character to the modem inc bx ;increment the character location pointer jmp getchr ;go get the next character alldone: ret ;return ;--------------------------------------------------------------- ; This routine sends a byte in AL to the modem, echoes ; the byte to the screen, and pauses one clock tick. ; send: mov dx,dataprt ;point DX to the modem data port out dx,al ;send the byte to the modem call modstatus ;go check modem status mov ax,0001 ;set timer delay in AX call timer ;go pause a bit ret ;return ;--------------------------------------------------------------- ; This routine sends a byte in AL to the modem and pauses ; one clock tick, but doesn't echo the byte to the screen. ; send2: mov dx,dataprt ;point DX to the modem data port out dx,al ;send the byte to the modem mov ax,0001 ;set timer delay in AX call timer ;go pause a bit ret ;return ;--------------------------------------------------------------- ; This routine checks to see if there's a byte ready at the ; modem...and if so, echoes it to the screen. ; modstatus: mov dx,ctrlprt ;point to modem status register in al,dx ;read it and al,1 ;is anything there? jz nomore ;no, so go return mov dx,dataprt ;yes, so point to modem data register in al,dx ;read it mov dl,al ;move character into DL mov cl,2 ;function 2 - console output int 224 ;call BDOS nomore: ret ;return ;-------------------------------------------------------------- ; This is our timer routine to introduce delays of various ; lengths, when needed. The delay factor is specified in AX ; prior to calling this routine. ; timer: mov nbr,ax ;move delay factor into variable mov ah,00 ;function 0 - read system timer int 1Ah ;call BIOS time-of-day services ; (current count returned in DX) add dx,nbr ;add our delay factor mov nbr,dx ;move result into variable count: mov ah,00h ;function 0 - read system timer int 1Ah ;call BIOS time-of-day services cmp dx,nbr ;has time period elapsed? jne count ;no, go count some more ret ;return end