Skip to content

Commit c259436

Browse files
committed
SAVEPOINT
1 parent de1c9cc commit c259436

2 files changed

Lines changed: 25 additions & 17 deletions

File tree

examples/test.asm

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ global _start
44
section .rodata
55

66
get_three#0: dq FUN#0
7-
main#2: dq FUN#1
7+
main#3: dq FUN#1
88

99
section .text
1010

@@ -24,32 +24,40 @@ FUN#0:
2424
FUN#1:
2525
enter 0, 0
2626

27-
; get_four#1 := FUN#2
28-
push qword FUN#2
27+
; t2 := 4 + 5
28+
mov rax, 4
29+
add rax, 5
30+
push qword rax
31+
32+
; x#1 := t2
33+
push qword [rbp - 8]
34+
35+
; get_nine#2 := FUN#3
36+
push qword FUN#3
2937

30-
; t3 := get_three#0()
38+
; t4 := get_three#0()
3139
call [get_three#0]
3240
push qword rax
3341

34-
; t4 := get_four#1()
35-
call [rbp - 8]
42+
; t5 := get_nine#2()
43+
call [rbp - 24]
3644
push qword rax
3745

38-
; t5 := t3 + t4
39-
mov rax, [rbp - 16]
40-
add rax, [rbp - 24]
46+
; t6 := t4 + t5
47+
mov rax, [rbp - 32]
48+
add rax, [rbp - 40]
4149
push qword rax
4250

43-
; exit t5
51+
; exit t6
4452
mov rax, 60
45-
mov rdi, [rbp - 32]
53+
mov rdi, [rbp - 48]
4654
syscall
4755

4856

49-
FUN#2:
57+
FUN#3:
5058
enter 0, 0
5159

52-
; ret 4
53-
mov rax, 4
60+
; ret x#1
61+
mov rax, [rbp - 16]
5462
leave
5563
ret

examples/test.lv

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
get_three :: fun () -> Int: 3
22

33
main :: fun () -> Int: {
4-
get_four :: fun () -> Int: 4
5-
6-
get_three() + get_four()
4+
x :: 4 + 5
5+
get_nine :: fun () -> Int: x
6+
get_three() + get_nine() # should be 12
77
}

0 commit comments

Comments
 (0)