Reputation: 95
I want a code to get the address of a variable using inline assembly with C++.
I'm doing this way, but it takes a value and not the address
#include <stdio.h>
#include <windows.h>
int main()
{
int n = 5;
DWORD addr;
__asm mov ebx, n;
__asm mov addr, ebx;
printf("%x", addr);
return 0;
}
Upvotes: 1
Views: 1367
Reputation: 32616
If you really need to do it via assembler, try
__asm lea ebx, n;
__asm mov addr, ebx;
Upvotes: 3