Get rid of gcc, adds exit()

This commit is contained in:
2025-06-25 14:58:02 +02:00
parent 36d21ca18b
commit 3e8bcdeb01
4 changed files with 15 additions and 4 deletions

View File

@ -3,6 +3,7 @@ section .rodata
global NR_write global NR_write
global NR_open global NR_open
global NR_close global NR_close
global NR_exit
global EOS global EOS
global NL global NL
@ -12,6 +13,7 @@ section .rodata
NR_write equ 1 NR_write equ 1
NR_open equ 2 NR_open equ 2
NR_close equ 3 NR_close equ 3
NR_exit equ 60
;ascii ;ascii
EOS equ 0x0 EOS equ 0x0

View File

@ -1,3 +1,4 @@
extern NR_exit
extern strclr extern strclr
section .text section .text
@ -10,6 +11,7 @@ section .text
global tolower global tolower
global toupper global toupper
global itoa global itoa
global exit
;----- min(int a, int b) -----; ;----- min(int a, int b) -----;
; return value: lowest value ; return value: lowest value
@ -176,3 +178,8 @@ itoa:
pop rax pop rax
leave leave
ret ret
;----- exit(int exit_code) -----;
; returns: nothing
exit:
mov rax, NR_exit
syscall

View File

@ -1,5 +1,5 @@
tests: tests.o constants.o core.o console.o string.o file.o tests: tests.o constants.o core.o console.o string.o file.o
gcc tests.o constants.o core.o console.o string.o file.o -o tests -no-pie -z noexecstack ld tests.o constants.o core.o console.o string.o file.o -o tests -no-pie -z noexecstack
tests.o: tests.asm tests.o: tests.asm
nasm tests.asm -f elf64 -l tests.lst -g -F dwarf nasm tests.asm -f elf64 -l tests.lst -g -F dwarf
constants.o: constants.asm constants.o: constants.asm

View File

@ -13,6 +13,7 @@ extern isupper
extern tolower extern tolower
extern toupper extern toupper
extern itoa extern itoa
extern exit
;console.asm ;console.asm
extern print extern print
extern puts extern puts
@ -177,8 +178,8 @@ section .bss
strBuff1 resb 32 strBuff1 resb 32
strBuff2 resb 8 strBuff2 resb 8
section .text section .text
global main global _start
main: _start:
push rbp push rbp
mov rbp, rsp mov rbp, rsp
@ -809,4 +810,5 @@ main:
%ENDIF %ENDIF
leave leave
ret mov rdi, 0
call exit