Visual Studio-X64汇编编写
纯64位汇编:
includelib ucrt.lib
includelib legacy_stdio_definitions.lib
includelib user32.lib
extern printf:proc
extern MessageBoxA:proc
.data
szFormat db "%s",0
szHello db "HelloWorld",0
szRk db "123",0
.code
start proc
sub rsp,28h
mov rdx,offset szHello
mov rcx,offset szFormat
call printf
mov r9,0
mov r8,offset szHello
mov rdx,offset szRk
mov rcx,0
call MessageBoxA
add rsp,28h
ret
start endp
end
注意:
1.平台工具集要选VS2015
2.属性->生成依赖项->masm
3.链接器->高级->入口点
64位混合编程(C++/Asm):
1.asm:
includelib legacy_stdio_definitions.lib
includelib user32.lib
extern printf:proc
.data
szformat db "%s\n",0
.code
Myadd proc
sub rsp,28h
add rcx,rdx
movrax,rcx
add rsp,28h
ret
Myadd endp
Myprintf proc
sub rsp,28h
mov rdx,rcx
lea rcx,szformat
call printf
add rsp,28h
ret
Myprintf endp
end
main.cpp:
#include <iostream>
#include <windows.h>
EXTERN_C UINT64 Myadd(UINT64 a, UINT64 b);
EXTERN_C void Myprintf(const char* szbuffer);
int main()
{
UINT64 num = Myadd(1, 2);
printf("%lld\r\n", num);
Myprintf("hello word");
system("pause");
return 0;
}
注意:
如果生成报错,并且没有属性里面没有Microsoft Macro Assembler,换成VS2015也没有的话,
就在源文件里面找到.asm后缀的文件右键属性->常规->项类型->Microsoft Macro Assembler即可。
原文地址:https://blog.csdn.net/weixin_48257887/article/details/142369652
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!