https://github.com/akkartik/mu/blob/master/077subx-words.subx
1
2
3 == code
4
5
6
7
8 has-metadata?:
9
10
11
12
13
14
15
16
17
18
19 55/push-ebp
20 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
21
22 51/push-ecx
23 52/push-edx
24 56/push-esi
25 57/push-edi
26
27 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 6/r32/esi 8/disp8 .
28
29 8b/copy 1/mod/*+disp8 6/rm32/esi . . . 2/r32/edx 4/disp8 .
30
31 68/push 0/imm32/end
32 68/push 0/imm32/start
33 89/copy 3/mod/direct 7/rm32/edi . . . 4/r32/esp . .
34
35
36 57/push-edi
37 68/push 0x2f/imm32/slash
38 52/push-edx
39 ff 6/subop/push 0/mod/indirect 6/rm32/esi . . . . . .
40
41 e8/call next-token-from-slice/disp32
42
43 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0x10/imm32
44 $has-metadata?:loop:
45
46
47 57/push-edi
48 68/push 0x2f/imm32/slash
49 52/push-edx
50 ff 6/subop/push 1/mod/*+disp8 7/rm32/edi . . . . 4/disp8 .
51
52 e8/call next-token-from-slice/disp32
53
54 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0x10/imm32
55
56
57
58 57/push-edi
59
60 e8/call slice-empty?/disp32
61
62 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
63
64 3d/compare-eax-and 0/imm32/false
65 75/jump-if-!= $has-metadata?:false/disp8
66
67
68
69 ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 0xc/disp8 .
70 57/push-edi
71
72 e8/call slice-equal?/disp32
73
74 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
75
76 3d/compare-eax-and 0/imm32/false
77
78 75/jump-if-!= $has-metadata?:end/disp8
79 eb/jump $has-metadata?:loop/disp8
80 $has-metadata?:false:
81 b8/copy-to-eax 0/imm32/false
82 $has-metadata?:end:
83
84 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
85
86 5f/pop-to-edi
87 5e/pop-to-esi
88 5a/pop-to-edx
89 59/pop-to-ecx
90
91 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
92 5d/pop-to-ebp
93 c3/return
94
95 test-has-metadata-true:
96
97 55/push-ebp
98 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
99
100 b8/copy-to-eax "ab/imm32"/imm32
101 8b/copy 0/mod/indirect 0/rm32/eax . . . 1/r32/ecx . .
102 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/eax 1/index/ecx . 1/r32/ecx 4/disp8 .
103 05/add-to-eax 4/imm32
104
105 51/push-ecx
106 50/push-eax
107 89/copy 3/mod/direct 6/rm32/esi . . . 4/r32/esp . .
108
109
110 68/push "imm32"/imm32
111 56/push-esi
112
113 e8/call has-metadata?/disp32
114
115 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
116
117
118 68/push "F - test-has-metadata-true"/imm32
119 68/push 1/imm32/true
120 50/push-eax
121
122 e8/call check-ints-equal/disp32
123
124 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
125
126 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
127 5d/pop-to-ebp
128 c3/return
129
130 test-has-metadata-false:
131
132 55/push-ebp
133 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
134
135 b8/copy-to-eax "ab/c"/imm32
136 8b/copy 0/mod/indirect 0/rm32/eax . . . 1/r32/ecx . .
137 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/eax 1/index/ecx . 1/r32/ecx 4/disp8 .
138 05/add-to-eax 4/imm32
139
140 51/push-ecx
141 50/push-eax
142 89/copy 3/mod/direct 6/rm32/esi . . . 4/r32/esp . .
143
144
145 68/push "d"/imm32
146 56/push-esi
147
148 e8/call has-metadata?/disp32
149
150 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
151
152
153 68/push "F - test-has-metadata-false"/imm32
154 68/push 0/imm32/false
155 50/push-eax
156
157 e8/call check-ints-equal/disp32
158
159 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
160
161 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
162 5d/pop-to-ebp
163 c3/return
164
165 test-has-metadata-ignore-name:
166
167 55/push-ebp
168 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
169
170 b8/copy-to-eax "a/b"/imm32
171 8b/copy 0/mod/indirect 0/rm32/eax . . . 1/r32/ecx . .
172 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/eax 1/index/ecx . 1/r32/ecx 4/disp8 .
173 05/add-to-eax 4/imm32
174
175 51/push-ecx
176 50/push-eax
177 89/copy 3/mod/direct 6/rm32/esi . . . 4/r32/esp . .
178
179
180 68/push "a"/imm32
181 56/push-esi
182
183 e8/call has-metadata?/disp32
184
185 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
186
187
188 68/push "F - test-has-metadata-ignore-name"/imm32
189 68/push 0/imm32/false
190 50/push-eax
191
192 e8/call check-ints-equal/disp32
193
194 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
195
196 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
197 5d/pop-to-ebp
198 c3/return
199
200 test-has-metadata-multiple-true:
201
202 55/push-ebp
203 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
204
205 b8/copy-to-eax "a/b/c"/imm32
206 8b/copy 0/mod/indirect 0/rm32/eax . . . 1/r32/ecx . .
207 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/eax 1/index/ecx . 1/r32/ecx 4/disp8 .
208 05/add-to-eax 4/imm32
209
210 51/push-ecx
211 50/push-eax
212 89/copy 3/mod/direct 6/rm32/esi . . . 4/r32/esp . .
213
214
215 68/push "c"/imm32
216 56/push-esi
217
218 e8/call has-metadata?/disp32
219
220 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
221
222
223 68/push "F - test-has-metadata-multiple-true"/imm32
224 68/push 1/imm32/true
225 50/push-eax
226
227 e8/call check-ints-equal/disp32
228
229 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
230
231 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
232 5d/pop-to-ebp
233 c3/return
234
235 test-has-metadata-multiple-false:
236
237 55/push-ebp
238 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
239
240 b8/copy-to-eax "a/b/c"/imm32
241 8b/copy 0/mod/indirect 0/rm32/eax . . . 1/r32/ecx . .
242 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/eax 1/index/ecx . 1/r32/ecx 4/disp8 .
243 05/add-to-eax 4/imm32
244
245 51/push-ecx
246 50/push-eax
247 89/copy 3/mod/direct 6/rm32/esi . . . 4/r32/esp . .
248
249
250 68/push "d"/imm32
251 56/push-esi
252
253 e8/call has-metadata?/disp32
254
255 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
256
257
258 68/push "F - test-has-metadata-multiple-false"/imm32
259 68/push 0/imm32/false
260 50/push-eax
261
262 e8/call check-ints-equal/disp32
263
264 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
265
266 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
267 5d/pop-to-ebp
268 c3/return
269
270
271
272
273
274
275
276
277
278 is-valid-name?:
279
280 55/push-ebp
281 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
282
283 51/push-ecx
284 56/push-esi
285
286 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 6/r32/esi 8/disp8 .
287
288 8b/copy 0/mod/indirect 6/rm32/esi . . . 1/r32/ecx . .
289 $is-valid-name?:check0:
290
291 3b/compare 1/mod/*+disp8 6/rm32/esi . . . 1/r32/ecx 4/disp8 .
292 73/jump-if-addr>= $is-valid-name?:false/disp8
293 $is-valid-name?:check1:
294
295 8b/copy 1/mod/*+disp8 6/rm32/esi . . . 0/r32/eax 4/disp8 .
296 29/subtract 3/mod/direct 0/rm32/eax . . . 1/r32/ecx . .
297
298 3d/compare-eax-and 2/imm32
299 74/jump-if-= $is-valid-name?:false/disp8
300 $is-valid-name?:check2:
301
302 31/xor 3/mod/direct 0/rm32/eax . . . 0/r32/eax . .
303 8a/copy-byte 0/mod/indirect 1/rm32/ecx . . . 0/r32/AL . .
304
305 3d/compare-eax-and 2d/imm32/-
306 74/jump-if-= $is-valid-name?:false/disp8
307 $is-valid-name?:check3a:
308
309 3d/compare-eax-with 30/imm32/0
310 7c/jump-if-< $is-valid-name?:true/disp8
311 $is-valid-name?:check3b:
312
313 3d/compare-eax-with 39/imm32/9
314 7f/jump-if-> $is-valid-name?:true/disp8
315 $is-valid-name?:false:
316
317 b8/copy-to-eax 0/imm32/false
318 eb/jump $is-valid-name?:end/disp8
319 $is-valid-name?:true:
320
321 b8/copy-to-eax 1/imm32/true
322 $is-valid-name?:end:
323
324 5e/pop-to-esi
325 59/pop-to-ecx
326
327 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
328 5d/pop-to-ebp
329 c3/return
330
331 test-is-valid-name-digit-prefix:
332
333 55/push-ebp
334 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
335
336 b8/copy-to-eax "34"/imm32
337 8b/copy 0/mod/indirect 0/rm32/eax . . . 1/r32/ecx . .
338 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/eax 1/index/ecx . 1/r32/ecx 4/disp8 .
339 05/add-to-eax 4/imm32
340
341 51/push-ecx
342 50/push-eax
343 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . .
344
345
346 51/push-ecx
347
348 e8/call is-valid-name?/disp32
349
350 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
351
352
353 68/push "F - test-is-valid-name-digit-prefix"/imm32
354 68/push 0/imm32/false
355 50/push-eax
356
357 e8/call check-ints-equal/disp32
358
359 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
360
361 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
362 5d/pop-to-ebp
363 c3/return
364
365 test-is-valid-name-negative-prefix:
366
367 55/push-ebp
368 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
369
370 b8/copy-to-eax "-0x34"/imm32
371 8b/copy 0/mod/indirect 0/rm32/eax . . . 1/r32/ecx . .
372 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/eax 1/index/ecx . 1/r32/ecx 4/disp8 .
373 05/add-to-eax 4/imm32
374
375 51/push-ecx
376 50/push-eax
377 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . .
378
379
380 51/push-ecx
381
382 e8/call is-valid-name?/disp32
383
384 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
385
386
387 68/push "F - test-is-valid-name-negative-prefix"/imm32
388 68/push 0/imm32/false
389 50/push-eax
390
391 e8/call check-ints-equal/disp32
392
393 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
394
395 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
396 5d/pop-to-ebp
397 c3/return
398
399 test-is-valid-name-0x-prefix:
400
401 55/push-ebp
402 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
403
404 b8/copy-to-eax "0x34"/imm32
405 8b/copy 0/mod/indirect 0/rm32/eax . . . 1/r32/ecx . .
406 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/eax 1/index/ecx . 1/r32/ecx 4/disp8 .
407 05/add-to-eax 4/imm32
408
409 51/push-ecx
410 50/push-eax
411 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . .
412
413
414 51/push-ecx
415
416 e8/call is-valid-name?/disp32
417
418 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
419
420
421 68/push "F - test-is-valid-name-0x-prefix"/imm32
422 68/push 0/imm32/false
423 50/push-eax
424
425 e8/call check-ints-equal/disp32
426
427 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
428
429 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
430 5d/pop-to-ebp
431 c3/return
432
433 test-is-valid-name-starts-with-pre-digit:
434
435 55/push-ebp
436 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
437
438 b8/copy-to-eax "/03"/imm32
439 8b/copy 0/mod/indirect 0/rm32/eax . . . 1/r32/ecx . .
440 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/eax 1/index/ecx . 1/r32/ecx 4/disp8 .
441 05/add-to-eax 4/imm32
442
443 51/push-ecx
444 50/push-eax
445 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . .
446
447
448 51/push-ecx
449
450 e8/call is-valid-name?/disp32
451
452 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
453
454
455 68/push "F - test-is-valid-name-starts-with-pre-digit"/imm32
456 68/push 1/imm32/true
457 50/push-eax
458
459 e8/call check-ints-equal/disp32
460
461 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
462
463 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
464 5d/pop-to-ebp
465 c3/return
466
467 test-is-valid-name-starts-with-post-digit:
468
469 55/push-ebp
470 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
471
472 b8/copy-to-eax "q34"/imm32
473 8b/copy 0/mod/indirect 0/rm32/eax . . . 1/r32/ecx . .
474 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/eax 1/index/ecx . 1/r32/ecx 4/disp8 .
475 05/add-to-eax 4/imm32
476
477 51/push-ecx
478 50/push-eax
479 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . .
480
481
482 51/push-ecx
483
484 e8/call is-valid-name?/disp32
485
486 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
487
488
489 68/push "F - test-is-valid-name-starts-with-post-digit"/imm32
490 68/push 1/imm32/true
491 50/push-eax
492
493 e8/call check-ints-equal/disp32
494
495 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
496
497 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
498 5d/pop-to-ebp
499 c3/return
500
501 test-is-valid-name-starts-with-digit:
502
503 55/push-ebp
504 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
505
506 b8/copy-to-eax "0x34"/imm32
507 8b/copy 0/mod/indirect 0/rm32/eax . . . 1/r32/ecx . .
508 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/eax 1/index/ecx . 1/r32/ecx 4/disp8 .
509 05/add-to-eax 4/imm32
510
511 51/push-ecx
512 50/push-eax
513 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . .
514
515
516 51/push-ecx
517
518 e8/call is-valid-name?/disp32
519
520 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
521
522
523 68/push "F - test-is-valid-name-starts-with-digit"/imm32
524 68/push 0/imm32/false
525 50/push-eax
526
527 e8/call check-ints-equal/disp32
528
529 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
530
531 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
532 5d/pop-to-ebp
533 c3/return
534
535 is-label?:
536
537 55/push-ebp
538 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
539
540 51/push-ecx
541
542 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 1/r32/ecx 8/disp8 .
543
544 8b/copy 1/mod/*+disp8 1/rm32/ecx . . . 1/r32/ecx 4/disp8 .
545
546
547 31/xor 3/mod/direct 0/rm32/eax . . . 0/r32/eax . .
548 8a/copy-byte 1/mod/*+disp8 1/rm32/ecx . . . 0/r32/AL -1/disp8 .
549
550 3d/compare-eax-and 0x3a/imm32/colon
551 b8/copy-to-eax 1/imm32/true
552 74/jump-if-= $is-label?:end/disp8
553 b8/copy-to-eax 0/imm32/false
554 $is-label?:end:
555
556 59/pop-to-ecx
557
558 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
559 5d/pop-to-ebp
560 c3/return
561
562 test-is-label?:
563
564 55/push-ebp
565 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
566 $test-is-label?:true:
567
568 b8/copy-to-eax "AAA:"/imm32
569 8b/copy 0/mod/indirect 0/rm32/eax . . . 1/r32/ecx . .
570 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/eax 1/index/ecx . 1/r32/ecx 4/disp8 .
571 05/add-to-eax 4/imm32
572
573 51/push-ecx
574 50/push-eax
575 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . .
576
577
578 51/push-ecx
579
580 e8/call is-label?/disp32
581
582 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
583
584
585 68/push "F - test-is-label?:true"/imm32
586 68/push 1/imm32
587 50/push-eax
588
589 e8/call check-ints-equal/disp32
590
591 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
592 $test-is-label?:false:
593
594 b8/copy-to-eax "AAA"/imm32
595 8b/copy 0/mod/indirect 0/rm32/eax . . . 1/r32/ecx . .
596 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/eax 1/index/ecx . 1/r32/ecx 4/disp8 .
597 05/add-to-eax 4/imm32
598
599 51/push-ecx
600 50/push-eax
601 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . .
602
603
604 51/push-ecx
605
606 e8/call is-label?/disp32
607
608 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
609
610
611 68/push "F - test-is-label?:false"/imm32
612 68/push 0/imm32
613 50/push-eax
614
615 e8/call check-ints-equal/disp32
616
617 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
618
619 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
620 5d/pop-to-ebp
621 c3/return
622
623