visual c++ - how to set labels in inline assembly? -


how in c++ visual can set labels when need use inline assembly, example...

__asm {     push eax     push var1     mov ecx,dword ptr ds:[var2]     call dword ptr ds:[var3]     jmp var4 } 

where var varables link value or address?

i have tried following

dword   var2 = 0x991770;    //0x991770 location of function  __asm {     ..code     mov ecx,dword ptr ds:[var2]     ..code } 

but app crashes, how done?

use offset variablename access variables inline assembly. see reference here.

example:

char format[] = "%s %s\n"; char hello[] = "hello"; char world[] = "world"; int main( void ) {    __asm    {       mov  eax, offset world       push eax       mov  eax, offset hello       push eax       mov  eax, offset format       push eax       call printf       //clean stack main can exit cleanly       //use unused register ebx cleanup       pop  ebx       pop  ebx       pop  ebx    } } 

Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c++ - Using OpenSSL in a multi-threaded application -

All overlapping substrings matching a java regex -