MSVC inline assembler equivalent of address operator "&"?

Dear all,

Why can i get the address of local variables in inline assembler in MSVC?

void func(
  int* a,
  int b
){
   int c;
   int* d;

  __asm mov eax, addressOf b ?
  (in C code , it would be: eax=&c)

}

thank you.
hengck23Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

dimitryCommented:
Its address is ebp+12 in C-convention.
I think you need to use:
  __asm mov eax, offset b
0
hengck23Author Commented:
I tried the keyword OFFSET, but it doesn't work.
I think "OFFSET" only works in the main function.
0
dimitryCommented:
You mean OFFSET works only for Global Data... Maybe you are right.
Again it is very simple:
After:
  push ebp
  mov ebp, esp
Stack frame looks like:
  ebp                 [ebp]
  return address [ebp + 4]
  param1           [ebp + 8]
  param2           [ebp + 12]

In Pascal convention, you need to switch addresses of param1 and param2.

0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

hengck23Author Commented:
Hi,

I know about  "param-N          [ebp + 4+N*4]". I was just wondering is there a MARCO expression for this in MSVC inline assember.
0
dimitryCommented:
Can you try
  mov  eax, addr b
0
grg99Commented:
you want o say  :   lea    eax,[ebp+LocalVar]
0
BeyondWuCommented:
void func( int* a,  int b)
{
   int c;
   int* d;

   //__asm mov eax, addressOf b ?
   _asm lea eax, b
}
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
hengck23Author Commented:
I am looking for a MACRO expression. But I guess there is none. I would have to use "lea (to get address)" or ,"mov ... [EBP+ ... ] (to get value)" then.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Assembly

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.