是否可以退出ISR而不返回到调用代码?

问题描述 投票:0回答:1

我正在尝试在汇编中创建一个中断服务例程,它不会返回到调用中断的位置,而是返回到一个标签。

我应该跳到标签而不使用

iret
(以及任何其他与中断相关的指令),还是有特定的方法可以做到这一点?

例如:

[org 0x7c00]

; setting up ISR for int 69h (isr69h is the ISR)
; (i did it already, and worked fine with IRET, but i dont want to return to the caller)
; ...

int 69h ; test
; don't continue code from here

; some more code...

continue_from_here:
    jmp $

isr69h:
    ; do something
    jmp continue_from_here ; is it enough, or should i place here more code? (for example: restoring FLAGS etc.)

times 510-($-$$) db 0 ; padding
dw 0xAA55 ; boot signature

(我使用网络汇编器)

assembly nasm interrupt x86-16
1个回答
1
投票

当然,没有规定你必须 IRET。一旦进入中断处理程序,它就拥有了 CPU 的控制权,可以为所欲为。

几点说明:

  • 您可能需要清理堆栈,删除返回地址和标志,以及可能无法恢复的中断代码正在使用的任何堆栈数据。您可能只想将堆栈指针重置为堆栈空间的顶部地址,从而有效地清除整个堆栈。

  • 如果这是硬件中断,则 CPU 在进入处理程序时禁用中断。通常 IRET 会在恢复 FLAGS 时重新启用它们,因此如果您不打算使用 IRET,则必须在适当的时候手动 STI 来重新启用中断。

© www.soinside.com 2019 - 2024. All rights reserved.