From dadae33848cbaf95b6355789348e0b1d3dff11af Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Fri, 11 Jan 2019 17:44:12 -0800 Subject: 4920 --- html/subx/apps/hex.subx.html | 501 ++++++++++++++----------------------------- 1 file changed, 165 insertions(+), 336 deletions(-) (limited to 'html/subx/apps/hex.subx.html') diff --git a/html/subx/apps/hex.subx.html b/html/subx/apps/hex.subx.html index 01eb2cda..bbd1a036 100644 --- a/html/subx/apps/hex.subx.html +++ b/html/subx/apps/hex.subx.html @@ -219,7 +219,7 @@ if ('onhashchange' in window) { 156 81 7/subop/compare 3/mod/direct 0/rm32/EAX . . . . . 0xffffffff/imm32 # compare EAX 157 74/jump-if-equal $convert-next-octet:end/disp8 158 # EAX = parse-hex-digit(EAX) - 159 e8/call parse-hex-digit/disp32 + 159 e8/call parse-hex-digit/disp32 160 # ECX = EAX 161 89/copy 3/mod/direct 1/rm32/ECX . . . 0/r32/EAX . . # copy EAX to ECX 162 # EAX = scan-next-byte(in, err, ed) @@ -244,7 +244,7 @@ if ('onhashchange' in window) { 181 e8/call error-byte/disp32 # never returns 182 $convert-next-octet:convert: 183 # EAX = parse-hex-digit(EAX) - 184 e8/call parse-hex-digit/disp32 + 184 e8/call parse-hex-digit/disp32 185 # EAX = (ECX << 4) | EAX 186 # . ECX <<= 4 187 c1/shift 4/subop/left 3/mod/direct 1/rm32/ECX . . . . . 4/imm8 # shift ECX left by 4 bits @@ -282,14 +282,14 @@ if ('onhashchange' in window) { 219 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP 220 # . clear-stream(_test-error-stream) 221 # . . push args - 222 68/push _test-error-stream/imm32 + 222 68/push _test-error-stream/imm32 223 # . . call 224 e8/call clear-stream/disp32 225 # . . discard args 226 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP 227 # . clear-stream(_test-error-buffered-file+4) 228 # . . push args - 229 b8/copy-to-EAX _test-error-buffered-file/imm32 + 229 b8/copy-to-EAX _test-error-buffered-file/imm32 230 05/add-to-EAX 4/imm32 231 50/push-EAX 232 # . . call @@ -320,7 +320,7 @@ if ('onhashchange' in window) { 257 # EAX = convert-next-octet(_test-buffered-file, _test-error-buffered-file, ed) 258 # . . push args 259 51/push-ECX/ed - 260 68/push _test-error-buffered-file/imm32 + 260 68/push _test-error-buffered-file/imm32 261 68/push _test-buffered-file/imm32 262 # . . call 263 e8/call convert-next-octet/disp32 @@ -384,14 +384,14 @@ if ('onhashchange' in window) { 321 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP 322 # . clear-stream(_test-error-stream) 323 # . . push args - 324 68/push _test-error-stream/imm32 + 324 68/push _test-error-stream/imm32 325 # . . call 326 e8/call clear-stream/disp32 327 # . . discard args 328 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP 329 # . clear-stream(_test-error-buffered-file+4) 330 # . . push args - 331 b8/copy-to-EAX _test-error-buffered-file/imm32 + 331 b8/copy-to-EAX _test-error-buffered-file/imm32 332 05/add-to-EAX 4/imm32 333 50/push-EAX 334 # . . call @@ -414,7 +414,7 @@ if ('onhashchange' in window) { 351 # EAX = convert-next-octet(_test-buffered-file, _test-error-buffered-file, ed) 352 # . . push args 353 51/push-ECX/ed - 354 68/push _test-error-buffered-file/imm32 + 354 68/push _test-error-buffered-file/imm32 355 68/push _test-buffered-file/imm32 356 # . . call 357 e8/call convert-next-octet/disp32 @@ -478,14 +478,14 @@ if ('onhashchange' in window) { 415 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP 416 # . clear-stream(_test-error-stream) 417 # . . push args - 418 68/push _test-error-stream/imm32 + 418 68/push _test-error-stream/imm32 419 # . . call 420 e8/call clear-stream/disp32 421 # . . discard args 422 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP 423 # . clear-stream(_test-error-buffered-file+4) 424 # . . push args - 425 b8/copy-to-EAX _test-error-buffered-file/imm32 + 425 b8/copy-to-EAX _test-error-buffered-file/imm32 426 05/add-to-EAX 4/imm32 427 50/push-EAX 428 # . . call @@ -516,7 +516,7 @@ if ('onhashchange' in window) { 453 # EAX = convert-next-octet(_test-buffered-file, _test-error-buffered-file, ed) 454 # . . push args 455 51/push-ECX/ed - 456 68/push _test-error-buffered-file/imm32 + 456 68/push _test-error-buffered-file/imm32 457 68/push _test-buffered-file/imm32 458 # . . call 459 e8/call convert-next-octet/disp32 @@ -553,7 +553,7 @@ if ('onhashchange' in window) { 490 # repeatedly 491 # EAX = read-byte(in) 492 # if EAX == 0xffffffff return EAX - 493 # if is-hex-lowercase-byte?(EAX) return EAX + 493 # if is-hex-byte?(EAX) return EAX 494 # if EAX == ' ' or '\t' or '\n' continue 495 # if EAX == '#' skip-until-newline(in) 496 # else error-byte(ed, err, "invalid byte: " EAX) @@ -573,14 +573,14 @@ if ('onhashchange' in window) { 510 # if (EAX == 0xffffffff) return EAX 511 3d/compare-with-EAX 0xffffffff/imm32 512 74/jump-if-equal $scan-next-byte:end/disp8 - 513 # if is-hex-lowercase-byte?(EAX) return EAX + 513 # if is-hex-byte?(EAX) return EAX 514 # . save EAX for now 515 50/push-EAX - 516 # . is-hex-lowercase-byte?(EAX) + 516 # . is-hex-byte?(EAX) 517 # . . push args 518 50/push-EAX 519 # . . call - 520 e8/call is-hex-lowercase-byte?/disp32 + 520 e8/call is-hex-byte?/disp32 521 # . . discard args 522 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP 523 # . compare with 'false' @@ -607,7 +607,7 @@ if ('onhashchange' in window) { 544 # . . push args 545 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 . # push *(EBP+8) 546 # . . call - 547 e8/call skip-until-newline/disp32 + 547 e8/call skip-until-newline/disp32 548 # . . discard args 549 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP 550 eb/jump $scan-next-byte:loop/disp8 @@ -651,14 +651,14 @@ if ('onhashchange' in window) { 588 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP 589 # . clear-stream(_test-error-stream) 590 # . . push args - 591 68/push _test-error-stream/imm32 + 591 68/push _test-error-stream/imm32 592 # . . call 593 e8/call clear-stream/disp32 594 # . . discard args 595 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP 596 # . clear-stream(_test-error-buffered-file+4) 597 # . . push args - 598 b8/copy-to-EAX _test-error-buffered-file/imm32 + 598 b8/copy-to-EAX _test-error-buffered-file/imm32 599 05/add-to-EAX 4/imm32 600 50/push-EAX 601 # . . call @@ -689,7 +689,7 @@ if ('onhashchange' in window) { 626 # EAX = scan-next-byte(_test-buffered-file, _test-error-buffered-file, ed) 627 # . . push args 628 51/push-ECX/ed - 629 68/push _test-error-buffered-file/imm32 + 629 68/push _test-error-buffered-file/imm32 630 68/push _test-buffered-file/imm32 631 # . . call 632 e8/call scan-next-byte/disp32 @@ -753,14 +753,14 @@ if ('onhashchange' in window) { 690 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP 691 # . clear-stream(_test-error-stream) 692 # . . push args - 693 68/push _test-error-stream/imm32 + 693 68/push _test-error-stream/imm32 694 # . . call 695 e8/call clear-stream/disp32 696 # . . discard args 697 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP 698 # . clear-stream(_test-error-buffered-file+4) 699 # . . push args - 700 b8/copy-to-EAX _test-error-buffered-file/imm32 + 700 b8/copy-to-EAX _test-error-buffered-file/imm32 701 05/add-to-EAX 4/imm32 702 50/push-EAX 703 # . . call @@ -791,7 +791,7 @@ if ('onhashchange' in window) { 728 # EAX = scan-next-byte(_test-buffered-file, _test-error-buffered-file, ed) 729 # . . push args 730 51/push-ECX/ed - 731 68/push _test-error-buffered-file/imm32 + 731 68/push _test-error-buffered-file/imm32 732 68/push _test-buffered-file/imm32 733 # . . call 734 e8/call scan-next-byte/disp32 @@ -855,14 +855,14 @@ if ('onhashchange' in window) { 792 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP 793 # . clear-stream(_test-error-stream) 794 # . . push args - 795 68/push _test-error-stream/imm32 + 795 68/push _test-error-stream/imm32 796 # . . call 797 e8/call clear-stream/disp32 798 # . . discard args 799 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP 800 # . clear-stream(_test-error-buffered-file+4) 801 # . . push args - 802 b8/copy-to-EAX _test-error-buffered-file/imm32 + 802 b8/copy-to-EAX _test-error-buffered-file/imm32 803 05/add-to-EAX 4/imm32 804 50/push-EAX 805 # . . call @@ -909,7 +909,7 @@ if ('onhashchange' in window) { 846 # EAX = scan-next-byte(_test-buffered-file, _test-error-buffered-file, ed) 847 # . . push args 848 51/push-ECX/ed - 849 68/push _test-error-buffered-file/imm32 + 849 68/push _test-error-buffered-file/imm32 850 68/push _test-buffered-file/imm32 851 # . . call 852 e8/call scan-next-byte/disp32 @@ -973,14 +973,14 @@ if ('onhashchange' in window) { 910 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP 911 # . clear-stream(_test-error-stream) 912 # . . push args - 913 68/push _test-error-stream/imm32 + 913 68/push _test-error-stream/imm32 914 # . . call 915 e8/call clear-stream/disp32 916 # . . discard args 917 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP 918 # . clear-stream(_test-error-buffered-file+4) 919 # . . push args - 920 b8/copy-to-EAX _test-error-buffered-file/imm32 + 920 b8/copy-to-EAX _test-error-buffered-file/imm32 921 05/add-to-EAX 4/imm32 922 50/push-EAX 923 # . . call @@ -1027,7 +1027,7 @@ if ('onhashchange' in window) { 964 # EAX = scan-next-byte(_test-buffered-file, _test-error-buffered-file, ed) 965 # . . push args 966 51/push-ECX/ed - 967 68/push _test-error-buffered-file/imm32 + 967 68/push _test-error-buffered-file/imm32 968 68/push _test-buffered-file/imm32 969 # . . call 970 e8/call scan-next-byte/disp32 @@ -1091,14 +1091,14 @@ if ('onhashchange' in window) { 1028 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP 1029 # . clear-stream(_test-error-stream) 1030 # . . push args -1031 68/push _test-error-stream/imm32 +1031 68/push _test-error-stream/imm32 1032 # . . call 1033 e8/call clear-stream/disp32 1034 # . . discard args 1035 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP 1036 # . clear-stream(_test-error-buffered-file+4) 1037 # . . push args -1038 b8/copy-to-EAX _test-error-buffered-file/imm32 +1038 b8/copy-to-EAX _test-error-buffered-file/imm32 1039 05/add-to-EAX 4/imm32 1040 50/push-EAX 1041 # . . call @@ -1145,7 +1145,7 @@ if ('onhashchange' in window) { 1082 # EAX = scan-next-byte(_test-buffered-file, _test-error-buffered-file, ed) 1083 # . . push args 1084 51/push-ECX/ed -1085 68/push _test-error-buffered-file/imm32 +1085 68/push _test-error-buffered-file/imm32 1086 68/push _test-buffered-file/imm32 1087 # . . call 1088 e8/call scan-next-byte/disp32 @@ -1209,14 +1209,14 @@ if ('onhashchange' in window) { 1146 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP 1147 # . clear-stream(_test-error-stream) 1148 # . . push args -1149 68/push _test-error-stream/imm32 +1149 68/push _test-error-stream/imm32 1150 # . . call 1151 e8/call clear-stream/disp32 1152 # . . discard args 1153 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP 1154 # . clear-stream(_test-error-buffered-file+4) 1155 # . . push args -1156 b8/copy-to-EAX _test-error-buffered-file/imm32 +1156 b8/copy-to-EAX _test-error-buffered-file/imm32 1157 05/add-to-EAX 4/imm32 1158 50/push-EAX 1159 # . . call @@ -1247,7 +1247,7 @@ if ('onhashchange' in window) { 1184 # EAX = scan-next-byte(_test-buffered-file, _test-error-buffered-file, ed) 1185 # . . push args 1186 51/push-ECX/ed -1187 68/push _test-error-buffered-file/imm32 +1187 68/push _test-error-buffered-file/imm32 1188 68/push _test-buffered-file/imm32 1189 # . . call 1190 e8/call scan-next-byte/disp32 @@ -1311,14 +1311,14 @@ if ('onhashchange' in window) { 1248 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP 1249 # . clear-stream(_test-error-stream) 1250 # . . push args -1251 68/push _test-error-stream/imm32 +1251 68/push _test-error-stream/imm32 1252 # . . call 1253 e8/call clear-stream/disp32 1254 # . . discard args 1255 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP 1256 # . clear-stream(_test-error-buffered-file+4) 1257 # . . push args -1258 b8/copy-to-EAX _test-error-buffered-file/imm32 +1258 b8/copy-to-EAX _test-error-buffered-file/imm32 1259 05/add-to-EAX 4/imm32 1260 50/push-EAX 1261 # . . call @@ -1341,7 +1341,7 @@ if ('onhashchange' in window) { 1278 # EAX = scan-next-byte(_test-buffered-file, _test-error-buffered-file, ed) 1279 # . . push args 1280 51/push-ECX/ed -1281 68/push _test-error-buffered-file/imm32 +1281 68/push _test-error-buffered-file/imm32 1282 68/push _test-buffered-file/imm32 1283 # . . call 1284 e8/call scan-next-byte/disp32 @@ -1405,14 +1405,14 @@ if ('onhashchange' in window) { 1342 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP 1343 # . clear-stream(_test-error-stream) 1344 # . . push args -1345 68/push _test-error-stream/imm32 +1345 68/push _test-error-stream/imm32 1346 # . . call 1347 e8/call clear-stream/disp32 1348 # . . discard args 1349 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP 1350 # . clear-stream(_test-error-buffered-file+4) 1351 # . . push args -1352 b8/copy-to-EAX _test-error-buffered-file/imm32 +1352 b8/copy-to-EAX _test-error-buffered-file/imm32 1353 05/add-to-EAX 4/imm32 1354 50/push-EAX 1355 # . . call @@ -1443,7 +1443,7 @@ if ('onhashchange' in window) { 1380 # EAX = scan-next-byte(_test-buffered-file, _test-error-buffered-file, ed) 1381 # . . push args 1382 51/push-ECX/ed -1383 68/push _test-error-buffered-file/imm32 +1383 68/push _test-error-buffered-file/imm32 1384 68/push _test-buffered-file/imm32 1385 # . . call 1386 e8/call scan-next-byte/disp32 @@ -1471,302 +1471,131 @@ if ('onhashchange' in window) { 1408 5d/pop-to-EBP 1409 c3/return 1410 -1411 is-hex-lowercase-byte?: # c : byte -> bool/EAX -1412 # . prolog -1413 55/push-EBP -1414 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP -1415 # . save registers -1416 51/push-ECX -1417 # ECX = c -1418 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 1/r32/ECX 8/disp8 . # copy *(EBP+8) to ECX -1419 # return false if c < '0' -1420 b8/copy-to-EAX 0/imm32/false -1421 81 7/subop/compare 3/mod/direct 1/rm32/ECX . . . . . 0x30/imm32 # compare ECX -1422 7c/jump-if-lesser $is-hex-lowercase-byte?:end/disp8 -1423 # return false if c > 'f' -1424 81 7/subop/compare 3/mod/direct 1/rm32/ECX . . . . . 0x66/imm32 # compare ECX -1425 7f/jump-if-greater $is-hex-lowercase-byte?:end/disp8 -1426 # return true if c <= '9' -1427 b8/copy-to-EAX 1/imm32/true -1428 81 7/subop/compare 3/mod/direct 1/rm32/ECX . . . . . 0x39/imm32 # compare ECX -1429 7e/jump-if-lesser-or-equal $is-hex-lowercase-byte?:end/disp8 -1430 # return true if c >= 'a' -1431 81 7/subop/compare 3/mod/direct 1/rm32/ECX . . . . . 0x61/imm32 # compare ECX -1432 7d/jump-if-greater-or-equal $is-hex-lowercase-byte?:end/disp8 -1433 # otherwise return false -1434 b8/copy-to-EAX 0/imm32/false -1435 $is-hex-lowercase-byte?:end: -1436 # . restore registers -1437 59/pop-to-ECX -1438 # . epilog -1439 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . . # copy EBP to ESP -1440 5d/pop-to-EBP -1441 c3/return -1442 -1443 test-hex-below-0: -1444 # is-hex-lowercase-byte?(0x2f) -1445 # . . push args -1446 68/push 0x2f/imm32 -1447 # . . call -1448 e8/call is-hex-lowercase-byte?/disp32 -1449 # . . discard args -1450 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP -1451 # check-ints-equal(EAX, 0, msg) -1452 # . . push args -1453 68/push "F - test-hex-below-0"/imm32 -1454 68/push 0/imm32/false -1455 50/push-EAX -1456 # . . call -1457 e8/call check-ints-equal/disp32 -1458 # . . discard args -1459 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP -1460 c3/return -1461 -1462 test-hex-0-to-9: -1463 # is-hex-lowercase-byte?(0x30) -1464 # . . push args -1465 68/push 0x30/imm32 -1466 # . . call -1467 e8/call is-hex-lowercase-byte?/disp32 -1468 # . . discard args -1469 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP -1470 # check-ints-equal(EAX, 1, msg) -1471 # . . push args -1472 68/push "F - test-hex-at-0"/imm32 -1473 68/push 1/imm32/true -1474 50/push-EAX -1475 # . . call -1476 e8/call check-ints-equal/disp32 -1477 # . . discard args -1478 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP -1479 # is-hex-lowercase-byte?(0x39) -1480 # . . push args -1481 68/push 0x39/imm32 -1482 # . . call -1483 e8/call is-hex-lowercase-byte?/disp32 -1484 # . . discard args -1485 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP -1486 # check-ints-equal(EAX, 1, msg) -1487 # . . push args -1488 68/push "F - test-hex-at-9"/imm32 -1489 68/push 1/imm32/true -1490 50/push-EAX -1491 # . . call -1492 e8/call check-ints-equal/disp32 -1493 # . . discard args -1494 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP -1495 c3/return -1496 -1497 test-hex-above-9-to-a: -1498 # is-hex-lowercase-byte?(0x3a) -1499 # . . push args -1500 68/push 0x3a/imm32 -1501 # . . call -1502 e8/call is-hex-lowercase-byte?/disp32 -1503 # . . discard args -1504 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP -1505 # check-ints-equal(EAX, 0, msg) -1506 # . . push args -1507 68/push "F - test-hex-above-9-to-a"/imm32 -1508 68/push 0/imm32/false -1509 50/push-EAX -1510 # . . call -1511 e8/call check-ints-equal/disp32 -1512 # . . discard args -1513 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP -1514 c3/return -1515 -1516 test-hex-a-to-f: -1517 # is-hex-lowercase-byte?(0x61) -1518 # . . push args -1519 68/push 0x61/imm32 -1520 # . . call -1521 e8/call is-hex-lowercase-byte?/disp32 -1522 # . . discard args -1523 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP -1524 # check-ints-equal(EAX, 1, msg) -1525 # . . push args -1526 68/push "F - test-hex-at-a"/imm32 -1527 68/push 1/imm32/true -1528 50/push-EAX -1529 # . . call -1530 e8/call check-ints-equal/disp32 -1531 # . . discard args -1532 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP -1533 # is-hex-lowercase-byte?(0x66) -1534 # . . push args -1535 68/push 0x66/imm32 -1536 # . . call -1537 e8/call is-hex-lowercase-byte?/disp32 -1538 # . . discard args -1539 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP -1540 # check-ints-equal(EAX, 1, msg) -1541 # . . push args -1542 68/push "F - test-hex-at-f"/imm32 -1543 68/push 1/imm32/true -1544 50/push-EAX -1545 # . . call -1546 e8/call check-ints-equal/disp32 -1547 # . . discard args -1548 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP -1549 c3/return -1550 -1551 test-hex-above-f: -1552 # is-hex-lowercase-byte?(0x67) -1553 # . . push args -1554 68/push 0x67/imm32 -1555 # . . call -1556 e8/call is-hex-lowercase-byte?/disp32 -1557 # . . discard args -1558 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP -1559 # check-ints-equal(EAX, 0, msg) -1560 # . . push args -1561 68/push "F - test-hex-above-f"/imm32 -1562 68/push 0/imm32/false -1563 50/push-EAX -1564 # . . call -1565 e8/call check-ints-equal/disp32 -1566 # . . discard args -1567 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP -1568 c3/return -1569 -1570 parse-hex-digit: # in/EAX : byte -> out/EAX : num -1571 # no error checking; accepts argument in EAX -1572 # if EAX <= '9' return EAX - '0' -1573 3d/compare-EAX 0x39/imm32/9 -1574 7f/jump-if-greater $parse-hex-digit:else/disp8 -1575 2d/subtract-from-EAX 0x30/imm32/0 -1576 c3/return -1577 $parse-hex-digit:else: -1578 # otherwise return EAX - 'a' + 10 -1579 2d/subtract-from-EAX 0x57/imm32/a-10 -1580 c3/return -1581 -1582 skip-until-newline: # in : (address buffered-file) -> <void> -1583 # pseudocode: -1584 # push EAX -1585 # repeatedly: -1586 # EAX = read-byte(in) -1587 # if EAX == 0xffffffff break -1588 # if EAX == 0x0a break -1589 # pop EAX -1590 # . prolog -1591 55/push-EBP -1592 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP -1593 # . save registers -1594 50/push-EAX -1595 $skip-until-newline:loop: -1596 # . EAX = read-byte(in) -1597 # . . push args -1598 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 . # push *(EBP+8) -1599 # . . call -1600 e8/call read-byte/disp32 -1601 # . . discard args -1602 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP -1603 # . if EAX == 0xffffffff break -1604 81 7/subop/compare 3/mod/direct 0/rm32/EAX . . . . . 0xffffffff/imm32 # compare EAX -1605 74/jump-if-equal $skip-until-newline:end/disp8 -1606 # . if EAX != 0xa/newline loop -1607 81 7/subop/compare 3/mod/direct 0/rm32/EAX . . . . . 0xa/imm32 # compare EAX -1608 75/jump-if-not-equal $skip-until-newline:loop/disp8 -1609 $skip-until-newline:end: -1610 # . restore registers -1611 58/pop-to-EAX -1612 # . epilog -1613 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . . # copy EBP to ESP -1614 5d/pop-to-EBP -1615 c3/return -1616 -1617 test-skip-until-newline: -1618 # - check that the read pointer points after the newline -1619 # setup -1620 # . clear-stream(_test-stream) -1621 # . . push args -1622 68/push _test-stream/imm32 -1623 # . . call -1624 e8/call clear-stream/disp32 -1625 # . . discard args -1626 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP -1627 # . clear-stream(_test-buffered-file+4) -1628 # . . push args -1629 b8/copy-to-EAX _test-buffered-file/imm32 -1630 05/add-to-EAX 4/imm32 -1631 50/push-EAX -1632 # . . call -1633 e8/call clear-stream/disp32 -1634 # . . discard args -1635 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP -1636 # initialize '_test-stream' to "abc\nde" -1637 # . write(_test-stream, "abc") -1638 # . . push args -1639 68/push "abc"/imm32 -1640 68/push _test-stream/imm32 -1641 # . . call -1642 e8/call write/disp32 -1643 # . . discard args -1644 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP -1645 # . write(_test-stream, Newline) -1646 # . . push args -1647 68/push Newline/imm32 -1648 68/push _test-stream/imm32 -1649 # . . call -1650 e8/call write/disp32 -1651 # . . discard args -1652 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP -1653 # . write(_test-stream, "de") -1654 # . . push args -1655 68/push "de"/imm32 -1656 68/push _test-stream/imm32 -1657 # . . call -1658 e8/call write/disp32 -1659 # . . discard args -1660 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP -1661 # skip-until-newline(_test-buffered-file) -1662 # . . push args -1663 68/push _test-buffered-file/imm32 -1664 # . . call -1665 e8/call skip-until-newline/disp32 -1666 # . . discard args -1667 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP -1668 # check-ints-equal(_test-buffered-file->read, 4, msg) -1669 # . . push args -1670 68/push "F - test-skip-until-newline"/imm32 -1671 68/push 4/imm32 -1672 b8/copy-to-EAX _test-buffered-file/imm32 -1673 ff 6/subop/push 1/mod/*+disp8 0/rm32/EAX . . . . 8/disp8 . # push *(EAX+8) -1674 # . . call -1675 e8/call check-ints-equal/disp32 -1676 # . . discard args -1677 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP -1678 # . end -1679 c3/return -1680 -1681 == data -1682 -1683 _test-error-stream: -1684 # current write index -1685 00 00 00 00 -1686 # current read index -1687 00 00 00 00 -1688 # length (= 8) -1689 08 00 00 00 -1690 # data -1691 00 00 00 00 00 00 00 00 # 8 bytes -1692 -1693 # a test buffered file for _test-stream -1694 _test-error-buffered-file: -1695 # file descriptor or (address stream) -1696 _test-error-stream/imm32 -1697 # current write index -1698 00 00 00 00 -1699 # current read index -1700 00 00 00 00 -1701 # length (6) -1702 06 00 00 00 -1703 # data -1704 00 00 00 00 00 00 # 6 bytes -1705 -1706 # . . vim:nowrap:textwidth=0 +1411 skip-until-newline: # in : (address buffered-file) -> <void> +1412 # pseudocode: +1413 # push EAX +1414 # repeatedly: +1415 # EAX = read-byte(in) +1416 # if EAX == 0xffffffff break +1417 # if EAX == 0x0a break +1418 # pop EAX +1419 # . prolog +1420 55/push-EBP +1421 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP +1422 # . save registers +1423 50/push-EAX +1424 $skip-until-newline:loop: +1425 # . EAX = read-byte(in) +1426 # . . push args +1427 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 . # push *(EBP+8) +1428 # . . call +1429 e8/call read-byte/disp32 +1430 # . . discard args +1431 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP +1432 # . if EAX == 0xffffffff break +1433 81 7/subop/compare 3/mod/direct 0/rm32/EAX . . . . . 0xffffffff/imm32 # compare EAX +1434 74/jump-if-equal $skip-until-newline:end/disp8 +1435 # . if EAX != 0xa/newline loop +1436 81 7/subop/compare 3/mod/direct 0/rm32/EAX . . . . . 0xa/imm32 # compare EAX +1437 75/jump-if-not-equal $skip-until-newline:loop/disp8 +1438 $skip-until-newline:end: +1439 # . restore registers +1440 58/pop-to-EAX +1441 # . epilog +1442 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . . # copy EBP to ESP +1443 5d/pop-to-EBP +1444 c3/return +1445 +1446 test-skip-until-newline: +1447 # - check that the read pointer points after the newline +1448 # setup +1449 # . clear-stream(_test-stream) +1450 # . . push args +1451 68/push _test-stream/imm32 +1452 # . . call +1453 e8/call clear-stream/disp32 +1454 # . . discard args +1455 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP +1456 # . clear-stream(_test-buffered-file+4) +1457 # . . push args +1458 b8/copy-to-EAX _test-buffered-file/imm32 +1459 05/add-to-EAX 4/imm32 +1460 50/push-EAX +1461 # . . call +1462 e8/call clear-stream/disp32 +1463 # . . discard args +1464 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP +1465 # initialize '_test-stream' to "abc\nde" +1466 # . write(_test-stream, "abc") +1467 # . . push args +1468 68/push "abc"/imm32 +1469 68/push _test-stream/imm32 +1470 # . . call +1471 e8/call write/disp32 +1472 # . . discard args +1473 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP +1474 # . write(_test-stream, Newline) +1475 # . . push args +1476 68/push Newline/imm32 +1477 68/push _test-stream/imm32 +1478 # . . call +1479 e8/call write/disp32 +1480 # . . discard args +1481 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP +1482 # . write(_test-stream, "de") +1483 # . . push args +1484 68/push "de"/imm32 +1485 68/push _test-stream/imm32 +1486 # . . call +1487 e8/call write/disp32 +1488 # . . discard args +1489 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP +1490 # skip-until-newline(_test-buffered-file) +1491 # . . push args +1492 68/push _test-buffered-file/imm32 +1493 # . . call +1494 e8/call skip-until-newline/disp32 +1495 # . . discard args +1496 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP +1497 # check-ints-equal(_test-buffered-file->read, 4, msg) +1498 # . . push args +1499 68/push "F - test-skip-until-newline"/imm32 +1500 68/push 4/imm32 +1501 b8/copy-to-EAX _test-buffered-file/imm32 +1502 ff 6/subop/push 1/mod/*+disp8 0/rm32/EAX . . . . 8/disp8 . # push *(EAX+8) +1503 # . . call +1504 e8/call check-ints-equal/disp32 +1505 # . . discard args +1506 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP +1507 # . end +1508 c3/return +1509 +1510 == data +1511 +1512 _test-error-stream: +1513 # current write index +1514 00 00 00 00 +1515 # current read index +1516 00 00 00 00 +1517 # length (= 8) +1518 08 00 00 00 +1519 # data +1520 00 00 00 00 00 00 00 00 # 8 bytes +1521 +1522 # a test buffered file for _test-stream +1523 _test-error-buffered-file: +1524 # file descriptor or (address stream) +1525 _test-error-stream/imm32 +1526 # current write index +1527 00 00 00 00 +1528 # current read index +1529 00 00 00 00 +1530 # length (6) +1531 06 00 00 00 +1532 # data +1533 00 00 00 00 00 00 # 6 bytes +1534 +1535 # . . vim:nowrap:textwidth=0 -- cgit 1.4.1-2-gfad0