内嵌汇编问题

时间:2022-02-17 04:06:57
请问在标准C++中怎样内嵌汇编代码,我在DEV C++中试了几下都没法编译.
请说明用的是何种编译器,是否是标准的

21 个解决方案

#1


__asm{

……
}

#2


各个环境的 嵌入汇编 的方式可能有一点区别的 ~
一般是类似
asm mov ah,9

或者是

__asm {}

#3


__asm {}

没发编译提示什么?

#4


gcc 是 AT&T 语法, 跟 Intel 的是不同地 .....

#5


同意楼上的
在at&t中应该是
asm("movw $9,%ax");

#6


如在DEV C++中运行以下代码:
#include <conio.h>
int main(void)
{
    __asm{
          mov ax,1
          }

      getch();
      return 0;
}
出错:
cc1plus.exe D:\Dev-Cpp\work\cc1plus.exe unrecognized command line option "-fsave-memoized" 
 D:\Dev-Cpp\work\Makefile.win [Build Error]  [test.o] Error 1 
DEV C++不是支持标准的吗,怎么没法编译?

#7


ISO/IEC 9899:1999说

J.5.10 The asm keyword
1 The asm keyword may be used to insert assembly language directly into the translator
output (6.8). The most common implementation is via a statement of the form:
asm ( character-string-literal );

STANDARD ISO/IEC14882说:

7.4 The asm declaration [dcl.asm]
1 An asm declaration has the form
asm-definition:
asm ( string-literal ) ;
The meaning of an asm declaration is implementation-defined. [Note: Typically it is used to pass information
through the implementation to an assembler. ]

asm ("movb $1, %ax"); 更多参见gcc 3.2.3(dev c++好像是gcc 3.2的版本)说明文档:http://gcc.gnu.org/onlinedocs/gcc-3.2.3/gcc/Extended-Asm.html#Extended%20Asm
再google以下“at&t assembly”

#8


偶打错了- -b
人民是对的:
mov ax,1 -> asm("movw $1, %ax");

#9


AT&T的汇编语法和intel的不一样,要注意的东西

#10


在VC++6下__asm{}十分通用

#11


学习

#12


以AT&T语法来写,还是出现
cc1plus.exe D:\Dev-Cpp\work\cc1plus.exe unrecognized command line option "-fdollar-in-identifiers" 

是不是哪些地方设置不对,请达人指点,不然立马将DEV C++删除,用MS!

#13


lz看一下帮助。
错误提示,是无法识别表示符号
unrecognized command line option

在VC中嵌入汇编
__asm
{
}

DEV C++ 中lz看看帮助吧

#14


好像就是
asm
{

}
前边没有下华线的

#15


GCC应该用ATT的汇编语法,可以找ATT汇编的参考手册看看!

#16


#include <conio.h>

int main()
{
          asm("movw $1,%ax");
          getch();
          return 0;
}

gcc test.c -o test
无问题通过。
gcc 3.4.2 (mingw-special)

#17


感谢各位!命令行下用GCC 可以,但在IDE中却不能.

#18


gcc (Dev c++)对c文件中的内嵌汇编使用AT&T汇编
而VC/BC/TC则使用Intel汇编

#19


gz

#20


mark

#21


gz

#1


__asm{

……
}

#2


各个环境的 嵌入汇编 的方式可能有一点区别的 ~
一般是类似
asm mov ah,9

或者是

__asm {}

#3


__asm {}

没发编译提示什么?

#4


gcc 是 AT&T 语法, 跟 Intel 的是不同地 .....

#5


同意楼上的
在at&t中应该是
asm("movw $9,%ax");

#6


如在DEV C++中运行以下代码:
#include <conio.h>
int main(void)
{
    __asm{
          mov ax,1
          }

      getch();
      return 0;
}
出错:
cc1plus.exe D:\Dev-Cpp\work\cc1plus.exe unrecognized command line option "-fsave-memoized" 
 D:\Dev-Cpp\work\Makefile.win [Build Error]  [test.o] Error 1 
DEV C++不是支持标准的吗,怎么没法编译?

#7


ISO/IEC 9899:1999说

J.5.10 The asm keyword
1 The asm keyword may be used to insert assembly language directly into the translator
output (6.8). The most common implementation is via a statement of the form:
asm ( character-string-literal );

STANDARD ISO/IEC14882说:

7.4 The asm declaration [dcl.asm]
1 An asm declaration has the form
asm-definition:
asm ( string-literal ) ;
The meaning of an asm declaration is implementation-defined. [Note: Typically it is used to pass information
through the implementation to an assembler. ]

asm ("movb $1, %ax"); 更多参见gcc 3.2.3(dev c++好像是gcc 3.2的版本)说明文档:http://gcc.gnu.org/onlinedocs/gcc-3.2.3/gcc/Extended-Asm.html#Extended%20Asm
再google以下“at&t assembly”

#8


偶打错了- -b
人民是对的:
mov ax,1 -> asm("movw $1, %ax");

#9


AT&T的汇编语法和intel的不一样,要注意的东西

#10


在VC++6下__asm{}十分通用

#11


学习

#12


以AT&T语法来写,还是出现
cc1plus.exe D:\Dev-Cpp\work\cc1plus.exe unrecognized command line option "-fdollar-in-identifiers" 

是不是哪些地方设置不对,请达人指点,不然立马将DEV C++删除,用MS!

#13


lz看一下帮助。
错误提示,是无法识别表示符号
unrecognized command line option

在VC中嵌入汇编
__asm
{
}

DEV C++ 中lz看看帮助吧

#14


好像就是
asm
{

}
前边没有下华线的

#15


GCC应该用ATT的汇编语法,可以找ATT汇编的参考手册看看!

#16


#include <conio.h>

int main()
{
          asm("movw $1,%ax");
          getch();
          return 0;
}

gcc test.c -o test
无问题通过。
gcc 3.4.2 (mingw-special)

#17


感谢各位!命令行下用GCC 可以,但在IDE中却不能.

#18


gcc (Dev c++)对c文件中的内嵌汇编使用AT&T汇编
而VC/BC/TC则使用Intel汇编

#19


gz

#20


mark

#21


gz