Skip to content

Commit

Permalink
Testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert-M-Lucas committed Jun 16, 2024
1 parent 133922f commit 31c8d7d
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 140 deletions.
17 changes: 13 additions & 4 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

140 changes: 21 additions & 119 deletions build/out.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Binary file modified build/out.o
Binary file not shown.
Binary file modified build/out.out
Binary file not shown.
22 changes: 5 additions & 17 deletions main.why
Original file line number Diff line number Diff line change
@@ -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;
}

0 comments on commit 31c8d7d

Please sign in to comment.