标签:dll file details roc target sem text include inf
参考了以下两个博客文章
http://blog.csdn.net/x356982611/article/details/51260841
http://www.cnblogs.com/antoniozhou/archive/2008/10/23/1318287.html
首先到CodeProject下载NASM的VS配置文件
https://www.codeproject.com/Articles/410776/Integrating-a-compiler-assembler-in-VS-Using-NASM
解压3个配置文件到
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\BuildCustomizations
也就是和masm的配置文件相同的位置
然后把NASM加入到系统环境变量
D:\nasm-2.13.01
新建一个控制台空工程,同之前MASM的一样,只不过这次选NASM
http://www.cnblogs.com/kileyi/p/7257852.html

建立1个cpp和1个asm文件
cpp01.cpp
#include <iostream>
void main();
extern "C" void nasm_function(void);
void main()
{
nasm_function();
system("pause");
}
asm01.asm
segment .text global _nasm_function _nasm_function: mov eax, 12345h ret
asm文件上,鼠标右键属性设置


编译应该就能通过了。
有趣的是MASM可以在ASM汇编代码上下断点,而NASM的却不行。不太清楚怎么回事,不过反正可以在cpp函数前下断点,也差不了太多。
接下来搞个纯ASM的测试
pure01.asm
;filename: sayhellon.asm
;cmd> nasm -fcoff -Xvc sayhellon.asm
;cmd> link sayhellon.obj
extern _MessageBoxA@16 ;in user32.dll
extern _ExitProcess@4 ;in kernel32.dll
global SayHello
global _WinMain
[SECTION .drectve info align=8]
db " /subsystem:windows"
db " /out:sayhellon.exe"
db " /defaultlib:kernel32.lib"
db " /defaultlib:user32.lib"
db " /export:SayHello"
db " /entry:WinMain"
db " /merge:.rdata=.text",0
[SECTION .text USE32 align=16]
szTitle:
db "SayHello",0
szMsg:
db "Hello World!", 0
SayHello:
push 0 ;uType
push dword szTitle ;lpCaption
push dword szMsg ;lpText
push 0 ;hWnd
call _MessageBoxA@16
ret 16
_WinMain:
call SayHello
push 0
call _ExitProcess@4
编译应该就能通过,如果不行,手动设置下工程属性中的入口函数

标签:dll file details roc target sem text include inf
原文地址:http://www.cnblogs.com/kileyi/p/7387803.html