gpt4 book ai didi

c - MSVC 中的伪寄存器

转载 作者:行者123 更新时间:2023-11-30 15:56:53 26 4
gpt4 key购买 nike

Borland C 有伪寄存器 _AX、_BX、_FLAGS 等,可以在“C”代码中使用它们将寄存器保存到临时变量。

是否有任何 MSVC 等效项?我尝试了@AX、@BX等,但编译器(MSVC1.5)给出了错误(“40”无法识别的符号)。

我正在开发一个 16 位预启动应用程序,无法使用 .谢谢。

最佳答案

如果您只在寄存器和变量之间移动值,则不需要伪寄存器。示例:

int a = 4;
int b = 999;
__asm
{
mov eax, a; // eax equals to 4
mov b, eax; // b equals to eax
}
// b equals to 4 now

编辑:要将标志复制到变量中并再次返回标志,可以使用 LAHFSAHF 指令。示例:

int flags = 0;
__asm
{
lahf;
mov flags, eax;
}
flags |= (1 << 3);
__asm
{
mov eax, flags;
sahf;
// 4th bit of the flag is set
}

关于c - MSVC 中的伪寄存器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10891566/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com