Why Inline asm in C++/CLI creates horrible problem?

Hello,

I am extremely begginer and at at most novice level for playing with assembly.

I am using Inline asm in C++/CLI. Horrible problem infact could be a bug I obsereved. I passed vector from one function call to another. If I comment the whole code snippet of _asm{....some assembly code here} inside the called function where vector used which are provided to it from other function, then no problem whole vector gets fine and copied to argument of called function successfully in correct manner.

But If uncomment _asm{} I mean if I use _asm{} patch in called function , it corrupts the whole vectors of objects, even single string which is participating as in parameter to the function .Infact every most of arguments as data of called function get corrupts where _asm code used. It just shows for every argument values like npos=4294967295. I was expecting string argument would contain valid "strings" and all other rest of parameter would have their correct states. which I just passed from other functions to that called function.


I am amazed while debugging the exe that even before reaching to the point of "_asm" at code , whole data before "_asm" place gets corrupts. Its just like unbelieveable.

EVEN IF I COMMENT EVERYTHING INSIDE _asm PATCH, AND HAVING JUST _asm{} EMPTY OPENING CLOSING BRACES AFTER _asm KEYWORD, STILL THE PROBLEM HAPPENS

Here If I dont write anything at all inside _asm{} even then problem occurs which I described.

What is it? Why this is so? Is CLI creating problem or I am using inline asm in wrong way?
Do I need to save the states of registers?

Kindly help me out , as I am stuck here.

example code:

strParamType = strReturnType;
if(strParamType.find("IDispatch")!=string::npos)
{
IDispatch* pIDispatch;
_asm
{
mov esi,esp
lea eax,[pIDispatch]
push eax
}
}



Regards
Usman
First of all consult your C++ manual about what registers are available from the compiler.
Then carefully observe its calling conventions. C++ has a lot of them published as well as
not along with various combinations.
Your not stuck but intervene something that is in the compiler jurisdiction.
Thus, it bytes in return.


I am using C++/CLI. Here I am temporarily switching to the native mode by just issuing #pragma (push,off).

So complete C++/CLI with .NET framework 4.0 is the complete environment on which I am working. What kind of other things needs to remember along with this?
Kindly help me out as I am new bie to work in assembly and I am completely stuck here.

I would be obliged and so kind of you If you help me out and solve my problem.
I do not have such a manual. The pragma without it
in conjunction with the ASM is giving a little clue.
I don't get it from the piece of code.
As soon as you are in ASM it does not matter.
Really. For sure there is nothing wrong with
the professional compiler.
Topic archived. No new replies allowed.