Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Having trouble with keyboard interrupts and a custom ISR (sort of )

Status
Not open for further replies.

weevilofdoom

Programmer
Jan 28, 2003
91
US
I've written an ISR type program that is supposed to detect when the escape key is pressed, and output a message, it uses chaining to go to the original ISR if escape is not pressed. When I type, it outputs normally to the screen, but when I hit escape, it outputs that stupid little arrow character instead of my message. I've debugged, and it doesn't seem that my ISR is a TSR, or something, because it doesn't detect the escape press from my .com file which I loaded.
Here's a bit of code:

.model tiny
.286

.code
org 100h
start:
jmp setup

int9_handler proc far
sti
pushf
push es
push ax
push di

L1:
mov ax, 40h
mov es, ax
mov di, 17h
mov ah, es:[di]

L2:
in al,60h
cmp al,01h ;not too sure if this is the value, experimenting
jne L4
L3:
mov si, offset message
go:
mov dl, [si]
cmp dl, 00h
je L4
mov ah, 09h
mov al, dl
int 10h
inc si
jmp go
L4:
pop di
pop ax
pop es
popf
jmp cs:[old_interrupt9]

old_interrupt9 dd ?
message BYTE "Escape Pressed", 00h

int9_handler endp
end_ISR label byte

setup:
mov ax, 3509h
int 21h
mov word ptr old_interrupt9, bx
mov word ptr old_interrupt9+2, es

mov ax, 2509h
mov dx, offset int9_handler
int 21h

mov dx, offset end_ISR
int 27h
end start The weevil of doooooooooom
-The eagle may soar, but the weasel never gets sucked up by a jet engine (Anonymous)
 
when you set your new handler - are you setting the right code segment?

have you ensured that the code acually works before you use it as an tsr?

tell me how you get on
"There are 10 types of people in this world, those who know binary and those who don't!"
 
far as I know, I'm in the right code segment, compiles fine, doesn't complain, loads fine, but when I try to use some sort of test program, it takes a crap! I'm not sure what to do, my debugger isn't giving me any real clues, so I'm sort of stuck The weevil of doooooooooom
-The eagle may soar, but the weasel never gets sucked up by a jet engine (Anonymous)
 
are you setting DS correctly for the interrupt call in your isr?
"There are 10 types of people in this world, those who know binary and those who don't!"
 
I don't have a data segment, it's a tiny model The weevil of doooooooooom
-The eagle may soar, but the weasel never gets sucked up by a jet engine (Anonymous)
 
ah har!

thats your problem - you need to set ds the same as cs

in the start of your setup code put

push cs
pop ds ;makes ds same as cs


also in your ISR you need something like the folowing

push ds ;backup ds
push cs
pop ds ;make ds same as cs

<stuff> ;do ISR stuff here

pop ds ;restore ds

straiph
&quot;There are 10 types of people in this world, those who know binary and those who don't!&quot;
 
Well spotted, straiph!!
In very small bits of tiny code with a single reference to something using ds, I sometimes specify cs instead. This is BAD, because it means an extra prefix byte to specify cs, and that makes things slower, but if I only read one word or something then it can be OK
 
pure genius :)
thank you The weevil of doooooooooom
-The eagle may soar, but the weasel never gets sucked up by a jet engine (Anonymous)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top