| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1137 人关注过本帖
标题:[求助]内联的汇编语言怎么在c++中使用
只看楼主 加入收藏
taijixing
Rank: 1
等 级:新手上路
威 望:1
帖 子:118
专家分:0
注 册:2007-6-9
收藏
 问题点数:0 回复次数:3 
[求助]内联的汇编语言怎么在c++中使用

#include <iostream>

using namespace std;

class Beepers
{
public:
void beep();
void beepbeep();

};

void Beepers::beep()
{
asm
{
mov ah,2;
mov dl,7;
int 0x21;
}
}

void Beepers::beepbeep()
{
asm
{
mov ah,2;
mov dl,7;
int 0x21;
mov ah,2;
mov dl,7;
int 0x21;
}
}


int main()
{
Beepers noise;
noise.beep();
noise.beepbeep();
return 0;
}

大家看看是什么错误!


--------------------Configuration: derived - Win32 Debug--------------------
Compiling...
derived.cpp
E:\vc++\add\derived\derived.cpp(16) : error C2059: syntax error : '{'
E:\vc++\add\derived\derived.cpp(16) : error C2143: syntax error : missing ';' before '{'
E:\vc++\add\derived\derived.cpp(17) : error C2065: 'mov' : undeclared identifier
E:\vc++\add\derived\derived.cpp(17) : error C2146: syntax error : missing ';' before identifier 'ah'
E:\vc++\add\derived\derived.cpp(17) : error C2065: 'ah' : undeclared identifier
E:\vc++\add\derived\derived.cpp(18) : error C2146: syntax error : missing ';' before identifier 'dl'
E:\vc++\add\derived\derived.cpp(18) : error C2065: 'dl' : undeclared identifier
E:\vc++\add\derived\derived.cpp(19) : warning C4091: '' : ignored on left of 'int' when no variable is declared
E:\vc++\add\derived\derived.cpp(19) : error C2143: syntax error : missing ';' before 'constant'
E:\vc++\add\derived\derived.cpp(26) : error C2059: syntax error : '{'
E:\vc++\add\derived\derived.cpp(26) : error C2143: syntax error : missing ';' before '{'
E:\vc++\add\derived\derived.cpp(27) : error C2146: syntax error : missing ';' before identifier 'ah'
E:\vc++\add\derived\derived.cpp(28) : error C2146: syntax error : missing ';' before identifier 'dl'
E:\vc++\add\derived\derived.cpp(29) : warning C4091: '' : ignored on left of 'int' when no variable is declared
E:\vc++\add\derived\derived.cpp(29) : error C2143: syntax error : missing ';' before 'constant'
E:\vc++\add\derived\derived.cpp(30) : error C2146: syntax error : missing ';' before identifier 'ah'
E:\vc++\add\derived\derived.cpp(31) : error C2146: syntax error : missing ';' before identifier 'dl'
E:\vc++\add\derived\derived.cpp(32) : warning C4091: '' : ignored on left of 'int' when no variable is declared
E:\vc++\add\derived\derived.cpp(32) : error C2143: syntax error : missing ';' before 'constant'
执行 cl.exe 时出错.

derived.exe - 1 error(s), 0 warning(s)

搜索更多相关主题的帖子: 内联 汇编语言 
2007-08-06 19:11
maoguoqing
Rank: 6Rank: 6
来 自:重庆
等 级:贵宾
威 望:28
帖 子:2980
专家分:19
注 册:2005-12-5
收藏
得分:0 
我不太懂汇编 不过C++中用好像是 _asm{...}用的


天行健,君子以自强不息!!QQ:68660681
2007-08-06 20:58
hwbnet
Rank: 1
等 级:新手上路
威 望:2
帖 子:355
专家分:0
注 册:2004-12-9
收藏
得分:0 
mov ah,2;
mov dl,7;
int 0x21;
⒈ 汇编语言结尾没有分号。
⒉ DOS功能调用,显示字符,WIN32应用程序不能调用。

胡文斌 本人论坛:http://hwbnet.bbs./
2007-08-07 04:41
taijixing
Rank: 1
等 级:新手上路
威 望:1
帖 子:118
专家分:0
注 册:2007-6-9
收藏
得分:0 
谢谢
2007-08-07 21:13
快速回复:[求助]内联的汇编语言怎么在c++中使用
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.026099 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved