Question

I have a C++ project created in VS6 that was opened in VS2010 and compiles fine. It contains a class with a bit of inline assembly including the following code:

__asm{
  mov eax,this
  mov esi,[eax].m_pImage
  ...

All fine and dandy, until I try and create a new MFC C++ project in VS2010 and add the class with the assembly code shown above. Suddenly, this will not compile as the newer interpretation of __asm requires the code to be as follows (or something similar; this compiles in any case):

__asm{
  mov eax,this
  mov esi,[eax]this.m_pImage
  ...

Now, for the life of me, I can not figure out what the difference is between the two projects which allows the converted VS6 project to compile the (presumable currently invalid) inline assembly code in VS2010, while a newly created project can't.

Is there somewhere a (hidden) setting which allows one to use the old VS6 compiler?

Was it helpful?

Solution

The VS6 inline ASM seems like a bug that was fixed. I say that because I am not sure how the compiler could verify that m_pImage was a member of what was loaded in the eax register and therefore could not find the offset. To answer your question, there is no way, I am aware of, to use the old ASM semantics in the VS6 compiler.

I would make a local variable outside of the inline ASM and assign that to esi instead.

void * pointer = this.m_pImage;
__asm
{
   mov ebx, pointer
   mov esi, ebx
   ...
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top