tags:

views:

257

answers:

1

how do i declare a jump table in inline assembly language? I want to do the code below, but msvc is not taking the dd lines.

I also tried _asm _emit offset label1 but it only spit out 1 byte

_asm _emit (offset label1) >> 8 doesn't compile either so I can't do it a byte at a time.

_asm {
    jmp skiptable

jmptable:
    dd offset label1
    dd offset label2

skiptable:
    jmp [table + 4*eax]

label1:
    ....

label2:
    ....
}
+1  A: 

Unfortunately _asm is a bare subset of actual assembly. You can't use data directives and as you noticed _emit only does a byte.

From Microsoft's docs:

Although an __asm block can reference C or C++ data types and objects, it
cannot define data objects with MASM directives or operators. Specifically,
you cannot use the definition directives DB, DW, DD, DQ, DT, and DF, or the
operators DUP or THIS.

Unless you can build the jump table in C I'm pretty sure that you can not use a jumptable in inline assembly.

Aaron