I'm using SASM and within it, NASM. Whenever I open run my simple NASM file, it closes in the blink of an eye. Here is my code:
%include "io64.inc"
section .text
global CMAIN
CMAIN:
mov eax,4
xor rax, rax
ret
I'm using SASM and within it, NASM. Whenever I open run my simple NASM file, it closes in the blink of an eye. Here is my code:
%include "io64.inc"
section .text
global CMAIN
CMAIN:
mov eax,4
xor rax, rax
ret
It also closes because all programs close when they are done running. You can add an infinite loop at the end of execution to stop it from closing. Do something like this:
%include "io64.h"
section .text
global CMAIN
CMAIN:
mov eax, 4
endLoop:
pause ; don't overheat your CPU as much while busy-waiting
jmp endLoop
; never reached unless you use a debugger to get out of the infinite loop
xor rax, rax
ret
This will cause the program to loop at endLoop so it never finishes and closes.
Making a system call that sleeps would be a lot more power-efficient way to make a program never exit. Waiting for keyboard input is another common method in C++ programs on systems that default to running a program in a new window that closes when it's done.
Or set a breakpoint inside your program.