c++ - 在 C++ 中使用 ASM

标签 c++ assembly

我正在使用以下代码:

int _tmain(int argc, _TCHAR* argv[])
{
    __asm{ 
           "MOV EAX, DMSN[0]";
           "LEA EBX, DMSN[0]";
           "CALL EBX";
         };
    return 0;
}

MOV EAXLEA EBX,稍后将包含两个不同的数组。 但至于示例,它们将包含相同的内容。

我正在使用以下内容:

const BYTE DMSN[694]={blah, blah, blah};

但我出现了这些错误:

1>c:\users\1337\documents\visual studio 2010\projects\test2\test2\test2.cpp(49): error     C2400: inline assembler syntax error in 'opcode'; found 'bad token'
1>c:\users\1337\documents\visual studio 2010\projects\test2\test2\test2.cpp(50): error     C2400: inline assembler syntax error in 'opcode'; found 'bad token'
1>c:\users\1337\documents\visual studio 2010\projects\test2\test2\test2.cpp(51): error     C2400: inline assembler syntax error in 'opcode'; found 'bad token'**strong text**

怎么了?

最佳答案

你的语法有问题,像这样使用它:-

 int _tmain(int argc, _TCHAR* argv[])
    {
      _asm{ 
           mov eax, DMSN[0]
           lea ebx, DMSN[0]
           call ebx
          }
        return 0;
    }

基于 VS 的编译器。

关于c++ - 在 C++ 中使用 ASM,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11949818/

相关文章:

c++ - 返回该对象(不是作为指针)时是否不打算调用析构函数?

c++ - 如何在一个类中存储多个位图?

c++ - OpenGL 3/GLFW 空白视口(viewport)

assembly - 比较汇编中的位

assembly - 在现有标签后两行设置 gdb 断点

c++ - 如何使用已知的非默认构造函数实例化未知大小的可变元组?

c++ - 为什么在对象表达式的上下文中找不到我的构造函数?

使用 gcc 编译 PowerPC 二进制文件并限制可用寄存器

assembly - 非常大的地址复制为负值

c - ARM Cortex 上的 super 简单 Tasker