【问题标题】:MSVC x86 inline assembler switch statementMSVC x86 内联汇编器 switch 语句
【发布时间】:2009-11-23 17:42:02
【问题描述】:

如何在内联汇编语言中声明跳转表? 我想做下面的代码,但是 msvc 没有走 dd 行。

我也试过_asm _emit offset label1,但它只吐出 1 个字节

_asm _emit (offset label1) >> 8 也不编译,所以我不能一次编译一个字节。

_asm {
    jmp skiptable

jmptable:
    dd offset label1
    dd offset label2

skiptable:
    jmp [table + 4*eax]

label1:
    ....

label2:
    ....
}

【问题讨论】:

    标签: assembly


    【解决方案1】:

    不幸的是 _asm 是实际程序集的一个子集。您不能使用数据指令,并且您注意到 _emit 只执行一个字节。

    来自微软的文档:

    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. 
    

    除非您可以在 C 中构建跳转表,否则我很确定您不能在内联汇编中使用跳转表。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-17
      • 2014-06-19
      • 1970-01-01
      • 2021-10-01
      • 2011-02-08
      • 1970-01-01
      相关资源
      最近更新 更多