compiler: simple hello world doesn't work

This commit is contained in:
SimonFJ20 2025-03-27 16:11:34 +01:00
parent 9881b55521
commit 14d5afcaea
2 changed files with 11 additions and 15 deletions

View File

@ -114,7 +114,7 @@ export class AsmGen {
}
const argRegs = ["rdi", "rsi", "rdx", "rcx", "r8", "r9"];
for (const reg of argRegs.slice(0, args + 1)) {
for (const reg of argRegs.slice(0, args)) {
this.writeIns(`pop ${reg}`);
}

View File

@ -11,25 +11,21 @@ fn factorial(v: int) -> int {
return v * factorial(v - 1);
}
fn return_void_ptr(ptr: *()) -> *() {
return ptr;
}
#[c_export("sbc_main")]
fn main() -> int {
let i = 0;
// while i < 10 {
//
// println("Hello\ world");
//
// i = i + 1;
// }
while i < 10 {
// print_int(i);
println("Hello\ world");
let a = factorial(5);
print_int(a);
i = i + 1;
}
return 0;
}
#[c_export("sbc_main")]
fn sbc_main() -> int {
main();
return 0;
}