为什么不能用 _asm

Iluly 2007-10-28 04:51:43
我想在程序中嵌入asm指令,但编译时却提示391 wxutil.h `_asm ' undeclared (first use this function)
下面是源代码:


//……
_asm {
cld // make sure we get the direction right
mov ecx, cnt // num of bytes to scan
mov edi, buf // pointer byte stream
mov eax, chr // byte to scan for
repne scasb // look for the byte in the byte stream
jnz exit_memchr // Z flag set if byte found
dec edi // scasb always increments edi even when it
// finds the required byte
mov pRet, edi
exit_memchr:
}
//……



好多书上就说能这样用的,但为什么提示不行呀,怎么才能让编译器支持_asm呢?
希望哪位能解释一下~谢谢~


...全文
508 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
Iluly 2007-10-28
  • 打赏
  • 举报
回复
呵呵,_asm解决了,不过确实不习惯AT&T 的语法~,!
散分了~
我啃 2007-10-28
  • 打赏
  • 举报
回复
The "GNU as" assembler uses AT&T syntax (not Intel)
呵呵,由于习惯用INTEL的,用来AT&T的就觉得特别怪
语法是:
__asm("asm code here");
VC下是
__asm
{
asm code here
}
飞哥 2007-10-28
  • 打赏
  • 举报
回复
AT & T的,感觉头疼,写着费劲
我啃 2007-10-28
  • 打赏
  • 举报
回复
dev-cpp啊
那么就这样:

How to use assembly with Dev-C++ ?
The "GNU as" assembler uses AT&T syntax (not Intel). Check out this page for more information.
Here's an example of such a syntax :

// 2 global variables
int AdrIO;
static char ValIO;

void MyFunction(..........)
{
__asm("mov _AdrIO, %dx") ; // loading 16 bits register
__asm("mov _ValIO, %al") ; // loading 8 bits register
/*
Don't forget the underscore _ before each global variable names !
*/
__asm("mov %ax,%dx") ; // AX --> DX
}


I am using Windows
飞哥 2007-10-28
  • 打赏
  • 举报
回复
dev,我现在没有爱

要不你就试 asm{}
Iluly 2007-10-28
  • 打赏
  • 举报
回复
我用的dev-C++
我啃 2007-10-28
  • 打赏
  • 举报
回复
VC下是__asm双下划线
GCC好像是asm()
飞哥 2007-10-28
  • 打赏
  • 举报
回复
胡扯了不是
啥编译器啊

64,654

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧