如何处理中断?
我的任务是编写一个处理除以零异常的程序。我很难找到相关信息。据我了解,我需要更改中断向量表中的第 0 个条目,但我该怎么做呢?我看到有一个 LIDT 指令,但是我不需要写整个表吗?
请注意,我将在 16 位模式下工作。
I have a task to write a program which handles the division by zero exception. I'm having a hard time finding information about that. As I understand, I need to change the 0th entry in interrupt vector table, but how do I do that? I see there is a LIDT instruction, but wouldn't I have to write the whole table then?
Note, I'll be working in 16 bit mode.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设您指的是 16 位模式的“实模式”,则中断向量表只是从线性地址 0 开始,请参阅 维基百科条目。因此,问题是从
[0000:0000]
获取旧的 4 字节远指针,以便稍后可以恢复(或链接)并使用您自己的处理程序覆盖该条目。如果您使用的是 DOS,则可以使用
INT 21h/AH=25h
设置中断向量,INT 21h/AH=35h
检索旧条目。Assuming that you mean "real mode" by 16-bit mode, the interrupt vector table is simply located starting at linear address 0, see the wikipedia entry. So it's a matter of getting the old 4-byte far pointer from
[0000:0000]
so it can be restored later (or chained) and overwriting the entry with your own handler.If you're using DOS you can use
INT 21h/AH=25h
to set the interrupt vector andINT 21h/AH=35h
to retrieve the old entry.