Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C 执行中断链接分配_C_Assembly_Interrupt_Interrupt Handling - Fatal编程技术网

C 执行中断链接分配

C 执行中断链接分配,c,assembly,interrupt,interrupt-handling,C,Assembly,Interrupt,Interrupt Handling,正如标题所说,我正在尝试进行中断链接。我要寻找的是,当定时器中断(IRQ 0)被调用,并且中断处理程序(ISR)完成时,它会执行我的代码。我正试图在汇编语言、C语言或任何允许我这样做的语言上实现它。我在这方面找到了一个例子,但它在TASM上不起作用。你能帮我吗,或者我在哪里能找到关于这个的信息?谢谢D我不再使用它了,只是想再次使用可能是我在汇编中给出的第一步的汇编程序: .186 .MODEL TINY, C .code ORG 100h Entry: ; Install handler

正如标题所说,我正在尝试进行中断链接。我要寻找的是,当定时器中断(IRQ 0)被调用,并且中断处理程序(ISR)完成时,它会执行我的代码。我正试图在汇编语言、C语言或任何允许我这样做的语言上实现它。我在这方面找到了一个例子,但它在TASM上不起作用。你能帮我吗,或者我在哪里能找到关于这个的信息?谢谢D

我不再使用它了,只是想再次使用可能是我在汇编中给出的第一步的汇编程序:

.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位)下测试:

但这当然只适用于DOS环境(DOSBox、Windows 32位版本等),并且最多对引导加载程序进行一些调整


不管怎样,感谢你给我的美好时光,让我重温这一切:p我不再使用它了,但我只是想再次使用可能是我在组装中迈出的第一步的汇编程序:

.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位)下测试:

但这当然只适用于DOS环境(DOSBox、Windows 32位版本等),并且最多对引导加载程序进行一些调整


无论如何,感谢你给我的美好时光,让我重温这一切:链式中断处理高度依赖于工作环境(操作系统、芯片等),从来不是最常见的编程方式。您可能应该更具体地说明您正在使用的是哪种系统,即使这样,您也可能需要耐心。我正在通过VirtualBox使用Windows XP。链式中断处理高度依赖于工作环境(操作系统、芯片等),从来不是最常见的编程方式。你可能应该更具体地说明你正在使用什么样的系统,即使这样,耐心也是必要的。我正在使用Windows XP而不是VirtualBox。你做得真是太棒了!谢谢你怎么做到的!谢谢D