PQ> How do I set up a serial port?
PQ> How do I access it?
PQ> How do I communicate with my modem with
PQ> command codes and such like?
Not real useful but I think this answers some of your questions. To use the
modem, set up an ISR.
;--------------------------------------------------------------------------
; Reset com2
cseg segment
assume cs:cseg
org 100h ;.COM format
Port EQU 2F8h ;3F8h for Com1
Begin:
call Drop ;Drop DTR in case we are online.
call Reset
call Drop ;Drop DTR - Reset might have set it high.
mov ax,11100011b ;Initialize comport to 9600,8,N,1
mov dx,1 ;COM 2 (COM 1 = 0)
int 14h
push ax
mov cx,1
call delay
call Reset
pop ax
test al,10000000b ;Test for carrier detect and if
jz exit ; found, try again to disconnect.
dec cntr
jnz Begin
exit:
mov ax,11100011b ;Initialize comport again.
mov dx,1 ;COM 2 (COM 1 = 0)
int 14h
call Reset
cmp cntr,0
jne bye
mov dx,offset error
mov ah,9
int 21h
bye:
mov ax,4C00h ;Exit to DOS.
int 21h
;*******************************************
file db 'COM2',0 ;Talking to com2.
cntr db 3 ;Try three times.
error db 'I/O error, try reseting machine',36
;*******************************************
Drop proc near ; Raise and lower DTR.
call Disable ;Disable IRQ's.
mov dx,Port+4 ;Access modem control port.
in al,dx
or al,00000001b ;Raise DTR
out dx,al
mov cx,1
call Delay
in al,dx
and al,00000000b ;Drop dtr & rts.
or al,00001100b
out dx,al
mov cx,1
call Delay
call Enable ;Enable IRQ's.
mov al,20h ;Signal 8259 that other
out 20h,al ; interrupts are okay.
ret
Drop endp
;**************************************************
Delay proc near ; Simple BIOS delay
;Requires number of reiterations in CX on entry.
push ds
;push cx
;mov cx,5 ;Approx. 5/18.2 sec.
mov ax,0040h
mov ds,ax
mov bx,6Ch ;BIOS timer, 40:6C
d1: mov al,[bx]
DelayLoop:
cmp al,[bx] ;Is it the same?
je DelayLoop ;Yes, try again.
loop d1 ;Nope, loop and decrement CX.
;pop cx
pop ds ;Restore registers and exit.
ret
Delay endp
;**************************************************
Reset proc near
mov dx, Port
mov al, 'A'
out dx,al
mov cx,1
call delay
mov al, 'T'
out dx,al
mov cx,1
call delay
mov al, 'Z'
out dx,al
mov cx,1
call delay
mov al, 0Dh
out dx,al
mov cx,10
call delay
ret
Reset endp
;**************************************************
Disable proc near
in al,21h
or al,00001000b ;Disable IRQ3 (com2)
or al,00010000b ;Disable IRQ4 (com1)
out 21h,al
ret
Disable endp
;**************************************************
Enable proc near
in al,21h
and al,11110111b ;Enable IRQ3 (com2)
and al,11101111b ;Enable IRQ4 (com1)
out 21h,al
ret
Enable endp
cseg ends
end Begin
--- timEd 1.01
---------------
* Origin: James Vahn (jvahn@short.circuit.com) (1:346/15.1)
|