环境为:win2000+VC6
以下源码:
_asm
{
   xor eax,1
   add eax,2
   jnz label1
   jz label1
   db 0E8h ;<----出错,说inline assembler syntax error in 'opcode'; found 'constant'
label1:
   xor eax,3
   add eax,4
   xor eax,5
}

解决方案 »

  1.   

    db 0E8h是分配一个字节,内容是十六进制的e8.
    在vc的嵌入式汇编里头不能用以下摘自msdnData Directives and Operators in Inline Assembly
    Home |  Overview |  How Do IAlthough 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. MASM structures and records are also unavailable. The inline assembler doesn’t accept the directives STRUC, RECORD, WIDTH, or MASK.
    --------------------------------------------------------------------------------
    Send feedback to MSDN.Look here for MSDN Online resources.
      

  2.   

    试试:
       db 0x0E8
             ~~
      

  3.   

    记得db好像是宏汇编的伪指令还记得vc内嵌的汇编指令中不能有伪指令
      

  4.   

    在汇编体外面用c的变量定义一个,比如BYTE var = 0x0E8;
      

  5.   

    同意  GR(永远问问题) __asm _emit 0xE8
      

  6.   

    今天外出没来看,晚上回来发现这么多朋友在帮我,感动ing... 。谢谢大家!经过测试:
    (1)用 db 0x0E8 还是不行的;
    (2)用_emit就可以了,不论是用 _asm{ } 块结构,还是每行都用 _asm 前缀,都行。不论给出的答案正确与否,见者有份都会给分,答案正确者会多点。想再问一下,_emit 0xE8 也是定义一个byte吗?如果不是的话,整个这段代码就失去了它的意义。
      

  7.   

    对的。_emit的功能基本上就够db是一样的。,只是一定要一个一个的定义。
      

  8.   

    GR(永远问问题):谢谢您的回答。也就是说,把 db 0xe8,0xE9 改写成
    _emit 0xE8
    _emit 0xE9
    就是等价的,对吧?