Jump to content
  • Advertisement
Sign in to follow this  
glitteringsound

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

This topic is 3042 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
The problem is not with IDispatch or even with any other thing used as assignment or push/pops.
Even I just write _asm{} with just opening and closing braces and nothing written in it, I mean no any assembly instruction written in it . Just empty body

_asm
{
}

Still it creates the problem.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!