进行中断链接分配

发布于 2024-10-19 06:32:05 字数 280 浏览 4 评论 0原文

正如标题所说,我正在尝试进行中断链接。我正在寻找的是,当调用定时器中断(IRQ 0)并且中断处理程序(ISR)完成时,它会执行我的代码。我正在尝试使用汇编语言、C 语言或任何允许我这样做的语言来实现这一点。我在此 页面 上找到了一个示例,但是它不适用于 TASM。您能帮我解决这个问题吗?或者我可以在哪里找到有关此问题的信息?谢谢。 :D

As the title says I'm trying to do the interrut chaining. What I'm looking for is that when the Timer Interrupt (IRQ 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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

任谁 2024-10-26 06:32:05

我不再使用它,但只是想再次使用我在汇编中给出的第一步的汇编器:

.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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文