Doing interrupt chaining assignment
As the title says I'm trying to do the interrut chaining. What I'm looking for is that when the Timer Interrupt (IRQ开发者_如何学JAVA 0) is called, and the interrupt handler (ISR) finishes it executes my code. I'm trying to do it on Assembly, C or any language that allows me to do that. I found an example on this page but it doesn't work on TASM. Could you help me with this, or where I can find information about this? Thank you. :D
I'm not using it anymore, but just wanted to play again with probably the assembler I gave my first steps in assembly:
.186
.MODEL TINY, C
.code
ORG 100h
Entry:
; Install handler
push ds
xor cx, cx
mov ds, cx
mov ax, ds:[8*4]
mov dx, ds:[8*4+2]
cli
mov ds:[8*4], OFFSET InterruptHandler
mov ds:[8*4+2], cs
pop ds
mov word ptr [OldIntVect], ax
mov word ptr [OldIntVect+2], dx
sti
; Wait for the user to press a key. In the meantime you should see lots of wildcards!
xor ax, ax
int 16h
; Restore original handler
mov ax, word ptr [OldIntVect]
mov dx, word ptr [OldIntVect+2]
push ds
xor cx, cx
mov ds, cx
cli
mov ds:[8*4], ax
mov ds:[8*4+2], dx
sti
pop ds
; Exit to DOS
int 20h
PROC MyHandler
mov ah, 0Eh
mov al, '*'
int 10h
ret
ENDP
InterruptHandler:
pushf
call cs:[OldIntVect]
cmp [busy], 0
jne ExitHandler ; If jumps then the timer was faster than the time it takes for MyHandler to complete
mov cs:[busy], 1
pusha
call MyHandler ; Other options are using a pointer to function or just inlining the code here.
popa
mov cs:[busy], 0
ExitHandler:
iret
OldIntVect dd ?
busy db ?
END Entry
Tested under WinXP (32-bit):
>tasm timer.asm
Turbo Assembler Version 1.01 Copyright (c) 1988, 1989 Borland International
Assembling file: TIMER.ASM
Error messages: None
Warning messages: None
Remaining memory: 481k
>tlink /t timer.obj
Turbo Link Version 3.0 Copyright (c) 1987, 1990 Borland International
>timer
***************************
But this of course is only valid for a DOS environment (DOSBox, Windows 32-bit versions, etc.) and with some tweaks for a bootloader at most.
Anyway, thanks for the beautiful time you just gave me reviving all this :P
精彩评论