Jump to content
  • Advertisement
Sign in to follow this  
roos

Inline assembly question

This topic is 4772 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
Advertisement
mov esi, dword ptr theArray

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

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
Cool, thanks very much for the help!

EDIT: It looks like both ways work fine :) Thanks again!

roos

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!