asm - convert.

01/14/2012 23:41 Dinitr#1
Hi, can I ask you to rework it so that you can compile the Dev-C++

Code:
int getCharW(int Font, char* Name, int nAlign)
{
    int TextLen = strlen(Name);
    int nret = 0;
    __asm
    {
        push nAlign
        push TextLen
        push Text
        push Font
        call Addr  // Addr = 0x3ABC11
        mov nret, eax
    }
    return nret;
}
01/15/2012 10:39 jacky919#2
Look [Only registered and activated users can see links. Click Here To Register...]
It's a tutorial about inline asm with GNU C++ on windows
01/15/2012 11:54 Dinitr#3
i try:

Quote:
asm("push %0" :: "g" (nAlign));
asm("push %0" :: "g" (TextLen));
asm("push %0" :: "g" (Text));
asm("push %0" :: "g" (Font));
asm("call" :: "g" (Addr));
asm("mov %eax, nret");
error: suffix or operands invalid for `call'

and

[Linker error] undefined reference to `nret'
01/15/2012 12:04 yihaaa#4
Maybe you can use a function pointer?
01/15/2012 12:33 Dinitr#5
to Addr ?
01/15/2012 12:39 yihaaa#6
typedef int ( *func )( int Font, char* Text, int len, int nAlign );

func _func = reinterpret_cast< func > ( 0x3ABC11 );

int getCharW(int Font, char* Name, int nAlign)
{
int TextLen = strlen(Name);
return _func ( Font, Name, TextLen, nAlign );
}

Or so