This commit is contained in:
nub31
2025-01-29 21:39:55 +01:00
parent 39be4d823b
commit d685fe2209
12 changed files with 205 additions and 1 deletions

29
input/core/print.nub Normal file
View File

@@ -0,0 +1,29 @@
let SYS_WRITE = 1;
let STD_OUT = 1;
let STD_ERR = 2;
func print(msg: String) {
syscall(SYS_WRITE, STD_OUT, msg, strlen(msg));
}
func print(value: bool) {
if value {
print("true");
} else {
print("false");
}
}
func println() {
print("\n");
}
func println(msg: String) {
print(msg);
println();
}
func println(value: bool) {
print(value);
println();
}

13
input/core/strlen.asm Normal file
View File

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

1
input/core/strlen.nub Normal file
View File

@@ -0,0 +1 @@
extern func strlen(msg: String): int64;