2
votes

I'm trying to figure out how to pull a register value from an ASM instruction and into a variable in C++.

For example: MOV DWORD PTR DS:[ESI],EDI

(Assuming value EDI holds is an int) int Value = EDI;

1
Of course, by the time your code executes, the value in the registers may have changed. What are you really trying to do? Perhaps you should be getting it from a context record or something. - Raymond Chen

1 Answers

5
votes

Depends on your compiler. Search for "inline assembly" and the compiler you use. For example with VC++

   int32_t x;
   _asm mov x, eax;

(might be __asm). GNU uses different syntax