-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTests.asm
155 lines (125 loc) · 2.72 KB
/
Tests.asm
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#macro Macro1()
1
#endmacro
#macro RecursiveMacro1(x)
#if x > 1
1 + RecursiveMacro1(x - 1)
#else
1
#endif
#endmacro
#define InfiniteRecursiveDefine InfiniteRecursiveDefine + 1
#macro FibonacciMacro(x)
#if x = 0
0
#else
#if x = 1
1
#else
FibonacciMacro(x - 1) + FibonacciMacro(x - 2)
#endif
#endif
#endmacro
#macro EchoMacro1()
.echo >> EchoMacro1.txt "Hello World"
#endmacro
#macro EchoMacro2(x)
.echo >> EchoMacro2.txt x
#endmacro
#macro EchoMacro3(x1, x2)
.echo >> EchoMacro3.txt "My prefix (", FibonacciMacro(x1), "): ", x2
#endmacro
#macro EchoMacro4(x1, x2)
.echo >> EchoMacro4.txt "My prefix (", RecursiveMacro1(x1), "): ", x2
#endmacro
#define .echomacro4 EchoMacro4(
#macro ConcatMacro1(x1)
#define x2 concat("\"",x1,"\"")
.echo >> ConcatMacro1.txt x2
#endmacro
#macro ConcatMacro2(x1)
#define x2 concat("\"",x1,"\"")
.echo >> ConcatMacro2.txt x2
#endmacro
#macro InternalConcatMacro3(string, times)
#if times = 0
.echo >> ConcatMacro3.txt string
#undef gfirst
#else
#define string concat(string, ",\"X\"")
InternalConcatMacro3(string, times - 1)
#endif
#endmacro
#macro ConcatMacro3(x1)
InternalConcatMacro3("\"\"", x1)
#endmacro
#macro InternalConcatMacro4(string, times)
#if times = 0
.echo >> ConcatMacro4.txt string
#else
#define string string,"X"
InternalConcatMacro4(string, times - 1)
#endif
#endmacro
#macro ConcatMacro4(x1)
InternalConcatMacro4("", x1)
#endmacro
#macro InternalConcatMacro5(times, char, base)
#if times > 0
#define base base,char
InternalConcatMacro5(times - 1, char, base)
#else
.echo >> ConcatMacro5.txt base
#endif
#endmacro
#macro ConcatMacro5()
InternalConcatMacro5(4, "X", "XXX")
#endmacro
#macro Fixed14Power(val, pow)
#if pow = 0
16384
#else
#define prev_val eval(Fixed14Power(val, pow - 1))
val * prev_val / 16384
#endif
#endmacro
#macro DegreesToRadians(deg)
(deg * 16384 / 180 * 51472 / 16384)
#endmacro
#macro Fixed14Cos(deg)
#define rad eval(DegreesToRadians(deg))
#define rad2 eval(rad * 16384 / 20643)
16384 - (Fixed14Power(rad, 2)/2) + (Fixed14Power(rad, 4)/24) - ((Fixed14Power(rad2, 6)/720) * 4)
#endmacro
#macro LocalLabel1()
.org 0
.block 3
_:
#endmacro
#macro LocalLabel3()
.org 0
.block 3
_:
.block 2
_:
#endmacro
#macro LocalLabel4()
.org 0
_:
.block 2
.db -_ + +_ + ++_
_:
.block 1
_:
#endmacro
#macro ParserError102(x)
x
#endmacro
#define EmitDefine1 10
#define EmitDefine2 10,11,12
#macro EmitMacro3(arg1, arg2)
arg1, arg2, 12
#endmacro
#define EmitDefine3 EmitMacro3(10, 11)
#define EmitDefine4 10+
#define EmitDefine5 "A"