是有可能访问的32位寄存器中C 2 [英] Is it possible to access 32-bit registers in C?

查看:101
本文介绍了是有可能访问的32位寄存器中C 2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能访问32位寄存器用C?如果是,怎么了?如果没有,那么有没有什么办法可以嵌入大会code用C?我真的使用MinGW的编译器,顺便说一句。
在此先感谢!

Is it possible to access 32-bit registers in C ? If it is, how ? And if not, then is there any way to embed Assembly code in C ? I`m using the MinGW compiler, by the way. Thanks in advance!

推荐答案

如果你想为只读寄存器,你可以简单的:

If you want to only read the register, you can simply:

register int ecx asm("ecx");

显然,这是依赖于实例。

Obviously it's tied to instantiation.

另一种方法是使用内联汇编。例如:

Another way is using inline assembly. For example:

asm("movl %%ecx, %0;" : "=r" (value) : );

本存储 ECX 值到变量。我已经发布了类似的答案<一个href=\"http://stackoverflow.com/questions/2582629/how-to-determine-values-saved-on-the-stack/2582902#2582902\">here.

This stores the ecx value into the variable value. I've already posted a similar answer here.

这篇关于是有可能访问的32位寄存器中C 2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆