Commit | Line | Data |
---|---|---|
79bfeef6 | 1 | #define def_wi(i, ii) \ |
4a71579b PC |
2 | name _w##i \ |
3 | _w##i: \ | |
4 | prolog \ | |
79bfeef6 | 5 | arg##ii $arg##i \ |
4a71579b | 6 | getarg##i %r0 $arg##i \ |
79bfeef6 | 7 | retr##i %r0 \ |
4a71579b PC |
8 | epilog |
9 | #define def_wf(f) \ | |
10 | name _w##f \ | |
11 | _w##f: \ | |
12 | prolog \ | |
13 | arg##f $arg##f \ | |
14 | getarg##f %f0 $arg##f \ | |
15 | truncr##f %r0 %f0 \ | |
16 | retr %r0 \ | |
17 | epilog | |
79bfeef6 | 18 | #define def_fi(f, i, ii) \ |
4a71579b PC |
19 | name f##i \ |
20 | f##i: \ | |
21 | prolog \ | |
79bfeef6 | 22 | arg##ii $arg##i \ |
4a71579b PC |
23 | getarg##i %r0 $arg##i \ |
24 | extr##f %f0 %r0 \ | |
25 | retr##f %f0 \ | |
26 | epilog | |
27 | #define def_f(f) \ | |
28 | name f##f \ | |
29 | f##f: \ | |
30 | prolog \ | |
31 | arg##f $arg##f \ | |
32 | getarg##f %f0 $arg##f \ | |
33 | retr##f %f0 \ | |
34 | epilog | |
35 | #define def_ff(f, g) \ | |
36 | name f##g \ | |
37 | name f##g \ | |
38 | f##g: \ | |
39 | prolog \ | |
40 | arg##g $arg##g \ | |
41 | getarg##g %f0 $arg##g \ | |
42 | extr##g##f %f0 %f0 \ | |
43 | retr##f %f0 \ | |
44 | epilog | |
45 | ||
46 | .data 32 | |
47 | fstr: | |
48 | .c "forward" | |
49 | bstr: | |
50 | .c "backward" | |
51 | ||
52 | .code | |
53 | jmpi main | |
54 | ||
79bfeef6 PC |
55 | def_wi(_c, _c) |
56 | def_wi(_uc, _c) | |
57 | def_wi(_s, _s) | |
58 | def_wi(_us, _s) | |
4a71579b | 59 | #if __WORDSIZE == 64 |
79bfeef6 PC |
60 | def_wi(_i, _i) |
61 | def_wi(_ui, _i) | |
4a71579b PC |
62 | #endif |
63 | def_wf(_f) | |
64 | def_wf(_d) | |
79bfeef6 PC |
65 | def_fi(_f, _c, _c) |
66 | def_fi(_f, _uc, _c) | |
67 | def_fi(_f, _s, _s) | |
68 | def_fi(_f, _us, _s) | |
69 | def_fi(_f, _i, _i) | |
4a71579b | 70 | #if __WORDSIZE == 64 |
79bfeef6 PC |
71 | def_fi(_f, _ui, _i) |
72 | def_fi(_f, _l, _l) | |
4a71579b | 73 | #endif |
79bfeef6 PC |
74 | def_fi(_d, _c, _c) |
75 | def_fi(_d, _uc, _c) | |
76 | def_fi(_d, _s, _s) | |
77 | def_fi(_d, _us, _s) | |
78 | def_fi(_d, _i, _i) | |
4a71579b | 79 | #if __WORDSIZE == 64 |
79bfeef6 PC |
80 | def_fi(_d, _ui, _i) |
81 | def_fi(_d, _l, _l) | |
4a71579b PC |
82 | #endif |
83 | def_f(_f) | |
84 | def_f(_d) | |
85 | def_ff(_f, _d) | |
86 | def_ff(_d, _f) | |
87 | ||
88 | name main | |
89 | main: | |
90 | prolog | |
91 | ||
92 | #define _call_w(n, i, a, r) \ | |
93 | prepare \ | |
79bfeef6 | 94 | pushargi##i a \ |
4a71579b PC |
95 | finishi _w##i \ |
96 | retval %r0 \ | |
97 | extr##i %r0 %r0 \ | |
98 | beqi _w##i##_##n %r0 r \ | |
99 | calli @abort \ | |
100 | _w##i##_##n: | |
101 | #define call_w(n, i, a, r) _call_w(n, i, a, r) | |
102 | #define _call_wf(n, f, a, r) \ | |
103 | prepare \ | |
104 | pushargi##f a \ | |
105 | finishi _w##f \ | |
106 | retval %r0 \ | |
107 | extr##f %f0 %r0 \ | |
108 | beqi##f _w##f##_##n %f0 r \ | |
109 | calli @abort \ | |
110 | _w##f##_##n: | |
111 | #define call_wf(n, f, a, r) _call_wf(n, f, a, r) | |
112 | #define _call_fi(n, f, i, a, r) \ | |
113 | prepare \ | |
79bfeef6 | 114 | pushargi##i a \ |
4a71579b PC |
115 | finishi f##i \ |
116 | retval##f %f0 \ | |
117 | beqi##f f##i##n %f0 r \ | |
118 | calli @abort \ | |
119 | f##i##n: | |
120 | #define call_fi(n, f, i, a, r) _call_fi(n, f, i, a, r) | |
121 | #define _call_f(n, f, a, r) \ | |
122 | prepare \ | |
123 | pushargi##f a \ | |
124 | finishi f##f \ | |
125 | retval##f %f0 \ | |
126 | beqi##f f##f##n %f0 r \ | |
127 | calli @abort \ | |
128 | f##f##n: | |
129 | #define call_f(n, f, a, r) _call_f(n, f, a, r) | |
130 | #define _call_ff(n, f, g, a, r) \ | |
131 | prepare \ | |
132 | pushargi##g a \ | |
133 | finishi f##g \ | |
134 | retval##f %f0 \ | |
135 | beqi##f f##g##n %f0 r \ | |
136 | calli @abort \ | |
137 | f##g##n: | |
138 | #define call_ff(n, f, g, a, r) _call_ff(n, f, g, a, r) | |
139 | ||
140 | #define c7f 0x7f | |
141 | #define c80 0x80 | |
142 | #define c81 0x81 | |
143 | #define cff 0xff | |
144 | #define s7f 0x7fff | |
145 | #define s80 0x8000 | |
146 | #define s81 0x8001 | |
147 | #define i7f 0x7fffffff | |
148 | #define i80 0x80000000 | |
149 | #define i81 0x80000001 | |
150 | #define iff 0xffffffff | |
151 | #define l7f 0x7fffffffffffffff | |
152 | #define l80 0x8000000000000000 | |
153 | #define l81 0x8000000000000001 | |
154 | #define f7f 127.0 | |
155 | #define f80 -128.0 | |
156 | #define f81 -127.0 | |
157 | #define uf80 128.0 | |
158 | #define uf81 127.0 | |
159 | #if __WORDSIZE == 32 | |
160 | # define wc80 0xffffff80 | |
161 | # define wc81 0xffffff81 | |
162 | # define ws80 0xffff8000 | |
163 | # define ws81 0xffff8001 | |
164 | #else | |
165 | # define wc80 0xffffffffffffff80 | |
166 | # define wc81 0xffffffffffffff81 | |
167 | # define ws80 0xffffffffffff8000 | |
168 | # define ws81 0xffffffffffff8001 | |
169 | # define wi80 0xffffffff80000000 | |
170 | # define wi81 0xffffffff80000001 | |
171 | #endif | |
172 | ||
173 | call_w(__LINE__, _c, c7f, c7f) | |
174 | call_w(__LINE__, _c, c80, wc80) | |
175 | call_w(__LINE__, _c, c81, wc81) | |
176 | call_w(__LINE__, _uc, c7f, c7f) | |
177 | call_w(__LINE__, _uc, c80, c80) | |
178 | call_w(__LINE__, _uc, c81, c81) | |
179 | call_w(__LINE__, _s, s7f, s7f) | |
180 | call_w(__LINE__, _s, s80, ws80) | |
181 | call_w(__LINE__, _s, s81, ws81) | |
182 | call_w(__LINE__, _us, s7f, s7f) | |
183 | call_w(__LINE__, _us, s80, s80) | |
184 | call_w(__LINE__, _us, s81, s81) | |
185 | #if __WORDSIZE == 64 | |
186 | call_w(__LINE__, _i, i7f, i7f) | |
187 | call_w(__LINE__, _i, i80, wi80) | |
188 | call_w(__LINE__, _i, i81, wi81) | |
189 | call_w(__LINE__, _ui, i7f, i7f) | |
190 | call_w(__LINE__, _ui, i80, i80) | |
191 | call_w(__LINE__, _ui, i81, i81) | |
192 | #endif | |
193 | call_wf(__LINE__, _f, c7f, f7f) | |
194 | call_wf(__LINE__, _f, wc80, f80) | |
195 | call_wf(__LINE__, _f, wc81, f81) | |
196 | call_wf(__LINE__, _d, c7f, f7f) | |
197 | call_wf(__LINE__, _d, wc80, f80) | |
198 | call_wf(__LINE__, _d, wc81, f81) | |
79bfeef6 | 199 | |
4a71579b PC |
200 | call_fi(__LINE__, _f, _c, c7f, f7f) |
201 | call_fi(__LINE__, _f, _c, c80, f80) | |
202 | call_fi(__LINE__, _f, _uc, c7f, f7f) | |
203 | call_fi(__LINE__, _f, _uc, c80, uf80) | |
204 | call_fi(__LINE__, _f, _s, c7f, f7f) | |
205 | call_fi(__LINE__, _f, _s, c80, uf80) | |
206 | call_fi(__LINE__, _f, _us, c7f, f7f) | |
207 | call_fi(__LINE__, _f, _us, c80, uf80) | |
208 | call_fi(__LINE__, _f, _i, c7f, f7f) | |
209 | call_fi(__LINE__, _f, _i, c80, uf80) | |
210 | #if __WORDSIZE == 64 | |
211 | call_fi(__LINE__, _f, _ui, c7f, f7f) | |
212 | call_fi(__LINE__, _f, _ui, c80, uf80) | |
213 | call_fi(__LINE__, _f, _l, c7f, f7f) | |
214 | call_fi(__LINE__, _f, _l, c80, uf80) | |
215 | #endif | |
216 | call_fi(__LINE__, _d, _c, c7f, f7f) | |
217 | call_fi(__LINE__, _d, _c, c80, f80) | |
218 | call_fi(__LINE__, _d, _uc, c7f, f7f) | |
219 | call_fi(__LINE__, _d, _uc, c80, uf80) | |
220 | call_fi(__LINE__, _d, _s, c7f, f7f) | |
221 | call_fi(__LINE__, _d, _s, c80, uf80) | |
222 | call_fi(__LINE__, _d, _us, c7f, f7f) | |
223 | call_fi(__LINE__, _d, _us, c80, uf80) | |
224 | call_fi(__LINE__, _d, _i, c7f, f7f) | |
225 | call_fi(__LINE__, _d, _i, c80, uf80) | |
226 | #if __WORDSIZE == 64 | |
227 | call_fi(__LINE__, _d, _ui, c7f, f7f) | |
228 | call_fi(__LINE__, _d, _ui, c80, uf80) | |
229 | call_fi(__LINE__, _d, _l, c7f, f7f) | |
230 | call_fi(__LINE__, _d, _l, c80, uf80) | |
231 | #endif | |
232 | call_f(__LINE__, _f, f7f, f7f) | |
233 | call_f(__LINE__, _d, f7f, f7f) | |
234 | call_ff(__LINE__, _f, _d, f80, f80) | |
235 | call_ff(__LINE__, _d, _f, f81, f81) | |
236 | ||
237 | movi %r0 forward | |
238 | callr %r0 | |
239 | ||
240 | calli iforward | |
241 | ||
242 | ret | |
243 | epilog | |
244 | ||
245 | name backward | |
246 | backward: | |
247 | prolog | |
248 | prepare | |
249 | pushargi bstr | |
250 | finishi @puts | |
251 | ret | |
252 | epilog | |
253 | ||
254 | name forward | |
255 | forward: | |
256 | prolog | |
257 | prepare | |
258 | pushargi fstr | |
259 | finishi @puts | |
260 | movi %r0 backward | |
261 | callr %r0 | |
262 | ret | |
263 | epilog | |
264 | ||
265 | name iforward | |
266 | iforward: | |
267 | prolog | |
268 | prepare | |
269 | pushargi fstr | |
270 | finishi @puts | |
271 | calli backward | |
272 | ret | |
273 | epilog |