[global _start]
[global start]
[extern main]
+[extern _exit]
_start:
start:
call main
- mov eax, ebx ; Set Argument 1 to Return Value
- xor eax, eax ; Set EAX to SYS_EXIT (0)
- int 0xAC
+ push eax
+
+ mov eax, [_crt0_exit_handler]
+ test eax, eax
+ jz .exit
+ call eax
+
+.exit:
+ call _exit
jmp $ ; This should never be reached
+[section .bss]
+[global _crt0_exit_handler]
+_crt0_exit_handler:
+ resd 1