[英]how can i read value from register using C++
我正在使用 C++ 为计算器编写代码,但它显示\\读取结果与汇编,我想将值存储在任何寄存器中,例如(Al)到 C++ 中的变量 int ......我搜索了但我总是找到它用C语言...
If you want to read value in al
into an int
:如果要将al
值读入int
:
GCC:海湾合作委员会:
unsigned char out;
asm volatile("movb %%al, %[Var]" : [Var] "=r" (out));
Or或者
unsigned char out;
asm volatile("movb %%al, %0" : "=r" (out));
For MSVC:对于 MSVC:
unsigned char c;
__asm movb c, al
There's no official C++ way, it stems it from C.没有官方的 C++ 方式,它源于 C。
EDIT编辑
You might also want:您可能还想要:
register unsigned char out asm("%al");
But that's GCC.但那是海湾合作委员会。
You mean like:你的意思是:
int read_register_eax()
{
int ret;
asm { mov [ret],eax }
return ret;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.