正如标题所说,我正试图进行中间链接。我正在寻找的是当调用定时器中断(IRQ 0),并且中断处理程序(ISR)完成时,它执行我的代码。我试图用Assembly,C或任何允许我这样做的语言来做。我在这个page上找到了一个例子,但它不适用于TASM。你可以帮我解决这个问题,或者我可以在哪里找到相关信息吗?谢谢。 :d
答案 0 :(得分:3)
我不再使用它了,但是我想再次使用汇编程序,我已经完成了汇编的第一步:
.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
在WinXP(32位)下测试:
>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
***************************
但是这当然只对DOS环境(DOSBox,Windows 32位版本等)有效,并且最多只能对引导加载程序进行一些调整。
无论如何,感谢你给我恢复这一切的美好时光:P