nasm -f win64 hello.asm -o hello.obj x86_64-w64-mingw32-ld hello.obj -o hello.exe -lkernel32 8.1 Check basic info (using dumpbin ) dumpbin /headers myapp.exe | findstr "machine magic subsystem" Output example:
PE32+ executable (console) x86-64 for MS Windows
It breaks down as:
cl /O1 /GS- /Gs9999999 minimal_console.c /link /SUBSYSTEM:CONSOLE /MACHINE:X64 /ENTRY:main Check output:
main: sub rsp, 40 ; shadow + align mov rcx, -11 ; STD_OUTPUT_HANDLE call GetStdHandle mov rcx, rax lea rdx, [msg] mov r8, 23 ; length lea r9, [rsp + 32] ; lpNumberOfBytesWritten call WriteFile xor rcx, rcx call ExitProcess pe32 executable -console- x86-64 for ms windows
my_func PROC push rbp mov rbp, rsp sub rsp, 32 ; shadow space + locals ; ... add rsp, 32 pop rbp ret my_func ENDP 7.1 Using MSVC (Visual Studio) cl /c hello.c link hello.obj /SUBSYSTEM:CONSOLE /MACHINE:X64 7.2 Using MinGW-w64 (gcc) x86_64-w64-mingw32-gcc -m64 hello.c -o hello.exe 7.3 Using NASM + LD (raw assembly) ; hello.asm bits 64 section .data msg db 'Hello PE32+ console', 0xd, 0xa, 0 section .text global main extern GetStdHandle extern WriteFile extern ExitProcess
dumpbin /headers minimal_console.exe | findstr "PE32+" Output: nasm -f win64 hello
Build: