提问人:R.T. 提问时间:11/11/2023 更新时间:11/11/2023 访问量:55
Windows 10 NASM ASM EXE 你好世界
Windows 10 NASM ASM EXE Hello World
问:
我一直在寻找 Stack Overflow 的工作汇编 Hello World 代码。我正在使用 NASM 和 GCC。
我试过这个asm:
global _main
extern _GetStdHandle@4
extern _WriteFile@20
extern _ExitProcess@4
section .text
_main:
; DWORD bytes;
mov ebp, esp
sub esp, 4
; hStdOut = GetstdHandle( STD_OUTPUT_HANDLE)
push -11
call _GetStdHandle@4
mov ebx, eax
; WriteFile( hstdOut, message, length(message), &bytes, 0);
push 0
lea eax, [ebp-4]
push eax
push (message_end - message)
push message
push ebx
call _WriteFile@20
; ExitProcess(0)
push 0
call _ExitProcess@4
; never here
hlt
message:
db 'Hello, World', 10
message_end:
它通过 NASM 和 GCC 编译良好,但运行它会导致一个 cmd 窗口,该窗口的可见时间不到一帧,没有 hello world。然后我还意识到我得到代码的帖子是 14 年前的。有什么帮助吗?
答: 暂无答案
评论
nasm h.asm -o h.obj -f win32
link h.obj kernel32.lib /entry:main