1 ### GNU Mes --- Maxwell Equations of Software
2 ### Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
4 ### This file is part of GNU Mes.
6 ### Mes is free software# you can redistribute it and/or modify it
7 ### under the terms of the GNU General Public License as published by
8 ### the Free Software Foundation# either version 3 of the License, or (at
9 ### your option) any later version.
11 ### GNU Mes is distributed in the hope that it will be useful, but
12 ### WITHOUT ANY WARRANTY# without even the implied warranty of
13 ### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ### GNU General Public License for more details.
16 ### You should have received a copy of the GNU General Public License
17 ### along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
19 # reduced instruction set: eax, ebx (some ecx for shift, edx for mul, div)
22 DEFINE add____$i32,%eax 05
23 DEFINE add____$i32,%ebx 81c3
24 DEFINE add____$i32,(%eax) 8100
25 DEFINE add____$i32,(%ebx) 8103
26 DEFINE add____$i32,0x32(%eax) 8180
27 DEFINE add____$i32,0x32(%ebp) 8185
28 DEFINE add____$i8,%eax 83c0
29 DEFINE add____$i8,%ebx 83c3
30 DEFINE add____$i8,%esp 83c4
31 DEFINE add____$i8,(%eax) 8300
32 DEFINE add____$i8,(%ebx) 8303
33 DEFINE add____$i8,0x32 8305
34 DEFINE add____$i8,0x32(%eax) 8380
35 DEFINE add____$i8,0x32(%ebp) 8385
36 DEFINE add____$i8,0x8(%eax) 8340
37 DEFINE add____$i8,0x8(%ebp) 8345
38 DEFINE add____%eax,%eax 01c0
39 DEFINE add____%ebp,%eax 01e8
40 DEFINE add____%ebx,%eax 01d8
41 DEFINE add____%ebx,%ebx 01db
42 DEFINE addb___$i8,(%eax) 8000
43 DEFINE addb___$i8,(%ebx) 8003
44 DEFINE addw___$i8,(%eax) 668100
45 DEFINE addw___$i8,(%ebx) 668103
46 DEFINE and____$i32,%eax 25
47 DEFINE and____$i32,%ebx 81e3
48 DEFINE and____%ebx,%eax 21d8
50 DEFINE call___*%eax ffd0
51 DEFINE call___*%ebx ffd3
53 DEFINE cmp____$0x32,%eax 3d
54 DEFINE cmp____$i32,%eax 3d
55 DEFINE cmp____$i8,%eax 83f8
56 DEFINE div___%ebx f7f3
58 DEFINE idiv___%ebx f7fb
60 DEFINE int____$0x80 cd80
72 DEFINE jmp____*%ebx ffe3
75 DEFINE lea____0x32(%ebp),%eax 8d85
76 DEFINE lea____0x8(%ebp),%eax 8d45
78 DEFINE mov____$i32,%eax b8
79 DEFINE mov____$i32,%ebx bb
80 DEFINE mov____$i32,(%eax) c700
81 DEFINE mov____$i32,0x32 c705
82 DEFINE mov____$i32,0x8(%eax) c740
83 DEFINE mov____$i32,0x8(%ebp) c745
84 DEFINE mov____%al,(%ebx) 8803
85 DEFINE mov____%al,0x8(%ebp) 8845
86 DEFINE mov____%ax,(%ebx) 668903
87 DEFINE mov____%ax,0x8(%ebp) 668945
88 DEFINE mov____%bx,%bx 6689db
89 DEFINE mov____%cl,(%ebx) 8a08
90 DEFINE mov____%cx,(%ebx) 668b08
91 DEFINE mov____%dl,(%eax) 8810
92 DEFINE mov____%dl,0x8(%eax) 8850
93 DEFINE mov____%eax,%ebx 89c3
94 DEFINE mov____%eax,%ecx 89c1
95 DEFINE mov____%eax,(%ebx) 8903
96 DEFINE mov____%eax,0x32 a3
97 DEFINE mov____%eax,0x32(%ebp) 8985
98 DEFINE mov____%eax,0x8(%ebp) 8945
99 DEFINE mov____%ebp,%eax 89e8
100 DEFINE mov____%ebp,%ebx 89eb
101 DEFINE mov____%ebx,%eax 89d8
102 DEFINE mov____%ebx,%ecx 89d9
103 DEFINE mov____%ebx,0x32 891d
104 DEFINE mov____%ebx,0x32(%ebp) 899d
105 DEFINE mov____%ebx,0x8(%ebp) 895d
106 DEFINE mov____%ecx,(%ebx) 890b
107 DEFINE mov____%edx,%eax 89d0
108 DEFINE mov____%edx,%ebx 89d3
109 DEFINE mov____%esp,%ebp 89e5
110 DEFINE mov____(%eax),%cl 8a08
111 DEFINE mov____(%eax),%cx 668b08
112 DEFINE mov____(%eax),%eax 8b00
113 DEFINE mov____(%eax),%ecx 8b08
114 DEFINE mov____(%ebx),%ebx 8b1b
115 DEFINE mov____0x32(%eax),%eax 8b80
116 DEFINE mov____0x32(%eax),%ebx 8b98
117 DEFINE mov____0x32(%ebp),%eax 8b85
118 DEFINE mov____0x32(%ebp),%ebx 8b9d
119 DEFINE mov____0x32,%eax a1
120 DEFINE mov____0x32,%ebx 8b1d
121 DEFINE mov____0x8(%eax),%eax 8b40
122 DEFINE mov____0x8(%eax),%ebx 8b58
123 DEFINE mov____0x8(%ebp),%eax 8b45
124 DEFINE mov____0x8(%ebp),%ebp 8b6d
125 DEFINE mov____0x8(%ebp),%ebx 8b5d
126 DEFINE mov____0x8(%ebp),%ecx 8b4d
127 DEFINE mov____0x8(%ebp),%edi 8b7d
128 DEFINE mov____0x8(%ebp),%edx 8b55
129 DEFINE mov____0x8(%ebp),%esi 8b75
130 DEFINE mov____0x8(%ebp),%esp 8b65
131 DEFINE movb___%al,0x32 a2
132 DEFINE movb___%bl,0x32 881d
133 DEFINE movsbl_%al,%eax 0fbec0
134 DEFINE movsbl_%bl,%ebx 0fbedb
135 DEFINE movswl_%ax,%eax 0fbfc0
136 DEFINE movswl_%bx,%ebx 0fbfdb
137 DEFINE movw___%ax,0x32 66a3
138 DEFINE movw___%bx,0x32 66891d
139 DEFINE movzbl_%al,%eax 0fb6c0
140 DEFINE movzbl_%bl,%ebx 0fb6db
141 DEFINE movzbl_(%eax),%eax 0fb600
142 DEFINE movzbl_(%ebx),%ebx 0fb61b
143 DEFINE movzbl_0x32(%eax),%eax 0fb680
144 DEFINE movzbl_0x8(%eax),%eax 0fb640
145 DEFINE movzbl_0x8(%ebp),%eax 0fb645
146 DEFINE movzwl_%ax,%eax 0fb7c0
147 DEFINE movzwl_%bx,%ebx 0fb7db
148 DEFINE movzwl_(%eax),%eax 0fb700
149 DEFINE movzwl_(%ebx),%ebx 0fb71b
150 DEFINE movzwl_0x32(%eax),%eax 0fb780
151 DEFINE movzwl_0x32(%ebp),%eax 0fb785
152 DEFINE movzwl_0x8(%eax),%eax 0fb740
153 DEFINE mul____%ebx f7e3
154 DEFINE mul_____%ebx f7e3
156 DEFINE not____%eax f7d0
157 DEFINE not____%ebx f7d3
158 DEFINE or_____%ebx,%eax 09d8
159 DEFINE pop____%eax 58
160 DEFINE pop____%ebx 5b
161 DEFINE pop____%edx 5a
162 DEFINE push___$i32 68
163 DEFINE push___%eax 50
164 DEFINE push___%ebp 55
165 DEFINE push___%ebx 53
166 DEFINE push___%edx 52
167 DEFINE push___(%eax) ff30
168 DEFINE push___0x32(%ebp) ffb5
169 DEFINE push___0x8(%ebp) ff75
172 DEFINE seta___%al 0f97c0
173 DEFINE seta___%bl 0f97c3
174 DEFINE setae__%al 0f93c0
175 DEFINE setae__%bl 0f93c3
176 DEFINE setb___%al 0f92c0
177 DEFINE setb___%bl 0f92c3
178 DEFINE setbe__%al 0f96c0
179 DEFINE setbe__%bl 0f96c3
180 DEFINE sete___%al 0f94c0
181 DEFINE sete___%bl 0f94c3
182 DEFINE setg___%al 0f9fc0
183 DEFINE setg___%bl 0f9fc3
184 DEFINE setge__%al 0f9dc0
185 DEFINE setge__%bl 0f9dc3
186 DEFINE setl___%al 0f9cc0
187 DEFINE setl___%bl 0f9cc3
188 DEFINE setle__%al 0f9ec0
189 DEFINE setle__%bl 0f9ec3
190 DEFINE setne__%al 0f95c0
191 DEFINE setne__%bl 0f95c3
192 DEFINE shl____$i8,%eax c1e0
193 DEFINE shl____$i8,%ebx c1e3
194 DEFINE shl____%cl,%eax d3e0
195 DEFINE shl____%cl,%ebx d3e3
196 DEFINE shr____%cl,%eax d3e8
197 DEFINE sub____$8,%esp 83ec
198 DEFINE sub____$i32,%esp 81ec
199 DEFINE sub____%al,%dl 28d0
200 DEFINE sub____%dl,%al 28c2
201 DEFINE sub____%ebx,%eax 29d8
202 DEFINE test___%al,%al 84c0
203 DEFINE test___%eax,%eax 85c0
204 DEFINE test___%ebx,%ebx 85db
205 DEFINE xchg___%eax,%ebx 93
206 DEFINE xchg___%eax,(%esp) 870424
207 DEFINE xchg___%ebx,(%esp) 871c24
208 DEFINE xor____$i32,%eax 35
209 DEFINE xor____$i8,%ah 80f4
210 DEFINE xor____%eax,%eax 31c0
211 DEFINE xor____%ebx,%eax 31d8
212 DEFINE xor____%ebx,%ebx 31db
213 DEFINE xor____%edx,%edx 31d2
216 # Enough for all of Mes + Mes C Libray when using all registers, i.e.,
217 # non-reduced instruction set
218 #DEFINE add____$i32,%ecx 81c1
219 #DEFINE add____$i32,%edx 81c2
220 #DEFINE add____$i32,%esi 81c6
221 #DEFINE add____$i8,%ecx 83c1
222 #DEFINE add____$i8,%edx 83c2
223 #DEFINE add____$i8,%esi 83c6
224 #DEFINE add____$i8,(%ecx) 8301
225 #DEFINE add____$i8,(%edx) 8302
226 #DEFINE add____%ecx,%ebx 01cb
227 #DEFINE add____%ecx,%ecx 01c9
228 #DEFINE add____%edx,%eax 01d0
229 #DEFINE add____%edx,%ecx 01d1
230 #DEFINE add____%edx,%edx 01d2
231 #DEFINE add____%esi,%edx 01f2
232 #DEFINE and____$i32,%ecx 81e1
233 #DEFINE and____$i32,%edx 81e2
234 #DEFINE and____%edx,%eax 21d0
235 #DEFINE and____(%edx),%eax 2302
236 #DEFINE cmp____%edx,%eax 39d0
237 #DEFINE idiv___%ecx f7f9
238 #DEFINE lea____0x32(%ebp),%edx 8d95
239 #DEFINE lea____0x8(%ebp),%edx 8d55
240 #DEFINE mov____$i32,%ecx b9
241 #DEFINE mov____$i32,%edx ba
242 #DEFINE mov____$i32,%esi be
243 #DEFINE mov____%al,(%edx) 8802
244 #DEFINE mov____%al,0x8(%edx) 8842
245 #DEFINE mov____%ax,(%edx) 668902
246 #DEFINE mov____%ax,0x32(%edx) 668982
247 #DEFINE mov____%ax,0x8(%edx) 668942
248 #DEFINE mov____%bl,(%ecx) 8819
249 #DEFINE mov____%eax,%edx 89c2
250 #DEFINE mov____%eax,%esi 89c6
251 #DEFINE mov____%eax,(%ecx) 8901
252 #DEFINE mov____%eax,(%edx) 8902
253 #DEFINE mov____%eax,0x32(%edx) 8982
254 #DEFINE mov____%eax,0x8(%edx) 8942
255 #DEFINE mov____%ebp,%ecx 89e9
256 #DEFINE mov____%ebp,%edx 89ea
257 #DEFINE mov____%ebp,%esi 89ee
258 #DEFINE mov____%ebx,(%ecx) 8919
259 #DEFINE mov____%ebx,0x8(%edx) 895a
260 #DEFINE mov____%ecx,%eax 89c8
261 #DEFINE mov____%ecx,%ecx 89c9
262 #DEFINE mov____%ecx,%edx 89ca
263 #DEFINE mov____%ecx,(%eax) 8908
264 #DEFINE mov____%ecx,(%edx) 890a
265 #DEFINE mov____%ecx,0x32(%ebp) 898d
266 #DEFINE mov____%ecx,0x8(%ebp) 894d
267 #DEFINE mov____%edi,%ebx 89fb
268 #DEFINE mov____%edx,%ecx 89d1
269 #DEFINE mov____%edx,(%eax) 8910
270 #DEFINE mov____%edx,0x32(%ebp) 8995
271 #DEFINE mov____%edx,0x8(%ebp) 8955
272 #DEFINE mov____%esi,%eax 89f0
273 #DEFINE mov____%esi,%ebx 89f3
274 #DEFINE mov____(%ecx),%ecx 8b09
275 #DEFINE mov____(%edx),%eax 8b02
276 #DEFINE mov____(%edx),%ecx 8b0a
277 #DEFINE mov____(%edx),%edx 8b12
278 #DEFINE mov____0x32(%eax),%ecx 8b88
279 #DEFINE mov____0x32(%ebp),%ecx 8b8d
280 #DEFINE mov____0x32(%ebp),%edx 8b95
281 #DEFINE mov____0x32,%ecx 8b0d
282 #DEFINE mov____0x32,%edx 8b15
283 #DEFINE mov____0x8(%eax),%ecx 8b48
284 #DEFINE movsbl_%cl,%ecx 0fbec9
285 #DEFINE movsbl_%dl,%edx 0fbed2
286 #DEFINE movswl_%cx,%ecx 0fbfc9
287 #DEFINE movzbl_%cl,%ecx 0fb6c9
288 #DEFINE movzbl_%dl,%edx 0fb6d2
289 #DEFINE movzbl_(%eax),%edx 0fb610
290 #DEFINE movzbl_(%ecx),%ecx 0fb609
291 #DEFINE movzbl_(%edx),%edx 0fb612
292 #DEFINE movzwl_(%ecx),%ecx 0fb709
293 #DEFINE mul____%ecx f7e1
294 #DEFINE mul____%edi f7e7
295 #DEFINE mul____%edx f7e2
296 #DEFINE mul____%esi f7e6
297 #DEFINE or_____%ecx,%ebx 09cb
298 #DEFINE or_____%edx,%eax 09d0
299 #DEFINE or_____(%edx),%eax 0b02
300 #DEFINE pop____%ecx 59
301 #DEFINE pop____%edi 5f
302 #DEFINE push___%ecx 51
303 #DEFINE push___%edi 57
304 #DEFINE push___%esi 56
305 #DEFINE shl____$i8,%ecx c1e1
306 #DEFINE shl____$i8,%edx c1e2
307 #DEFINE shl____%cl,%ecx d3e1
308 #DEFINE sub____%eax,%edx 29c2
309 #DEFINE sub____%ecx,%ebx 29cb
310 #DEFINE sub____%edx,%eax 29d0
311 #DEFINE sub____%edx,%ecx 29d1
312 #DEFINE xchg___%ebx,%ecx 87d9
313 #DEFINE xchg___%ecx,%edx 87ca
314 #DEFINE xor____%ecx,%ecx 31c9
315 #DEFINE xor____%edx,%eax 31d0
318 # deprecated, remove after 0.18
319 DEFINE sub____%esp,$i32 81ec
320 DEFINE sub____%esp,$i8 83ec
322 DEFINE SYS_exit 01000000
323 DEFINE SYS_fork 02000000
324 DEFINE SYS_read 03000000
325 DEFINE SYS_rmdir 28000000
326 DEFINE SYS_write 04000000
327 DEFINE SYS_open 05000000
328 DEFINE SYS_close 06000000
329 DEFINE SYS_waitpid 07000000
330 DEFINE SYS_unlink 0a000000
331 DEFINE SYS_execve 0b000000
332 DEFINE SYS_chmod 0f000000
333 DEFINE SYS_lseek 13000000
334 DEFINE SYS_access 21000000
335 DEFINE SYS_brk 2d000000
336 DEFINE SYS_ioctl 36000000
337 DEFINE SYS_stat 6a000000
338 DEFINE SYS_fsync 76000000
339 DEFINE SYS_getcwd b7000000