尝试实现一个基本的操作系统,但我正在使用 vs2015,但这些 asm 的东西让我很困惑
出错的代码
inline cpu_flags DisableInterrupts()
{
cpu_flags fl;
_asm volatile ("pushfl; popl %0; cli" : "=g" (fl));
return fl;
}
它给出这样的错误
Error C2400 'opcode' 中的内联汇编语法错误;找到“数据类型”
删除 volatile 后也没有运气
inline cpu_flags DisableInterrupts()
{
cpu_flags fl;
_asm ("pushfl; popl %0; cli" : "=g" (fl));
return fl;`
}
它给
Error C2400 'opcode' 中的内联汇编语法错误;找到 '('
谢谢
最佳答案
这是 gcc 使用的 AT&T 语法。
Visual Studio 的内联汇编程序使用 Intel 语法。但是,还有一个内置的 _disable()不需要任何汇编代码的函数。
也不是关于限制使用该功能的备注:
This function is only available in kernel mode. If used in user mode, a Privileged Instruction exception is thrown at run time.
关于c++ - 内联汇编器在 vs 2015 中给出了 c2400,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43157143/