diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 1727ea5..7276ff3 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -7,15 +7,12 @@ - + + - - - - @@ -547,7 +552,6 @@ - @@ -572,7 +576,8 @@ - diff --git a/build/out.asm b/build/out.asm index 991770a..e3eabb5 100644 --- a/build/out.asm +++ b/build/out.asm @@ -5,49 +5,44 @@ section .text main: push rbp mov rbp, rsp - mov qword [rbp-8], 1 + mov qword [rbp-8], 0 + main_0: mov rax, qword [rbp-8] - mov qword [rbp-16], rax - sub rsp, 16 - call _2 - add rsp, 16 - mov qword [rbp-16], 1 - mov rax, qword [rbp-16] - leave - ret - - -_2: - push rbp - mov rbp, rsp - mov rax, qword [rbp+16] - mov qword [rbp-8], rax + mov qword [rbp-17], rax + mov qword [rbp-25], 1000000000 + mov rax, qword [rbp-25] + cmp rax, qword [rbp-17] + jg __18_2 + mov byte [rbp-9], 0 + jmp __18_3 + __18_2: + mov byte [rbp-9], 1 + __18_3: + cmp byte [rbp-9], 0 + jz main_1 + mov rax, rbp + add rax, -8 + mov qword [rbp-33], rax + mov qword [rbp-41], 1 + mov rax, qword [rbp-33] + mov rdx, qword [rbp-41] + add qword [rax], rdx + jmp main_0 + main_1: + mov rax, qword [rbp-8] + mov qword [rbp-33], rax mov rdi, __8_fstr - mov rsi, [rbp-8] + mov rsi, [rbp-33] mov al, 0 - sub rsp, 8 + sub rsp, 33 extern printf call printf - add rsp, 8 - mov qword [rbp-16], 12 - mov qword [rbp-24], 12 - mov rax, rbp - add rax, 16 - mov qword [rbp-32], rax - mov qword [rbp-40], 1 - mov rax, qword [rbp-32] - mov rdx, qword [rbp-40] - add qword [rax], rdx - mov rax, qword [rbp+16] - mov qword [rbp-48], rax - mov rax, qword [rbp-48] - mov qword [rbp-56], rax - sub rsp, 56 - call _2 - add rsp, 56 + add rsp, 33 + mov qword [rbp-41], 1 + mov rax, qword [rbp-41] + leave + ret -leave -ret section .data_readonly __8_fstr db `Integer: %ld\n`,0 \ No newline at end of file diff --git a/build/out.o b/build/out.o index f8db73f..bc4935e 100644 Binary files a/build/out.o and b/build/out.o differ diff --git a/build/out.out b/build/out.out index b3fa046..628f1db 100755 Binary files a/build/out.out and b/build/out.out differ diff --git a/main.why b/main.why index 817244a..f2abf0d 100644 --- a/main.why +++ b/main.why @@ -1,11 +1,9 @@ -fn rec(a: int) { - printi(a); - &a += 1; - rec(a); -} - fn main() -> int { - rec(1); + let a: int = 0; + while (a < 1000000000) { + &a += 1; + } + printi(a); return 1; }