diff --git a/sbc/asm_gen.ts b/sbc/asm_gen.ts index e279a73..b554f6c 100644 --- a/sbc/asm_gen.ts +++ b/sbc/asm_gen.ts @@ -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}`); } diff --git a/sbc/program.sbl b/sbc/program.sbl index d0c0c67..7ad87ba 100644 --- a/sbc/program.sbl +++ b/sbc/program.sbl @@ -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; }