home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
assemblr
/
library
/
slowdown
/
cdtrap.asm
next >
Wrap
Assembly Source File
|
1987-09-21
|
3KB
|
174 lines
title Carrier Loss Trap
name CDtrap
;
;Inserted in the time tick interrupt, watches
;the carrier detect line, and if it goes
;false, reboots the system. This assumes that
;the console has been redirected to the AUX
;(COM1) port. (It will work otherwise, but
;is pretty useless.)
;
;You can run this any number of times, and it
;wont eat up more and more memory every time.
;It only installs once; each subsequent time
;CDTRAP looks for an old copy of itself and
;turns that one on and off instead of loading
;a new one.
;
;If the CD line remains true, no action is
;taken. It is presumed this program will not
;be run when the console is the normal CON.
;
TICK equ 08h ;local tick
COM1P equ 3f8h+6 ;status port
COM2P equ 2f8h+6 ;
CDBIT equ 80h ;CD status bit
code segment
assume cs:code,ds:code
org 5dh
tfcb label byte
org 100h
stack label word
start: jmp over
;
;......... Resident Code .................
;
statp dw COM2P ;-6 port
sig dw 55aah ;-4 signature
flag dw 1 ;-2 enable flag
;
;This is the thing that watches the DSR line
;on the AUX device.
;
dsrtrap:
test cs:flag,1 ;if flag zero
jz dt2 ;dont look
push ax
push dx
mov dx,cs:statp ;MODEM status
in al,dx
and al,CDBIT ;mask CD bit
pop dx
pop ax
jnz dt2 ;if true exit
cli
int 19h ;IBM boot
dt2: jmp dword ptr cs:oldvec
oldvec dd (?) ;orig. vector,
trapend: ;end of driver.
;
;..... End of Resident Code ..............
;
signon db "CD Trap for Pclones",13,10
db '5 Feb 85',13,10,'$'
inmsg db 'Carrier Loss Trap Installed'
db 13,10,'$'
outmsg db 'Carrier Loss Trap Removed'
db 13,10,'$'
notmsg db 'CD trap not installed!',13,10,'$'
;
;Install or remove the DSRTRAP. If R is present
;on the command line, remove it if it exists.
;
over: mov ax,cs
mov ds,ax
mov ss,ax
mov sp,offset stack
mov dx,offset signon
call msg
mov ah,35h ;get orig clock
mov al,TICK ;tick vector
int 21h
mov word ptr cs:oldvec,bx ;save it,
mov word ptr cs:oldvec + 2,es
;
;If R present, remove the trap, else install
;it.
;
cmp tfcb,'R'
jne in
;
;Remove the trap. If already resident, clear
;the flag, disabling it. If not installed,
;do nothing.
;
out: cmp word ptr es:[bx]-4,55aah
je o1
mov dx,offset notmsg
mov ah,0
jmp msg_then_dos
o1: mov word ptr es:[bx]-2,0
mov dx,offset outmsg
mov ah,0
jmp msg_then_dos
;
;Install the DSR Trap. If it is already
;installed, just set the flag and enable it.
;If not there, install ourselves. Check for
;COM1 or COM2.
;
in: mov ax,COM1P ;assume COM1
cmp tfcb,'2'
jne i0
mov ax,COM2P ;else COM2
i0: mov statp,ax ;set port #
cmp word ptr es:[bx]-4,55aah
jne i1
;
;Re-enabling an existing trap. Set flag and
;IO port number and go exit.
;
mov byte ptr es:[bx]-2,1
mov word ptr es:[bx]-6,ax
mov ah,0
jmp i2
i1: mov ah,25h ;insert ours
mov al,TICK
mov dx,offset dsrtrap
int 21h
mov dx,offset trapend
add dx,15 ;make segment
shr dx,1 ;address of the
shr dx,1 ;end of the
shr dx,1 ;driver above,
shr dx,1
mov ah,31h ;keep process,
mov al,0
i2: mov dx,offset inmsg
;
;Display a message, return to DOS with the
;passed AH and AL.
;
msg_then_dos:
push ax
call msg
pop ax
int 21h
;
;Display a message
;
msg: mov ah,9
int 21h
ret
code ends
end start