我是 x86 汇编的新手,最近使用 nasm 做了一些实验并在 Windows 10 计算机上运行该程序。
我有这个代码:
global _start
extern _GetStdHandle@4
extern _WriteFile@20
extern _ExitProcess@4
section .data
message db "1234"
section .text
_start:
call print
call _ExitProcess@4
print:
; 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 4
push message
push ebx
call _WriteFile@20
mov esp, ebp
ret
; ExitProcess(0)
Run Code Online (Sandbox Code Playgroud)
我使用以下命令组装它: …