vc中使用汇编asm文件
2008-05-27 10:25
260 查看
use ASM and CPP together:
1. create an ASM file
;;;;;;;;;;;;; asmsrc.asm:
.386
.model flat, stdcall
option casemap :none
.code
myasmproc proc dw1:DWORD,dw2:DWORD
mov eax,dw1
add eax,dw2
ret
myasmproc endp
end
;;;;;;;;;;;;end of asmsrc.asm
2. create a VC project name: useasm, type console application, A "Hello World" application
3. move the asm file to your project directory, then in VC project menu->Add to Project...->Files...
Files of type change to "all files", then you can select the asmsrc.asm, and click OK
4.in workspace window, FileView tab, select asmsrc.asm, right click to select "settings..." menu, custom build tab, put the following in commands edit box :
d:/masm32/bin/ml.exe /nologo /coff /Zf /c /Sa $(InputName).asm
put the following in Outputs edit box:
$(InputName).obj
5.edit your useasm.cpp as the following:
//////////////////////useasm.cpp///////////////////////////////
#i nclude "stdafx.h"
#i nclude <windows.h>
extern "C" int __stdcall myasmproc(DWORD d1,DWORD d2);
int main(int argc, char* argv[])
{
printf("test of using cpp and asm together, if it works, it is done by masterz,otherwise I don't know who write this^_^/n");
int ret=myasmproc(22,33);
printf("ASM result:%d/n",ret);
return 0;
}
//////////////////////end of useasm.cpp///////////////////////////////
6. build the project and run it, it works.
notes: I assume you have installed masm32V8(you can get it from http://www.movsd.com/masmdl.htm) at D:/masm32
http://www.oioj.net/blog/user2/16215/archives/2005/103563.shtml
1. create an ASM file
;;;;;;;;;;;;; asmsrc.asm:
.386
.model flat, stdcall
option casemap :none
.code
myasmproc proc dw1:DWORD,dw2:DWORD
mov eax,dw1
add eax,dw2
ret
myasmproc endp
end
;;;;;;;;;;;;end of asmsrc.asm
2. create a VC project name: useasm, type console application, A "Hello World" application
3. move the asm file to your project directory, then in VC project menu->Add to Project...->Files...
Files of type change to "all files", then you can select the asmsrc.asm, and click OK
4.in workspace window, FileView tab, select asmsrc.asm, right click to select "settings..." menu, custom build tab, put the following in commands edit box :
d:/masm32/bin/ml.exe /nologo /coff /Zf /c /Sa $(InputName).asm
put the following in Outputs edit box:
$(InputName).obj
5.edit your useasm.cpp as the following:
//////////////////////useasm.cpp///////////////////////////////
#i nclude "stdafx.h"
#i nclude <windows.h>
extern "C" int __stdcall myasmproc(DWORD d1,DWORD d2);
int main(int argc, char* argv[])
{
printf("test of using cpp and asm together, if it works, it is done by masterz,otherwise I don't know who write this^_^/n");
int ret=myasmproc(22,33);
printf("ASM result:%d/n",ret);
return 0;
}
//////////////////////end of useasm.cpp///////////////////////////////
6. build the project and run it, it works.
notes: I assume you have installed masm32V8(you can get it from http://www.movsd.com/masmdl.htm) at D:/masm32
http://www.oioj.net/blog/user2/16215/archives/2005/103563.shtml
相关文章推荐
- vc中使用汇编asm文件 收藏 (转)
- vc下使用asm文件
- vc生成MIF文件,ROM使用
- VC如何设置使用mysql的相关文件
- VC操作INI文件 ,INI文件操作总结,如何操作INI文件,INI文件使用方法小结
- 使用 ASMCMD 工具管理ASM目录及文件
- VC中使用低级音频函数WaveX播放声音文件
- 使用 ASMCMD 工具管理ASM目录及文件
- 【原创】VC中多文件工程的PCLint使用详解
- VC ++ 6.0 环境中LIB 与DLL 文件的使用
- VC 中使用Log 记录文件
- 关于oracle 11.2.0.4 使用asm磁盘组条件下对应用数据表空间文件的rename alias操作
- 转:VC++中使用内存映射技术处理大文件
- ORACLE 10g中ASMCMD使用及ASM文件
- 使用RMAN在ASM和文件系统之间拷贝数据
- VC 中使用内存映射文件处理大文件
- VC中使用Socket网络文件传输结构
- 使用dex2jar反汇编android的apk文件 jd-gui
- 使用Idaq工具查看可执行文件ARM汇编代码
- 在u-boot C语言文件中使用汇编文件中定义的变量