on-internet
← Community

How do I fix my NASM code from auto-exiting after I open the EXE on Windows 11?

Stack Overflow ·

I wrote a WIN64 compiled NASM program, but I can't figure out how to wait for a keypress before exiting. My code is: bits 64 global main extern _getch extern exit extern printf section .data msg db "hmmmmmmmmmm", 10, 1 section .text main: sub rsp, 40 lea rcx, [rel msg] call printf add rsp, 40 mov rax, 0 ret call _getch xor rdi, rdi call exit I compiled this with a batch script that executes the following: @echo off nasm -f win64 MyNasm.asm -o MyNasm.obj gcc MyNasm.obj -o MyNasm.exe .\MyNasm.exe Then I execute the program in the VSCode terminal. If the code is wrong, or there is some "library"

Comments

Sign in or sign up to comment and upvote.

No comments yet.