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