Sign in to follow this  

Inline assembly question

This topic is 4562 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

Hi, I'm working on some inline assembly in Visual c++ .net 2k3. I was trying to copy the address of an array into esi, but it says the size doesn't match. So I had to create a separate pointer which points to the array first. Is there any way around doing this? (example below)
char theArray[arraySize];
char *p = theArray;

__asm
{
    mov esi, p   // have to use p instead of theArray
}


Thanks! roos

Share this post


Link to post
Share on other sites
Quote:
Original post by deffer
mov esi, dword ptr theArray

It compiles, but I'm not completely sure if it will peform what you really want...
/def


It is supposed to work accordingly to OP's needs (it will copy the adress of the beginning of the array into esi).

Regards,

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I've seen VS being kind of flaky with this stuff.
If I'm loading the start of an array, I do:


__asm {
lea esi, [theArray] // lea == load effective address, [] == dereference
}


so all in all, it means "load the address of the first array element"

Share this post


Link to post
Share on other sites

This topic is 4562 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this