我如何使用C ++从寄存器读取值 [英] how can i read value from register using C++
本文介绍了我如何使用C ++从寄存器读取值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在用C ++编写一个计算器的代码,但它显示并读取了汇编结果,我想将该值存储在任何寄存器中,例如(Al)到C ++中的int变量...我搜寻了但我总是用C语言找到它...
I am writhing code with C++ for a calculator ,but it display\read results with assembly,I want to store the value in any register for example( Al )to variable int in C++... I searched for away but I always find it with C language ...
推荐答案
如果要将al
中的值读入int
:
海湾合作委员会:
unsigned char out;
asm volatile("movb %%al, %[Var]" : [Var] "=r" (out));
或
unsigned char out;
asm volatile("movb %%al, %0" : "=r" (out));
对于MSVC:
unsigned char c;
__asm movb c, al
没有正式的C ++方式,它源于C.
There's no official C++ way, it stems it from C.
编辑
您可能还想要:
register unsigned char out asm("%al");
但这就是海湾合作委员会.
But that's GCC.
这篇关于我如何使用C ++从寄存器读取值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文