views:

54

answers:

3

When I try to make an immediate call or jump in VC++ 2010 inline assembler

_asm 
{
    call 00405B90h;
    jmp 00405B90h;
    jmp far 00405B90h;
}

it generates an error

C2415: improper operand type

Is it possbile and how to do this?

So far I have a work around:

_asm 
{
    push 00405B90h; // This is a jump work around
    call 00405B90h;        
}
A: 

See how this implementation does Using Two Common 'Compression' Techniques - Huffman ATL/COM

Try this one "Jumping to Labels in Inline Assembly"

lsalamon
Could you post an example here? I couldn't find anything. There are only jumps to labels. No jumps to addresses.
Max
Remember : Inline assembly is not supported on the Itanium and x64 processors.
lsalamon
+1  A: 

depending on what you want to call, either set a var to the address and do:

DWORD var = 0xDEADBEEF;
__asm jmp [var]

or, what I do:

__asm
{
    mov eax,ModuleBase
    add eax,RVA
    call eax ;obviously call can be jmp
}

you can easily macro this(probably a good idea to add a register param):

#define JMP_IMM(x) __asm mov eax,x \
                   __asm jmp eax
Necrolis
Thanks. That would work. I'm still wondering why the immediate jump/call instructions do not compile.
Max
@Max: more than likely due to the fact that the compiler cannot deduce whether its a short, local or far jump/call(due to it not being able to know the address of the outputted binary when virtualised)
Necrolis
I've tried putting 'far' modifier. Anyway I think it's just not possible. At least in VC++. Thanks.
Max
A: 

__asm jmp fword ptr cs:[00405B90h]

plan9assembler
I get the same error C2415: improper operand type. Does it work for you?
Max
operand edited.
plan9assembler