use ASM and CPP together
来源:互联网 发布:js循环数组 编辑:程序博客网 时间:2024/05/22 14:17
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///////////////////////////////
#include "stdafx.h"
#include <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
;;;;;;;;;;;;; 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///////////////////////////////
#include "stdafx.h"
#include <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
- use ASM and CPP together
- How to use UTF-8_with_BOM, XML and Java together
- How to use Trace2UML together with Doxygen
- asm[dynamically produce a class and use it without writing it to disk]
- About how to use Edit Control and SPin Control together! (关于怎么组合使用Edit Control 和 Spin Control 增加浮点数)
- Together,
- GeoWorld: KML and GML Working Together
- How Blocks And PHTML Work Together
- Bringing Big Data and Smart Energy Together
- Powerpath and VxVM work together mechanism
- combine facebook and google/Twitter together
- ASM and Process 杂项
- asm and c language
- Install and Configure ASM
- ASM Metadata and Internals
- Cpp inner asm block for add operating
- cpp thread and tip
- IDL Files and Cpp
- Windows下的函数hook技术
- C#中类的继承问题03
- 关于Windows下ShellCode编写的一点思考
- 内核级利用通用Hook函数方法检测进程
- 2007年1月26日、离散数学复习一
- use ASM and CPP together
- C#中类的继承问题04
- 2007年1月26日、离散数学中三个概念
- 潜入II即将发布!
- 浩方战网平台分析
- 你为谁工作?
- RC4 加密
- Execute a function in any Win32 DLL - Reflection in Win32 DLL?
- 男人25岁的忠告