简体   繁体   English

我可以在内联汇编中使用中断吗

[英]Can i use interrupts in inline assembly

I want to use interrupts in inline asm but it is not letting me I think my app is this我想在内联 asm 中使用中断,但它不允许我认为我的应用程序是这样的

__asm__("movb %ah,9;" 
"movb %al,0x41;" 
"movb %bh,0x0;" 
"movw %cx,0x1; "
"movb %bl,0x0F ;" 
"int $10; ");

I am getting nothing after running this just a blank space what should I do?运行这只是一个空白区域后我什么也没有得到我该怎么办?

Can i use interrupts in inline assembly?我可以在内联汇编中使用中断吗?

Yes, as long as the interrupt exists and you inform the compiler of how to deal with it correctly (eg "clobber list" to tell the compiler which registers changed, etc).是的,只要中断存在并且您通知编译器如何正确处理它(例如,“clobber list”告诉编译器哪些寄存器发生了变化等)。 See the GCC manual and https://stackoverflow.com/tags/inline-assembly/info请参阅GCC 手册https://stackoverflow.com/tags/inline-assembly/info

And as long as you use the correct number, likely you wanted int $0x10 instead of int $10 .只要您使用正确的数字,您可能想要int $0x10而不是int $10 And you'll want to mov immediates into registers, not mov registers to absolute memory addresses.而且您需要将立即数移动到寄存器中,而不是将寄存器移动到绝对 memory 地址。

If that doesn't work, I'd be tempted to suspect that you're trying to use BIOS "video services" to print a character on the screen;如果这不起作用,我会怀疑您正在尝试使用 BIOS “视频服务”在屏幕上打印字符; but you're not in real mode (and doing it in 32-bit code or 64-bit code);但你不是在实模式下(并且使用 32 位代码或 64 位代码); and the BIOS might not exist at all (eg a UEFI system);并且 BIOS 可能根本不存在(例如 UEFI 系统); and an OS may have taken over control of the hardware (and broken all the assumptions that BIOS expects, like disabling obsolete "legacy junk emuation" in certain devices, reconfiguring memory, and timers and interrupt controllers; so that even if BIOS exists and you're in real mode you still can't use it safely).并且操作系统可能已经接管了对硬件的控制(并打破了 BIOS 期望的所有假设,例如在某些设备中禁用过时的“旧垃圾仿真”,重新配置 memory,以及计时器和中断控制器;这样即使 BIOS 存在并且您'在实模式下你仍然不能安全地使用它)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM