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
57 DEFINE idiv___%ebx f7fb
59 DEFINE int____$0x80 cd80
71 DEFINE jmp____*%ebx ffe3
74 DEFINE lea____0x32(%ebp),%eax 8d85
75 DEFINE lea____0x8(%ebp),%eax 8d45
77 DEFINE mov____$i32,%eax b8
78 DEFINE mov____$i32,%ebx bb
79 DEFINE mov____$i32,(%eax) c700
80 DEFINE mov____$i32,0x32 c705
81 DEFINE mov____$i32,0x8(%eax) c740
82 DEFINE mov____$i32,0x8(%ebp) c745
83 DEFINE mov____%al,(%ebx) 8803
84 DEFINE mov____%al,0x8(%ebp) 8845
85 DEFINE mov____%ax,(%ebx) 668903
86 DEFINE mov____%ax,0x8(%ebp) 668945
87 DEFINE mov____%dl,(%eax) 8810
88 DEFINE mov____%dl,0x8(%eax) 8850
89 DEFINE mov____%eax,%ebx 89c3
90 DEFINE mov____%eax,%ecx 89c1
91 DEFINE mov____%eax,(%ebx) 8903
92 DEFINE mov____%eax,0x32 a3
93 DEFINE mov____%eax,0x32(%ebp) 8985
94 DEFINE mov____%eax,0x8(%ebp) 8945
95 DEFINE mov____%ebp,%eax 89e8
96 DEFINE mov____%ebp,%ebx 89eb
97 DEFINE mov____%ebx,%eax 89d8
98 DEFINE mov____%ebx,%ecx 89d9
99 DEFINE mov____%ebx,0x32 891d
100 DEFINE mov____%ebx,0x32(%ebp) 899d
101 DEFINE mov____%ebx,0x8(%ebp) 895d
102 DEFINE mov____%ecx,(%ebx) 890b
103 DEFINE mov____%edx,%eax 89d0
104 DEFINE mov____%edx,%ebx 89d3
105 DEFINE mov____%esp,%ebp 89e5
106 DEFINE mov____(%eax),%eax 8b00
107 DEFINE mov____(%eax),%ecx 8b08
108 DEFINE mov____(%ebx),%ebx 8b1b
109 DEFINE mov____0x32(%eax),%eax 8b80
110 DEFINE mov____0x32(%eax),%ebx 8b98
111 DEFINE mov____0x32(%ebp),%eax 8b85
112 DEFINE mov____0x32(%ebp),%ebx 8b9d
113 DEFINE mov____0x32,%eax a1
114 DEFINE mov____0x32,%ebx 8b1d
115 DEFINE mov____0x8(%eax),%eax 8b40
116 DEFINE mov____0x8(%eax),%ebx 8b58
117 DEFINE mov____0x8(%ebp),%eax 8b45
118 DEFINE mov____0x8(%ebp),%ebp 8b6d
119 DEFINE mov____0x8(%ebp),%ebx 8b5d
120 DEFINE mov____0x8(%ebp),%ecx 8b4d
121 DEFINE mov____0x8(%ebp),%edi 8b7d
122 DEFINE mov____0x8(%ebp),%edx 8b55
123 DEFINE mov____0x8(%ebp),%esi 8b75
124 DEFINE mov____0x8(%ebp),%esp 8b65
125 DEFINE movb___%al,0x32 a2
126 DEFINE movsbl_%al,%eax 0fbec0
127 DEFINE movsbl_%bl,%ebx 0fbedb
128 DEFINE movswl_%ax,%eax 0fbfc0
129 DEFINE movswl_%bx,%ebx 0fbfdb
130 DEFINE movw___%ax,0x32 66a3
131 DEFINE movzbl_%al,%eax 0fb6c0
132 DEFINE movzbl_%bl,%ebx 0fb6db
133 DEFINE movzbl_%bl,%ebx 0fb6db
134 DEFINE movzbl_(%eax),%eax 0fb600
135 DEFINE movzbl_(%ebx),%ebx 0fb61b
136 DEFINE movzbl_0x32(%eax),%eax 0fb680
137 DEFINE movzbl_0x8(%eax),%eax 0fb640
138 DEFINE movzbl_0x8(%ebp),%eax 0fb645
139 DEFINE movzwl_%ax,%eax 0fb7c0
140 DEFINE movzwl_%bx,%ebx 0fb7db
141 DEFINE movzwl_(%eax),%eax 0fb700
142 DEFINE movzwl_(%ebx),%ebx 0fb71b
143 DEFINE movzwl_0x32(%eax),%eax 0fb780
144 DEFINE movzwl_0x32(%ebp),%eax 0fb785
145 DEFINE movzwl_0x8(%eax),%eax 0fb740
146 DEFINE mul____%ebx f7e3
147 DEFINE mul_____%ebx f7e3
149 DEFINE not____%eax f7d0
150 DEFINE not____%ebx f7d3
151 DEFINE or_____%ebx,%eax 09d8
152 DEFINE pop____%eax 58
153 DEFINE pop____%ebx 5b
154 DEFINE pop____%edx 5a
155 DEFINE push___$i32 68
156 DEFINE push___%eax 50
157 DEFINE push___%ebp 55
158 DEFINE push___%ebx 53
159 DEFINE push___%edx 52
160 DEFINE push___(%eax) ff30
161 DEFINE push___0x32(%ebp) ffb5
162 DEFINE push___0x8(%ebp) ff75
165 DEFINE seta___%al 0f97c0
166 DEFINE seta___%bl 0f97c3
167 DEFINE setae__%al 0f93c0
168 DEFINE setae__%bl 0f93c3
169 DEFINE setb___%al 0f92c0
170 DEFINE setb___%bl 0f92c3
171 DEFINE setbe__%al 0f96c0
172 DEFINE setbe__%bl 0f96c3
173 DEFINE sete___%al 0f94c0
174 DEFINE sete___%bl 0f94c3
175 DEFINE setg___%al 0f9fc0
176 DEFINE setg___%bl 0f9fc3
177 DEFINE setge__%al 0f9dc0
178 DEFINE setge__%bl 0f9dc3
179 DEFINE setl___%al 0f9cc0
180 DEFINE setl___%bl 0f9cc3
181 DEFINE setle__%al 0f9ec0
182 DEFINE setle__%bl 0f9ec3
183 DEFINE setne__%al 0f95c0
184 DEFINE setne__%bl 0f95c3
185 DEFINE shl____$i8,%eax c1e0
186 DEFINE shl____$i8,%ebx c1e3
187 DEFINE shl____%cl,%eax d3e0
188 DEFINE shl____%cl,%ebx d3e3
189 DEFINE shr____%cl,%eax d3e8
190 DEFINE sub____$8,%esp 83ec
191 DEFINE sub____$i32,%esp 81ec
192 DEFINE sub____%al,%dl 28d0
193 DEFINE sub____%dl,%al 28c2
194 DEFINE sub____%ebx,%eax 29d8
195 DEFINE test___%al,%al 84c0
196 DEFINE test___%eax,%eax 85c0
197 DEFINE test___%ebx,%ebx 85db
198 DEFINE xchg___%eax,%ebx 93
199 DEFINE xchg___%eax,(%esp) 870424
200 DEFINE xchg___%eax,(%esp) 870424
201 DEFINE xchg___%ebx,(%esp) 871c24
202 DEFINE xor____$i32,%eax 35
203 DEFINE xor____$i8,%ah 80f4
204 DEFINE xor____%eax,%eax 31c0
205 DEFINE xor____%ebx,%eax 31d8
206 DEFINE xor____%ebx,%ebx 31db
207 DEFINE xor____%edx,%edx 31d2
210 # Enough for all of Mes + Mes C Libray when using all registers, i.e.,
211 # non-reduced instruction set
212 #DEFINE add____$i32,%ecx 81c1
213 #DEFINE add____$i32,%edx 81c2
214 #DEFINE add____$i32,%esi 81c6
215 #DEFINE add____$i8,%ecx 83c1
216 #DEFINE add____$i8,%edx 83c2
217 #DEFINE add____$i8,%esi 83c6
218 #DEFINE add____$i8,(%ecx) 8301
219 #DEFINE add____$i8,(%edx) 8302
220 #DEFINE add____%ecx,%ebx 01cb
221 #DEFINE add____%ecx,%ecx 01c9
222 #DEFINE add____%edx,%eax 01d0
223 #DEFINE add____%edx,%ecx 01d1
224 #DEFINE add____%edx,%edx 01d2
225 #DEFINE add____%esi,%edx 01f2
226 #DEFINE and____$i32,%ecx 81e1
227 #DEFINE and____$i32,%edx 81e2
228 #DEFINE and____%edx,%eax 21d0
229 #DEFINE and____(%edx),%eax 2302
230 #DEFINE cmp____%edx,%eax 39d0
231 #DEFINE idiv___%ecx f7f9
232 #DEFINE lea____0x32(%ebp),%edx 8d95
233 #DEFINE lea____0x8(%ebp),%edx 8d55
234 #DEFINE mov____$i32,%ecx b9
235 #DEFINE mov____$i32,%edx ba
236 #DEFINE mov____$i32,%esi be
237 #DEFINE mov____%al,(%edx) 8802
238 #DEFINE mov____%al,0x8(%edx) 8842
239 #DEFINE mov____%ax,(%edx) 668902
240 #DEFINE mov____%ax,0x32(%edx) 668982
241 #DEFINE mov____%ax,0x8(%edx) 668942
242 #DEFINE mov____%bl,(%ecx) 8819
243 #DEFINE mov____%eax,%edx 89c2
244 #DEFINE mov____%eax,%esi 89c6
245 #DEFINE mov____%eax,(%ecx) 8901
246 #DEFINE mov____%eax,(%edx) 8902
247 #DEFINE mov____%eax,0x32(%edx) 8982
248 #DEFINE mov____%eax,0x8(%edx) 8942
249 #DEFINE mov____%ebp,%ecx 89e9
250 #DEFINE mov____%ebp,%edx 89ea
251 #DEFINE mov____%ebp,%esi 89ee
252 #DEFINE mov____%ebx,(%ecx) 8919
253 #DEFINE mov____%ebx,0x8(%edx) 895a
254 #DEFINE mov____%ecx,%eax 89c8
255 #DEFINE mov____%ecx,%ecx 89c9
256 #DEFINE mov____%ecx,%edx 89ca
257 #DEFINE mov____%ecx,(%eax) 8908
258 #DEFINE mov____%ecx,(%edx) 890a
259 #DEFINE mov____%ecx,0x32(%ebp) 898d
260 #DEFINE mov____%ecx,0x8(%ebp) 894d
261 #DEFINE mov____%edi,%ebx 89fb
262 #DEFINE mov____%edx,%ecx 89d1
263 #DEFINE mov____%edx,(%eax) 8910
264 #DEFINE mov____%edx,0x32(%ebp) 8995
265 #DEFINE mov____%edx,0x8(%ebp) 8955
266 #DEFINE mov____%esi,%eax 89f0
267 #DEFINE mov____%esi,%ebx 89f3
268 #DEFINE mov____(%ecx),%ecx 8b09
269 #DEFINE mov____(%edx),%eax 8b02
270 #DEFINE mov____(%edx),%ecx 8b0a
271 #DEFINE mov____(%edx),%edx 8b12
272 #DEFINE mov____0x32(%eax),%ecx 8b88
273 #DEFINE mov____0x32(%ebp),%ecx 8b8d
274 #DEFINE mov____0x32(%ebp),%edx 8b95
275 #DEFINE mov____0x32,%ecx 8b0d
276 #DEFINE mov____0x32,%edx 8b15
277 #DEFINE mov____0x8(%eax),%ecx 8b48
278 #DEFINE movsbl_%cl,%ecx 0fbec9
279 #DEFINE movsbl_%dl,%edx 0fbed2
280 #DEFINE movswl_%cx,%ecx 0fbfc9
281 #DEFINE movzbl_%cl,%ecx 0fb6c9
282 #DEFINE movzbl_%dl,%edx 0fb6d2
283 #DEFINE movzbl_(%eax),%edx 0fb610
284 #DEFINE movzbl_(%ecx),%ecx 0fb609
285 #DEFINE movzbl_(%edx),%edx 0fb612
286 #DEFINE movzwl_(%ecx),%ecx 0fb709
287 #DEFINE mul____%ecx f7e1
288 #DEFINE mul____%edi f7e7
289 #DEFINE mul____%edx f7e2
290 #DEFINE mul____%esi f7e6
291 #DEFINE or_____%ecx,%ebx 09cb
292 #DEFINE or_____%edx,%eax 09d0
293 #DEFINE or_____(%edx),%eax 0b02
294 #DEFINE pop____%ecx 59
295 #DEFINE pop____%edi 5f
296 #DEFINE push___%ecx 51
297 #DEFINE push___%edi 57
298 #DEFINE push___%esi 56
299 #DEFINE shl____$i8,%ecx c1e1
300 #DEFINE shl____$i8,%edx c1e2
301 #DEFINE shl____%cl,%ecx d3e1
302 #DEFINE sub____%eax,%edx 29c2
303 #DEFINE sub____%ecx,%ebx 29cb
304 #DEFINE sub____%edx,%eax 29d0
305 #DEFINE sub____%edx,%ecx 29d1
306 #DEFINE xchg___%ebx,%ecx 87d9
307 #DEFINE xchg___%ecx,%edx 87ca
308 #DEFINE xor____%ecx,%ecx 31c9
309 #DEFINE xor____%edx,%eax 31d0
312 # deprecated, remove after 0.18
313 DEFINE sub____%esp,$i32 81ec
314 DEFINE sub____%esp,$i8 83ec
316 DEFINE SYS_exit 01000000
317 DEFINE SYS_fork 02000000
318 DEFINE SYS_read 03000000
319 DEFINE SYS_rmdir 28000000
320 DEFINE SYS_write 04000000
321 DEFINE SYS_open 05000000
322 DEFINE SYS_close 06000000
323 DEFINE SYS_waitpid 07000000
324 DEFINE SYS_unlink 0a000000
325 DEFINE SYS_execve 0b000000
326 DEFINE SYS_chmod 0f000000
327 DEFINE SYS_lseek 13000000
328 DEFINE SYS_access 21000000
329 DEFINE SYS_brk 2d000000
330 DEFINE SYS_ioctl 36000000
331 DEFINE SYS_stat 6a000000
332 DEFINE SYS_fsync 76000000
333 DEFINE SYS_getcwd b7000000