我使用的是 Windows 11。 我在将 asm 文件编译为 64 位时遇到问题。
汇编代码: 1 种方法 2方法 我已经尝试了所有方法,但 Windows 仍然将 exe 文件视为 16 位
请帮忙 我想学习 asm lang ;)
使用 Windows 系统调用进行编码
section .data
hello_msg db 'Hello, world!'
section .text
extern _MessageBoxA@16
extern _ExitProcess@4
global _WinMain@16
_WinMain@16:
push dword 0
push dword hello_msg
push dword hello_msg
push dword 0
call _MessageBoxA@16
push dword 0
call _ExitProcess@4
更正的 makefile:
all:
nasm -f win32 hello.asm -o hello.obj
gcc -m32 hello.obj -o hello.exe -L"F:/mingw/lib" -luser32 -lkernel32
start:
hello.exe
一些问题出现如下:
ld -m32 hello.obj -o hello.exe -luser32 -lkernel32
ld: unrecognised emulation mode: 32
Supported emulations: i386pe
ld -mi386pe hello.obj -o hello.exe -luser32 -lkernel32
ld: cannot find -luser32
ld: cannot find -lkernel32
但至少它有效
PS:在 Windows 上组装比较困难;/