可以在不使用库函数的情况下在C中创建中断 [英] Can interrupt be created in C without use of library functions

查看:74
本文介绍了可以在不使用库函数的情况下在C中创建中断的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<pre lang="c++">





我的尝试:



i不知道关于中断的任何事情所以请解释



What I have tried:

i dont know any thing about interrupt also so please explain

推荐答案

这个问题确实没有任何意义,因为这一切都取决于操作系统和CPU。当您谈论库时,可能意味着您需要创建软件中断。硬件中断只是由硬件引起的,你的库只能处理它们。



现在,现代操作系统受到高度保护(甚至受硬件保护) t让你直接访问中断。一些旧的东西,比如DOS,广泛基于中断。使用C ++,您可以使用C ++ 内联汇编程序创建中断(例如,参见内联汇编程序 [ ^ ]);并且它从不需要任何库。



在8088/8086 CPU系列上,它看起来像

The question really makes no certain sense, because it all depends on the OS and CPU. When you are talking of "library", it probably means that you need to create a software interrupt. Hardware interrupts are only caused by hardware, your "library" can only handle them.

Now, modern OS are highly protected (and even hardware-protected) and don't give you direct access to interrupts. Some old stuff, like DOS, was broadly based on interrupts. With C++, you could create an interrupt using C++ inline assembler (see, for example, Inline Assembler[^]); and it never required any "libraries".

On 8088/8086 CPU family, it would look like
MOV AH, 0Eh
MOV AL, 'A'
INT 10h  ; BIOS interrupt, call to interrupt procedure



在现代系统上,趋势是:根本不使用软件中断,硬件中断只能在内部处理保护环,在内核模式中,它仅适用于内部OS组件和内核模式驱动程序。在快速解答中,甚至无法简要介绍这些主题。另请参阅:

保护环 - 维基百科,免费的百科全书 [ ^ ],

内核模式驱动程序框架 - 维基百科,免费的百科全书 [ ^ ]。



-SA


On modern systems, the trend is: software interrupts are not used at all, and the hardware interrupts can only be handled in the inner protection ring, in kernel mode, which is only designed for inner OS components and kernel-mode drivers. It's not possible to provide even a short introduction to these topics in a Quick Answer. See also:
Protection ring — Wikipedia, the free encyclopedia[^],
Kernel-Mode Driver Framework — Wikipedia, the free encyclopedia[^].

—SA

这篇关于可以在不使用库函数的情况下在C中创建中断的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆