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;
}
If you really need to do it via assembler, try
__asm lea ebx, n;
__asm mov addr, ebx;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.