This commit is contained in:
nub31
2025-05-05 16:36:24 +02:00
parent f77fdb86f3
commit cca6fc55d6
9 changed files with 17 additions and 58 deletions

View File

@@ -3,14 +3,10 @@ mkdir -p out
dotnet run --project lang/Nub.Lang example out/out.qbe
gcc -c -g -fno-stack-protector -fno-builtin std/baseline/gc.c -o out/gc.o
nasm -g -felf64 std/baseline/str_cmp.asm -o out/str_cmp.o
nasm -g -felf64 std/baseline/runtime.asm -o out/runtime.o
nasm -g -felf64 std/core/str_len.asm -o out/str_len.o
nasm -g -felf64 std/core/itoa.asm -o out/itoa.o
gcc -c -g -fno-stack-protector -fno-builtin std/gc.c -o out/gc.o
nasm -g -felf64 std/runtime.asm -o out/runtime.o
qbe out/out.qbe > out/out.s
gcc -c -g out/out.s -o out/out.o
gcc -no-pie -nostartfiles -o out/program out/gc.o out/str_cmp.o out/str_len.o out/itoa.o out/runtime.o out/out.o
gcc -no-pie -nostartfiles -o out/program out/gc.o out/runtime.o out/out.o

View File

@@ -1,2 +0,0 @@
extern func str_len(msg: string): int64;
extern func itoa(value: int64): string;

View File

@@ -1,4 +1,4 @@
import "core";
import "c";
global func main() {
let x = "test";

View File

@@ -1,10 +0,0 @@
global _start
extern main, gc_init
section .text
_start:
call gc_init
call main
mov rax, 60
mov rdi, 0
syscall

View File

@@ -1,23 +0,0 @@
section .bss
buffer resb 20
section .text
global itoa
itoa:
mov rax, rdi
mov rsi, buffer + 19
mov byte [rsi], 0
dec rsi
.loop:
xor rdx, rdx
mov rcx, 10
div rcx
add dl, '0'
mov [rsi], dl
dec rsi
test rax, rax
jnz .loop
inc rsi
mov rax, rsi
ret

View File

@@ -1,13 +0,0 @@
global str_len
section .text
str_len:
xor rax, rax
.loop:
cmp byte [rdi], 0
jz .done
inc rax
inc rdi
jmp .loop
.done:
ret

View File

@@ -1,7 +1,18 @@
global str_cmp
global _start
extern main, gc_init
section .text
str_cmp:
_start:
call gc_init
call main
mov rax, 60
mov rdi, 0
syscall
global base_str_cmp
section .text
base_str_cmp:
xor rdx, rdx
.loop:
mov al, [rsi + rdx]