我不再使用它,只是想再次使用我在组装过程中给出的第一步的汇编器:
.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