diff --git a/.idea/workspace.xml b/.idea/workspace.xml index ff2ef1e..812ff09 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -7,7 +7,7 @@ - + @@ -189,7 +189,7 @@ - + - @@ -434,6 +442,7 @@ - \ No newline at end of file diff --git a/build/out.asm b/build/out.asm index 77f19a6..c6df377 100644 --- a/build/out.asm +++ b/build/out.asm @@ -6,141 +6,43 @@ main: push rbp mov rbp, rsp - mov qword [rbp-8], 3 + mov qword [rbp-8], 1 mov rax, qword [rbp-8] mov qword [rbp-16], rax - push 0 - mov rdi, __10_fstr - mov rsi, [rbp-16] - mov al, 0 sub rsp, 16 - extern printf - call printf + call _1 add rsp, 16 - - mov rax, qword [rbp-8] - mov qword [rbp-24], rax - push 0 - mov rdi, __10_fstr - mov rsi, [rbp-24] - mov al, 0 - sub rsp, 24 - extern printf - call printf - add rsp, 24 - - mov rax, qword [rbp-8] - mov qword [rbp-32], rax - push 0 - mov rdi, __10_fstr - mov rsi, [rbp-32] - mov al, 0 - sub rsp, 32 - extern printf - call printf - add rsp, 32 - - mov rax, qword [rbp-8] - mov qword [rbp-40], rax - push 0 - mov rdi, __10_fstr - mov rsi, [rbp-40] - mov al, 0 - sub rsp, 40 - extern printf - call printf - add rsp, 40 - - mov rax, qword [rbp-8] - mov qword [rbp-48], rax - push 0 - mov rdi, __10_fstr - mov rsi, [rbp-48] - mov al, 0 - sub rsp, 48 - extern printf - call printf - add rsp, 48 - - mov rax, qword [rbp-8] - mov qword [rbp-56], rax - push 0 - mov rdi, __10_fstr - mov rsi, [rbp-56] - mov al, 0 - sub rsp, 56 - extern printf - call printf - add rsp, 56 - - mov rax, qword [rbp-8] - mov qword [rbp-64], rax - push 0 - mov rdi, __10_fstr - mov rsi, [rbp-64] - mov al, 0 - sub rsp, 64 - extern printf - call printf - add rsp, 64 - - mov rax, qword [rbp-8] - mov qword [rbp-72], rax - push 0 - mov rdi, __10_fstr - mov rsi, [rbp-72] - mov al, 0 - sub rsp, 72 - extern printf - call printf - add rsp, 72 - - mov rax, qword [rbp-8] - mov qword [rbp-88], rax - mov rax, qword [rbp-88] - mov qword [rbp-104], rax - sub rsp, 104 - call _2 - add rsp, 104 - mov rax, qword [rbp-96] - mov qword [rbp-80], rax - mov rax, qword [rbp-80] + mov qword [rbp-16], 255 + mov rax, qword [rbp-16] leave ret -_2: +_1: push rbp mov rbp, rsp mov rax, qword [rbp+16] - mov qword [rbp-16], rax - mov rax, qword [rbp-16] - mov qword [rbp-32], rax - sub rsp, 32 - call _1 - add rsp, 32 - mov rax, qword [rbp-24] mov qword [rbp-8], rax - mov qword [rbp-32], 1 - mov rax, qword [rbp-8] - add rax, qword [rbp-32] - mov qword [rbp+24], rax - leave - ret -_1: - push rbp - mov rbp, rsp + mov rdi, __10_fstr + mov rsi, [rbp-8] + mov al, 0 + sub rsp, 8 + extern printf + call printf + add rsp, 8 mov rax, qword [rbp+16] - mov qword [rbp-8], rax - mov rax, qword [rbp+16] + mov qword [rbp-24], rax + mov qword [rbp-32], 1 + mov rax, qword [rbp-24] + add rax, qword [rbp-32] mov qword [rbp-16], rax - mov rax, qword [rbp-8] - add rax, qword [rbp-16] - mov qword [rbp+24], rax - leave - ret + mov rax, qword [rbp-16] + mov qword [rbp-40], rax + sub rsp, 40 + call _1 + add rsp, 40 section .data __10_fstr db `Integer: %d\n`,0 \ No newline at end of file diff --git a/build/out.o b/build/out.o index 6eed537..77c790b 100644 Binary files a/build/out.o and b/build/out.o differ diff --git a/build/out.out b/build/out.out index 5822262..fc791b0 100755 Binary files a/build/out.out and b/build/out.out differ diff --git a/main.why b/main.why index e43546e..dd34695 100644 --- a/main.why +++ b/main.why @@ -1,21 +1,9 @@ -fn test_two(a: int) -> int { - return a + a; -} - -fn test(a: int) -> int { - return test_two(a) + 1; +fn r(a: int) { + printi(a); + r(a + 1); } fn main() -> int { - let x: int = 3; - printi(x); - printi(x); - printi(x); - printi(x); - printi(x); - printi(x); - printi(x); - printi(x); - return test(x); + r(1); + return 255; } -