Is it possible to access 32-bit registers in C?

后端 未结 7 1296
猫巷女王i
猫巷女王i 2020-12-14 11:55

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. Th

7条回答
  •  [愿得一人]
    2020-12-14 12:17

    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) : );
    

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

提交回复
热议问题