SL> mov ah,34h
SL> int 21h
SL> mov dl,es:[bx]
SL> The tsr seem to work fine until i type few keys and lock up
SL> very hard! I wonder what wrong i did?
Don't call that function from inside a TSR. Set up a pointer in
the tsr init code. Here's a bit of code- the InDOS portion is
a tad clumsy but I'm sure you can clean it up.
;======================SAVER.ASM================================
; MONO/EGA/VGA Screen blanker TSR. Also fixes that cAPS lOCK pROBLEM.
; Courtesy of James Vahn 1:346/15.1
; Puts that scrollock key to work.
Hook equ 01Ch ; Vector to hook. 01Ch
cseg segment
assume cs:cseg,ds:cseg
org 100h ; .COM format
;.286 ; 286+ opcodes
;---------------------------
; Start of the resident ISR code.
;---------------------------
Begin:
jmp Init ; Jump over the ISR code
; to the intitialization code.
Old_Int dd ? ; Storage- points to the old ISR.
InDOS dd ? ; DOS busy flag.
old_lite db ? ; Data storage for the blanking routine,
new_lite db ? ; contains the LED status.
New_ISR:
db 60h
;pusha ; Save the registers
push es
push ds
mov es, word ptr cs:InDOS ; Test if DOS is busy.
mov bx, word ptr cs:InDOS+2
cmp word ptr es:[bx-1],0
jne Exit
mov ax,40h ; Set data segment to BIOS area
mov ds,ax
mov bx,0017h
mov al,[bx] ; Get the byte at 0040:0017
test al,00000011b ; and test for SHIFT key.
jz Blanker ; nope, jump.
and al,10111111b ; Turn that Capslock off.
mov [bx],al ;
jmp Exit
Blanker:
push cs
pop ds ; Point data segment to code.
test al,00010000b ; Test bit 4, scrollock lite
jz Vid_on ; If not on, then Video ON.
Vid_off:
cmp al,old_lite ; Skip if it's been done, otherwise
je exit ; we will call BIOS at every timer IRQ.
mov old_lite,al ; Set our flag.
; mov ax,1000h ; Turn video off.
; mov bx,012h
; int 10h
; jmp exit
mov dx,03B8h ;monochrome
in al,dx
and al,1110111b
mov al,2
out dx,al
jmp exit
Vid_on:
cmp al,old_lite ; Skip if it's been done.
je exit
mov old_lite,al ; Set flag.
; mov ax,1000h ; Turn video on.
; mov bx,0F12h
; int 10h
; jmp exit
mov dx,03B8h ;monochrome
in al,dx
or al,0001000b
mov al,0Ah
out dx,al
jmp exit
Exit:
pop ds
pop es
;popa ; End of ISR- exit
db 61h
jmp cs:[Old_Int] ; to old vector.
;-----------------------------
; TSR Initialization code.
;-----------------------------
Init:
mov ax,40h
mov ds,ax ; Set data segment to 40h
mov bx, 17h ; Set index to 17h
mov al,byte ptr [bx] ; Pointing to keyboard data area.
and al, 10001111b
or al, 00000000b ; LEDs off.
mov byte ptr [bx],al
push cs
pop ds
mov dx,offset Msg ; Prints the hello message.
mov ah,09h
int 21h
mov bx,02Ch
mov es,[bx] ; Get environment segment
mov ah,49h ; from Program Segment Prefix
int 21h ; and release the environment memory.
mov ah,35h ; Get old vector and store it.
mov al,Hook
int 21h
mov word ptr [Old_Int],bx
mov word ptr [Old_Int+2],es
mov ah,34h ; Get address of DOS Busy flag.
int 21h
mov word ptr [InDOS],es
mov word ptr [InDOS+2],bx
mov al,Hook ; Change this vector
mov dx,offset New_ISR ; Move offset of New_ISR into dx
mov ah,25h ; call function 21/25
int 21h ;
mov dx,offset Init ; Allocate TSR memory
int 27h ; and exit to DOS.
Msg db 13,10
db 'Saver.Com- Press Scrollock to blank EGA/VGA screen.',13,10
db 'Also turns off cAPSLOCK when you hit the SHIFT key.',13,10
db 'Courtesy of James Vahn, 5/16/94',13,10
db 13,10,36
cseg ends
end Begin
--- timEd 1.01
---------------
* Origin: James Vahn (jvahn@short.circuit.com) (1:346/15.1)
|