-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path006.fun
More file actions
100 lines (83 loc) · 1.79 KB
/
006.fun
File metadata and controls
100 lines (83 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# hello reader :)
# things to watch out for in this test:
# - labels don't interfere with common label names
# - functions return 0 (make sure you move to %rax!)
fun labelInterferenceTest() {
# variable names to check for interference of common labels
printf = 1
main = 2
callq = 3
format = 4
# the following should print
# 1
print(printf)
# 2
print(main)
# 3
print(callq)
# 4
print(format)
}
# you can't push large constants, so make sure to move them to a register first!
fun testParamOverflowUnderflow(a, b, c) {
print(a)
print(b)
print(c)
}
# tests for pushing large functions
fun pushLargeTest() {
a = 0 - 1
if (a) {
print(a)
}
# be careful when pushing (0-1) to stack
# you'll need to move it into a register first
if ((0 - 1) % 2) {
print(1)
} else {
print(0)
}
}
# tests large multiplications, divisions, mods
fun testMulDivLg() {
print((0 - 1) * (0 - 1))
print((0 - 1) / (0 - 1))
print((0 - 1) % (0 - 1))
}
# tests while loops, if, mod, add, sub
fun fibDp(c) {
a = 1
b = 1
while(c > 0) {
if (c % 2 == 1) {
a = a + b
} else {
b = a + b
}
c = c - 1
}
# 144
print(a)
# 89
print(b)
}
fun main() {
# <3 ASCII Art :D
print(118881111111888811)
print(181118811118111881)
print(811111181181111188)
print(888111118811111118)
print(188111111111111881)
print(111881111111118111)
print(111188811118881111)
print(111111881188811111)
print(111111188881111111)
labelInterferenceTest()
# this should also print 0
print(testParamOverflowUnderflow(0-1, 18446744073709551615, 0))
print(11111111111111111)
testMulDivLg()
fibDp(10)
}
# comment below with no characters after it
#