GCC Inline-assembly: call dword ptr

If I have the following code in Windows VC ++:

DWORD somevar = 0x12345678;
_asm call dword ptr [somevar]

How can I do the same in the GCC inline assembly, with AT & T syntax?

__asm__ __volatile__ (
    "call dword ptr [%%edx]" : :
    "d" (somevar)
);

I tried something like this, but it generates a garbage error ...

And then I tried to transfer somevarto some registers, and then convert it to dword, ptretc., but I could not get it to work.

UPDATE: I found something useful, it seems that in this case we should use brackets instead of brackets, and I found something with lcallto call far, but I still can’t figure out how I can reproduce dword ptr.

+5
1

DWORD PTR - AT & T. ( ), , , C, asm(). , , , x86_64 i386. - call *%rdx, call *%edx:

#include <stdio.h>
void p()
{
    puts("Hallo");
}
typedef void (*fp)();
int main()
{
    fp var=&p;
    var();  
    // put 'var' in a register, the '*' says call indirect:
    asm volatile ("call *%0"::"r"(var));
}

, GCC ( -S), AT & T. - google, :

: gcc . , , , . , ( "r" ), , . , , " ".

+7

All Articles