Question about inserting assembly code in C++
- by Bruce
I am working on VC++ compiler. I want to accomplish the following
The variables s.AddrFrame.Offset and s.AddrStack.Offset contain the value of EBP and ESP respectively. I want to extract the value of old EBP and the return address. Assuming the address EBP + 1 contains the old 32 bit EBP value and EBP + 5 the return address I wrote the following code:
unsigned int old_ebp = 0;
unsigned int ret_addr = 0;
__asm{
mov old_ebp, DWORD PTR [s.AddrFrame.Offset + 1]
mov ret_addr, DWORD PTR [s.AddrStack.Offset + 5]
}
But this is not compiling
xxxx.cpp(1130) : error C2415: improper operand type
Please Help