https://github.com/akkartik/mu/blob/master/067parse-hex.subx
1
2
3
4 == code
5
6
7
8
9 is-hex-int?:
10
11 55/push-ebp
12 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
13
14 51/push-ecx
15 52/push-edx
16 53/push-ebx
17
18 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 1/r32/ecx 8/disp8 .
19
20 8b/copy 1/mod/*+disp8 1/rm32/ecx . . . 2/r32/edx 4/disp8 .
21
22 8b/copy 0/mod/indirect 1/rm32/ecx . . . 1/r32/ecx . .
23
24 b8/copy-to-eax 0/imm32/false
25 39/compare 3/mod/direct 1/rm32/ecx . . . 2/r32/edx . .
26 73/jump-if-greater-or-equal-unsigned $is-hex-int?:end/disp8
27
28
29 31/xor 3/mod/direct 3/rm32/ebx . . . 3/r32/ebx . .
30 8a/copy-byte 0/mod/indirect 1/rm32/ecx . . . 3/r32/BL . .
31 81 7/subop/compare 3/mod/direct 3/rm32/ebx . . . . . 0x2d/imm32/-
32 75/jump-if-not-equal $is-hex-int?:initial-0/disp8
33
34 41/increment-ecx
35
36 $is-hex-int?:initial-0:
37
38 31/xor 3/mod/direct 3/rm32/ebx . . . 3/r32/ebx . .
39 8a/copy-byte 0/mod/indirect 1/rm32/ecx . . . 3/r32/BL . .
40 81 7/subop/compare 3/mod/direct 3/rm32/ebx . . . . . 0x30/imm32/0
41 75/jump-if-not-equal $is-hex-int?:loop/disp8
42
43 41/increment-ecx
44 $is-hex-int?:initial-0x:
45
46 39/compare 3/mod/direct 1/rm32/ecx . . . 2/r32/edx . .
47 73/jump-if-greater-or-equal-unsigned $is-hex-int?:true/disp8
48
49 31/xor 3/mod/direct 3/rm32/ebx . . . 3/r32/ebx . .
50 8a/copy-byte 0/mod/indirect 1/rm32/ecx . . . 3/r32/BL . .
51 81 7/subop/compare 3/mod/direct 3/rm32/ebx . . . . . 0x78/imm32/x
52 75/jump-if-not-equal $is-hex-int?:loop/disp8
53
54 41/increment-ecx
55 $is-hex-int?:loop:
56
57 39/compare 3/mod/direct 1/rm32/ecx . . . 2/r32/edx . .
58 73/jump-if-greater-or-equal-unsigned $is-hex-int?:true/disp8
59
60
61 8a/copy-byte 0/mod/indirect 1/rm32/ecx . . . 0/r32/AL . .
62 50/push-eax
63
64 e8/call is-hex-digit?/disp32
65
66 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
67
68 3d/compare-eax-and 0/imm32
69 74/jump-if-equal $is-hex-int?:end/disp8
70
71 41/increment-ecx
72
73 eb/jump $is-hex-int?:loop/disp8
74 $is-hex-int?:true:
75
76 b8/copy-to-eax 1/imm32/true
77 $is-hex-int?:end:
78
79 5b/pop-to-ebx
80 5a/pop-to-edx
81 59/pop-to-ecx
82
83 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
84 5d/pop-to-ebp
85 c3/return
86
87 test-is-hex-int:
88
89 55/push-ebp
90 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
91
92 b8/copy-to-eax "34"/imm32
93 8b/copy 0/mod/indirect 0/rm32/eax . . . 1/r32/ecx . .
94 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/eax 1/index/ecx . 1/r32/ecx 4/disp8 .
95 05/add-to-eax 4/imm32
96
97 51/push-ecx
98 50/push-eax
99 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . .
100
101
102 51/push-ecx
103
104 e8/call is-hex-int?/disp32
105
106 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
107
108
109 68/push "F - test-is-hex-int"/imm32
110 68/push 1/imm32/true
111 50/push-eax
112
113 e8/call check-ints-equal/disp32
114
115 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
116
117 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
118 5d/pop-to-ebp
119 c3/return
120
121 test-is-hex-int-handles-letters:
122
123 55/push-ebp
124 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
125
126 b8/copy-to-eax "34a"/imm32
127 8b/copy 0/mod/indirect 0/rm32/eax . . . 1/r32/ecx . .
128 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/eax 1/index/ecx . 1/r32/ecx 4/disp8 .
129 05/add-to-eax 4/imm32
130
131 51/push-ecx
132 50/push-eax
133 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . .
134
135
136 51/push-ecx
137
138 e8/call is-hex-int?/disp32
139
140 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
141
142
143 68/push "F - test-is-hex-int-handles-letters"/imm32
144 68/push 1/imm32/true
145 50/push-eax
146
147 e8/call check-ints-equal/disp32
148
149 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
150
151 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
152 5d/pop-to-ebp
153 c3/return
154
155 test-is-hex-int-with-trailing-char:
156
157 55/push-ebp
158 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
159
160 b8/copy-to-eax "34q"/imm32
161 8b/copy 0/mod/indirect 0/rm32/eax . . . 1/r32/ecx . .
162 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/eax 1/index/ecx . 1/r32/ecx 4/disp8 .
163 05/add-to-eax 4/imm32
164
165 51/push-ecx
166 50/push-eax
167 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . .
168
169
170 51/push-ecx
171
172 e8/call is-hex-int?/disp32
173
174 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
175
176
177 68/push "F - test-is-hex-int-with-trailing-char"/imm32
178 68/push 0/imm32/false
179 50/push-eax
180
181 e8/call check-ints-equal/disp32
182
183 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
184
185 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
186 5d/pop-to-ebp
187 c3/return
188
189 test-is-hex-int-with-leading-char:
190
191 55/push-ebp
192 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
193
194 b8/copy-to-eax "q34"/imm32
195 8b/copy 0/mod/indirect 0/rm32/eax . . . 1/r32/ecx . .
196 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/eax 1/index/ecx . 1/r32/ecx 4/disp8 .
197 05/add-to-eax 4/imm32
198
199 51/push-ecx
200 50/push-eax
201 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . .
202
203
204 51/push-ecx
205
206 e8/call is-hex-int?/disp32
207
208 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
209
210
211 68/push "F - test-is-hex-int-with-leading-char"/imm32
212 68/push 0/imm32/false
213 50/push-eax
214
215 e8/call check-ints-equal/disp32
216
217 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
218
219 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
220 5d/pop-to-ebp
221 c3/return
222
223 test-is-hex-int-empty:
224
225 55/push-ebp
226 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
227
228 68/push 0/imm32
229 68/push 0/imm32
230 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . .
231
232
233 51/push-ecx
234
235 e8/call is-hex-int?/disp32
236
237 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
238
239
240 68/push "F - test-is-hex-int-empty"/imm32
241 68/push 0/imm32/false
242 50/push-eax
243
244 e8/call check-ints-equal/disp32
245
246 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
247
248 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
249 5d/pop-to-ebp
250 c3/return
251
252 test-is-hex-int-handles-0x-prefix:
253
254 55/push-ebp
255 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
256
257 b8/copy-to-eax "0x3a"/imm32
258 8b/copy 0/mod/indirect 0/rm32/eax . . . 1/r32/ecx . .
259 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/eax 1/index/ecx . 1/r32/ecx 4/disp8 .
260 05/add-to-eax 4/imm32
261
262 51/push-ecx
263 50/push-eax
264 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . .
265
266
267 51/push-ecx
268
269 e8/call is-hex-int?/disp32
270
271 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
272
273
274 68/push "F - test-is-hex-int-handles-0x-prefix"/imm32
275 68/push 1/imm32/true
276 50/push-eax
277
278 e8/call check-ints-equal/disp32
279
280 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
281
282 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
283 5d/pop-to-ebp
284 c3/return
285
286 test-is-hex-int-handles-negative:
287
288 55/push-ebp
289 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
290
291 b8/copy-to-eax "-34a"/imm32
292 8b/copy 0/mod/indirect 0/rm32/eax . . . 1/r32/ecx . .
293 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/eax 1/index/ecx . 1/r32/ecx 4/disp8 .
294 05/add-to-eax 4/imm32
295
296 51/push-ecx
297 50/push-eax
298 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . .
299
300
301 51/push-ecx
302
303 e8/call is-hex-int?/disp32
304
305 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
306
307
308 68/push "F - test-is-hex-int-handles-negative"/imm32
309 68/push 1/imm32/true
310 50/push-eax
311
312 e8/call check-ints-equal/disp32
313
314 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
315
316 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
317 5d/pop-to-ebp
318 c3/return
319
320 test-is-hex-int-handles-negative-0x-prefix:
321
322 55/push-ebp
323 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
324
325 b8/copy-to-eax "-0x3a"/imm32
326 8b/copy 0/mod/indirect 0/rm32/eax . . . 1/r32/ecx . .
327 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/eax 1/index/ecx . 1/r32/ecx 4/disp8 .
328 05/add-to-eax 4/imm32
329
330 51/push-ecx
331 50/push-eax
332 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . .
333
334
335 51/push-ecx
336
337 e8/call is-hex-int?/disp32
338
339 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
340
341
342 68/push "F - test-is-hex-int-handles-negative-0x-prefix"/imm32
343 68/push 1/imm32/true
344 50/push-eax
345
346 e8/call check-ints-equal/disp32
347
348 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
349
350 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
351 5d/pop-to-ebp
352 c3/return
353
354 parse-hex-int:
355
356 55/push-ebp
357 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
358
359 51/push-ecx
360 52/push-edx
361 53/push-ebx
362 56/push-esi
363
364 31/xor 3/mod/direct 3/rm32/ebx . . . 3/r32/ebx . .
365
366 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 1/r32/ecx 8/disp8 .
367
368 8b/copy 1/mod/*+disp8 1/rm32/ecx . . . 2/r32/edx 4/disp8 .
369
370 8b/copy 0/mod/indirect 1/rm32/ecx . . . 1/r32/ecx . .
371
372 31/xor 3/mod/direct 6/rm32/esi . . . 6/r32/esi . .
373 $parse-hex-int:negative:
374
375 31/xor 3/mod/direct 0/rm32/eax . . . 0/r32/eax . .
376 8a/copy-byte 0/mod/indirect 1/rm32/ecx . . . 0/r32/AL . .
377 3d/compare-eax-and 0x2d/imm32/-
378 75/jump-if-not-equal $parse-hex-int:initial-0/disp8
379
380 41/increment-ecx
381
382 be/copy-to-esi 1/imm32/true
383 $parse-hex-int:initial-0:
384
385
386 8a/copy-byte 0/mod/indirect 1/rm32/ecx . . . 0/r32/AL . .
387 3d/compare-eax-and 0x30/imm32/0
388 75/jump-if-not-equal $parse-hex-int:loop/disp8
389
390 41/increment-ecx
391 $parse-hex-int:initial-0x:
392
393 39/compare 3/mod/direct 1/rm32/ecx . . . 2/r32/edx . .
394 73/jump-if-greater-or-equal-unsigned $parse-hex-int:end/disp8
395
396 31/xor 3/mod/direct 0/rm32/eax . . . 0/r32/eax . .
397 8a/copy-byte 0/mod/indirect 1/rm32/ecx . . . 0/r32/AL . .
398 3d/compare-eax-and 0x78/imm32/x
399 75/jump-if-not-equal $parse-hex-int:loop/disp8
400
401 41/increment-ecx
402 $parse-hex-int:loop:
403
404 39/compare 3/mod/direct 1/rm32/ecx . . . 2/r32/edx . .
405 73/jump-if-greater-or-equal-unsigned $parse-hex-int:negate/disp8
406
407
408 8a/copy-byte 0/mod/indirect 1/rm32/ecx . . . 0/r32/AL . .
409
410 e8/call from-hex-char/disp32
411
412 c1/shift 4/subop/left 3/mod/direct 3/rm32/ebx . . . . . 4/imm8
413 01/add 3/mod/direct 3/rm32/ebx . . . 0/r32/eax . .
414
415 41/increment-ecx
416
417 eb/jump $parse-hex-int:loop/disp8
418 $parse-hex-int:negate:
419 81 7/subop/compare 3/mod/direct 6/rm32/esi . . . . . 0/imm32
420 74/jump-if-equal $parse-hex-int:end/disp8
421 f7 3/subop/negate 3/mod/direct 3/rm32/ebx . . . . . .
422 $parse-hex-int:end:
423 89/copy 3/mod/direct 0/rm32/eax . . . 3/r32/ebx . .
424
425 5e/pop-to-esi
426 5b/pop-to-ebx
427 5a/pop-to-edx
428 59/pop-to-ecx
429
430 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
431 5d/pop-to-ebp
432 c3/return
433
434 test-parse-hex-int-single-digit:
435
436 55/push-ebp
437 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
438
439 b8/copy-to-eax "a"/imm32
440 8b/copy 0/mod/indirect 0/rm32/eax . . . 1/r32/ecx . .
441 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/eax 1/index/ecx . 1/r32/ecx 4/disp8 .
442 05/add-to-eax 4/imm32
443
444 51/push-ecx
445 50/push-eax
446 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . .
447
448
449 51/push-ecx
450
451 e8/call parse-hex-int/disp32
452
453 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
454
455
456 68/push "F - test-parse-hex-int-single-digit"/imm32
457 68/push 0xa/imm32
458 50/push-eax
459
460 e8/call check-ints-equal/disp32
461
462 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
463
464 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
465 5d/pop-to-ebp
466 c3/return
467
468 test-parse-hex-int-multi-digit:
469
470 55/push-ebp
471 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
472
473 b8/copy-to-eax "34a"/imm32
474 8b/copy 0/mod/indirect 0/rm32/eax . . . 1/r32/ecx . .
475 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/eax 1/index/ecx . 1/r32/ecx 4/disp8 .
476 05/add-to-eax 4/imm32
477
478 51/push-ecx
479 50/push-eax
480 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . .
481
482
483 51/push-ecx
484
485 e8/call parse-hex-int/disp32
486
487 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
488
489
490 68/push "F - test-parse-hex-int-multi-digit"/imm32
491 68/push 0x34a/imm32
492 50/push-eax
493
494 e8/call check-ints-equal/disp32
495
496 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
497
498 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
499 5d/pop-to-ebp
500 c3/return
501
502 test-parse-hex-int-0x-prefix:
503
504 55/push-ebp
505 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
506
507 b8/copy-to-eax "0x34"/imm32
508 8b/copy 0/mod/indirect 0/rm32/eax . . . 1/r32/ecx . .
509 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/eax 1/index/ecx . 1/r32/ecx 4/disp8 .
510 05/add-to-eax 4/imm32
511
512 51/push-ecx
513 50/push-eax
514 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . .
515
516
517 51/push-ecx
518
519 e8/call parse-hex-int/disp32
520
521 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
522
523
524 68/push "F - test-parse-hex-int-0x-prefix"/imm32
525 68/push 0x34/imm32
526 50/push-eax
527
528 e8/call check-ints-equal/disp32
529
530 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
531
532 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
533 5d/pop-to-ebp
534 c3/return
535
536 test-parse-hex-int-zero:
537
538 55/push-ebp
539 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
540
541 b8/copy-to-eax "0"/imm32
542 8b/copy 0/mod/indirect 0/rm32/eax . . . 1/r32/ecx . .
543 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/eax 1/index/ecx . 1/r32/ecx 4/disp8 .
544 05/add-to-eax 4/imm32
545
546 51/push-ecx
547 50/push-eax
548 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . .
549
550
551 51/push-ecx
552
553 e8/call parse-hex-int/disp32
554
555 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
556
557
558 68/push "F - test-parse-hex-int-zero"/imm32
559 68/push 0/imm32
560 50/push-eax
561
562 e8/call check-ints-equal/disp32
563
564 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
565
566 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
567 5d/pop-to-ebp
568 c3/return
569
570 test-parse-hex-int-0-prefix:
571
572 55/push-ebp
573 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
574
575 b8/copy-to-eax "03"/imm32
576 8b/copy 0/mod/indirect 0/rm32/eax . . . 1/r32/ecx . .
577 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/eax 1/index/ecx . 1/r32/ecx 4/disp8 .
578 05/add-to-eax 4/imm32
579
580 51/push-ecx
581 50/push-eax
582 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . .
583
584
585 51/push-ecx
586
587 e8/call parse-hex-int/disp32
588
589 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
590
591
592 68/push "F - test-parse-hex-int-0-prefix"/imm32
593 68/push 0x3/imm32
594 50/push-eax
595
596 e8/call check-ints-equal/disp32
597
598 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
599
600 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
601 5d/pop-to-ebp
602 c3/return
603
604 test-parse-hex-int-negative:
605
606 55/push-ebp
607 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
608
609 b8/copy-to-eax "-03"/imm32
610 8b/copy 0/mod/indirect 0/rm32/eax . . . 1/r32/ecx . .
611 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/eax 1/index/ecx . 1/r32/ecx 4/disp8 .
612 05/add-to-eax 4/imm32
613
614 51/push-ecx
615 50/push-eax
616 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . .
617
618
619 51/push-ecx
620
621 e8/call parse-hex-int/disp32
622
623 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
624
625
626 68/push "F - test-parse-hex-int-negative"/imm32
627 68/push -3/imm32
628 50/push-eax
629
630 e8/call check-ints-equal/disp32
631
632 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
633
634 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
635 5d/pop-to-ebp
636 c3/return
637
638 is-hex-digit?:
639
640 55/push-ebp
641 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
642
643 51/push-ecx
644
645 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 1/r32/ecx 8/disp8 .
646
647 b8/copy-to-eax 0/imm32/false
648 81 7/subop/compare 3/mod/direct 1/rm32/ecx . . . . . 0x30/imm32
649 7c/jump-if-lesser $is-hex-digit?:end/disp8
650
651 81 7/subop/compare 3/mod/direct 1/rm32/ecx . . . . . 0x66/imm32
652 7f/jump-if-greater $is-hex-digit?:end/disp8
653
654 b8/copy-to-eax 1/imm32/true
655 81 7/subop/compare 3/mod/direct 1/rm32/ecx . . . . . 0x39/imm32
656 7e/jump-if-lesser-or-equal $is-hex-digit?:end/disp8
657
658 81 7/subop/compare 3/mod/direct 1/rm32/ecx . . . . . 0x61/imm32
659 7d/jump-if-greater-or-equal $is-hex-digit?:end/disp8
660
661 b8/copy-to-eax 0/imm32/false
662 $is-hex-digit?:end:
663
664 59/pop-to-ecx
665
666 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
667 5d/pop-to-ebp
668 c3/return
669
670 test-hex-below-0:
671
672
673 68/push 0x2f/imm32
674
675 e8/call is-hex-digit?/disp32
676
677 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
678
679
680 68/push "F - test-hex-below-0"/imm32
681 68/push 0/imm32/false
682 50/push-eax
683
684 e8/call check-ints-equal/disp32
685
686 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
687 c3/return
688
689 test-hex-0-to-9:
690
691
692 68/push 0x30/imm32
693
694 e8/call is-hex-digit?/disp32
695
696 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
697
698
699 68/push "F - test-hex-at-0"/imm32
700 68/push 1/imm32/true
701 50/push-eax
702
703 e8/call check-ints-equal/disp32
704
705 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
706
707
708 68/push 0x39/imm32
709
710 e8/call is-hex-digit?/disp32
711
712 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
713
714
715 68/push "F - test-hex-at-9"/imm32
716 68/push 1/imm32/true
717 50/push-eax
718
719 e8/call check-ints-equal/disp32
720
721 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
722 c3/return
723
724 test-hex-above-9-to-a:
725
726
727 68/push 0x3a/imm32
728
729 e8/call is-hex-digit?/disp32
730
731 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
732
733
734 68/push "F - test-hex-above-9-to-a"/imm32
735 68/push 0/imm32/false
736 50/push-eax
737
738 e8/call check-ints-equal/disp32
739
740 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
741 c3/return
742
743 test-hex-a-to-f:
744
745
746 68/push 0x61/imm32
747
748 e8/call is-hex-digit?/disp32
749
750 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
751
752
753 68/push "F - test-hex-at-a"/imm32
754 68/push 1/imm32/true
755 50/push-eax
756
757 e8/call check-ints-equal/disp32
758
759 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
760
761
762 68/push 0x66/imm32
763
764 e8/call is-hex-digit?/disp32
765
766 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
767
768
769 68/push "F - test-hex-at-f"/imm32
770 68/push 1/imm32/true
771 50/push-eax
772
773 e8/call check-ints-equal/disp32
774
775 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
776 c3/return
777
778 test-hex-above-f:
779
780
781 68/push 0x67/imm32
782
783 e8/call is-hex-digit?/disp32
784
785 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
786
787
788 68/push "F - test-hex-above-f"/imm32
789 68/push 0/imm32/false
790 50/push-eax
791
792 e8/call check-ints-equal/disp32
793
794 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
795 c3/return
796
797 from-hex-char:
798 $from-hex-char:check0:
799
800 3d/compare-eax-with 0x30/imm32/0
801 7c/jump-if-lesser $from-hex-char:abort/disp8
802 $from-hex-char:check1:
803
804 3d/compare-eax-with 0x66/imm32/f
805 7f/jump-if-greater $from-hex-char:abort/disp8
806 $from-hex-char:check2:
807
808 3d/compare-eax-with 0x39/imm32/9
809 7f/jump-if-greater $from-hex-char:check3/disp8
810 $from-hex-char:digit:
811
812 2d/subtract-from-eax 0x30/imm32/0
813 c3/return
814 $from-hex-char:check3:
815
816 3d/compare-eax-with 0x61/imm32/a
817 7c/jump-if-lesser $from-hex-char:abort/disp8
818 $from-hex-char:letter:
819
820 2d/subtract-from-eax 0x57/imm32/a-10
821 c3/return
822
823 $from-hex-char:abort:
824
825
826 68/push "invalid hex char: "/imm32
827 68/push 2/imm32/stderr
828
829 e8/call _write/disp32
830
831 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
832
833
834 50/push-eax
835
836 68/push Stderr->buffer/imm32
837
838 e8/call clear-stream/disp32
839
840 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
841
842 58/pop-to-eax
843
844
845 50/push-eax
846 68/push Stderr/imm32
847
848 e8/call print-int32-buffered/disp32
849
850 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
851
852
853 68/push Stderr/imm32
854
855 e8/call flush/disp32
856
857 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
858
859
860 68/push Newline/imm32
861 68/push 2/imm32/stderr
862
863 e8/call _write/disp32
864
865 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
866
867 bb/copy-to-ebx 1/imm32
868 b8/copy-to-eax 1/imm32/exit
869 cd/syscall 0x80/imm8
870
871
872