From a966881b6ef57de52cbf3001ed71bb66f0c77c2a Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Thu, 6 Dec 2018 10:50:26 -0800 Subject: 4848 --- html/subx/apps/hex.subx.html | 1807 +++++++++++++++++++++--------------------- 1 file changed, 903 insertions(+), 904 deletions(-) (limited to 'html/subx/apps') diff --git a/html/subx/apps/hex.subx.html b/html/subx/apps/hex.subx.html index 7de27c37..b5bd7458 100644 --- a/html/subx/apps/hex.subx.html +++ b/html/subx/apps/hex.subx.html @@ -241,910 +241,909 @@ if ('onhashchange' in window) { 175 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP 176 eb/jump $scan-next-byte:loop/disp8 177 $scan-next-byte:check3: - 178 # TODO: error-byte takes a buffered-file, not a (fd or (address stream)) - 179 # otherwise error-byte(ed, err, msg, EAX) - 180 # . . push args - 181 50/push-EAX - 182 68/push "scan-next-byte: invalid byte"/imm32 - 183 ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0xc/disp8 . # push *(EBP+12) - 184 ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0x10/disp8 . # push *(EBP+16) - 185 # . . call - 186 e8/call error-byte/disp32 # never returns - 187 $scan-next-byte:end: - 188 # . restore registers - 189 # . epilog - 190 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . . # copy EBP to ESP - 191 5d/pop-to-EBP - 192 c3/return - 193 - 194 test-scan-next-byte: - 195 # - check that the first two bytes of the input are assembled into the resulting number - 196 # This test uses exit-descriptors. Use EBP for setting up local variables. - 197 55/push-EBP - 198 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP - 199 # clear all streams - 200 # . clear-stream(_test-stream) - 201 # . . push args - 202 68/push _test-stream/imm32 - 203 # . . call - 204 e8/call clear-stream/disp32 - 205 # . . discard args - 206 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP - 207 # . clear-stream(_test-buffered-file+4) - 208 # . . push args - 209 b8/copy-to-EAX _test-buffered-file/imm32 - 210 05/add-to-EAX 4/imm32 - 211 50/push-EAX - 212 # . . call - 213 e8/call clear-stream/disp32 - 214 # . . discard args - 215 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP - 216 # . clear-stream(_test-error-stream) - 217 # . . push args - 218 68/push _test-error-stream/imm32 - 219 # . . call - 220 e8/call clear-stream/disp32 - 221 # . . discard args - 222 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP - 223 # initialize '_test-stream' to "abc" - 224 # . write(_test-stream, "abc") - 225 # . . push args - 226 68/push "abc"/imm32 - 227 68/push _test-stream/imm32 - 228 # . . call - 229 e8/call write/disp32 - 230 # . . discard args - 231 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - 232 # initialize exit-descriptor 'ed' for the call to 'scan-next-byte' below - 233 # . var ed/ECX : exit-descriptor - 234 81 5/subop/subtract 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # subtract from ESP - 235 8d/copy-address 0/mod/indirect 4/rm32/sib 4/base/ESP 4/index/none . 1/r32/ECX . . # copy ESP to ECX - 236 # . tailor-exit-descriptor(ed, 12) - 237 # . . push args - 238 68/push 0xc/imm32/nbytes-of-args-for-scan-next-byte - 239 51/push-ECX/ed - 240 # . . call - 241 e8/call tailor-exit-descriptor/disp32 - 242 # . . discard args - 243 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - 244 # EAX = scan-next-byte(_test-buffered-file, _test-error-stream, ed) - 245 # . . push args - 246 51/push-ECX/ed - 247 68/push _test-error-stream/imm32 - 248 68/push _test-buffered-file/imm32 - 249 # . . call - 250 e8/call scan-next-byte/disp32 - 251 # registers except ESP may be clobbered at this point - 252 # pop args to scan-next-bytes - 253 # . . discard first 2 args - 254 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - 255 # . . restore ed - 256 59/pop-to-ECX - 257 # check that scan-next-byte didn't abort - 258 # . check-ints-equal(ed->value, 0, msg) - 259 # . . push args - 260 68/push "F - test-scan-next-byte: unexpected abort"/imm32 - 261 68/push 0/imm32 - 262 # . . push ed->value - 263 ff 6/subop/push 1/mod/*+disp8 1/rm32/ECX . . . . 4/disp8 . # push *(ECX+4) - 264 # . . call - 265 e8/call check-ints-equal/disp32 - 266 # . . discard args - 267 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP - 268 # return if abort - 269 81 7/subop/compare 1/mod/*+disp8 1/rm32/ECX . . . . 4/disp8 0/imm32 # compare *(ECX+4) - 270 75/jump-if-not-equal $test-scan-next-byte:end/disp8 - 271 # check-ints-equal(EAX, 0x61/a, msg) - 272 # . . push args - 273 68/push "F - test-scan-next-byte"/imm32 - 274 68/push 0x61/imm32/a - 275 50/push-EAX - 276 # . . call - 277 e8/call check-ints-equal/disp32 - 278 # . . discard args - 279 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP - 280 $test-scan-next-byte:end: - 281 # . epilog - 282 # don't restore ESP from EBP; manually reclaim locals - 283 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - 284 5d/pop-to-EBP - 285 c3/return - 286 - 287 test-scan-next-byte-skips-whitespace: - 288 # - check that the first two bytes of the input are assembled into the resulting number - 289 # This test uses exit-descriptors. Use EBP for setting up local variables. - 290 55/push-EBP - 291 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP - 292 # clear all streams - 293 # . clear-stream(_test-stream) - 294 # . . push args - 295 68/push _test-stream/imm32 - 296 # . . call - 297 e8/call clear-stream/disp32 - 298 # . . discard args - 299 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP - 300 # . clear-stream(_test-buffered-file+4) - 301 # . . push args - 302 b8/copy-to-EAX _test-buffered-file/imm32 - 303 05/add-to-EAX 4/imm32 - 304 50/push-EAX - 305 # . . call - 306 e8/call clear-stream/disp32 - 307 # . . discard args - 308 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP - 309 # . clear-stream(_test-error-stream) - 310 # . . push args - 311 68/push _test-error-stream/imm32 - 312 # . . call - 313 e8/call clear-stream/disp32 - 314 # . . discard args - 315 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP - 316 # initialize '_test-stream' to input with leading whitespace - 317 # . write(_test-stream, text) - 318 # . . push args - 319 68/push " abc"/imm32 - 320 68/push _test-stream/imm32 - 321 # . . call - 322 e8/call write/disp32 - 323 # . . discard args - 324 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - 325 # initialize exit-descriptor 'ed' for the call to 'scan-next-byte' below - 326 # . var ed/ECX : exit-descriptor - 327 81 5/subop/subtract 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # subtract from ESP - 328 8d/copy-address 0/mod/indirect 4/rm32/sib 4/base/ESP 4/index/none . 1/r32/ECX . . # copy ESP to ECX - 329 # . tailor-exit-descriptor(ed, 12) - 330 # . . push args - 331 68/push 0xc/imm32/nbytes-of-args-for-scan-next-byte - 332 51/push-ECX/ed - 333 # . . call - 334 e8/call tailor-exit-descriptor/disp32 - 335 # . . discard args - 336 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - 337 # EAX = scan-next-byte(_test-buffered-file, _test-error-stream, ed) - 338 # . . push args - 339 51/push-ECX/ed - 340 68/push _test-error-stream/imm32 - 341 68/push _test-buffered-file/imm32 - 342 # . . call - 343 e8/call scan-next-byte/disp32 - 344 # registers except ESP may be clobbered at this point - 345 # pop args to scan-next-bytes - 346 # . . discard first 2 args - 347 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - 348 # . . restore ed - 349 59/pop-to-ECX - 350 # check that scan-next-byte didn't abort - 351 # . check-ints-equal(ed->value, 0, msg) - 352 # . . push args - 353 68/push "F - test-scan-next-byte-skips-whitespace: unexpected abort"/imm32 - 354 68/push 0/imm32 - 355 # . . push ed->value - 356 ff 6/subop/push 1/mod/*+disp8 1/rm32/ECX . . . . 4/disp8 . # push *(ECX+4) - 357 # . . call - 358 e8/call check-ints-equal/disp32 - 359 # . . discard args - 360 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP - 361 # return if abort - 362 81 7/subop/compare 1/mod/*+disp8 1/rm32/ECX . . . . 4/disp8 0/imm32 # compare *(ECX+4) - 363 75/jump-if-not-equal $test-scan-next-byte-skips-whitespace:end/disp8 - 364 # check-ints-equal(EAX, 0x61/a, msg) - 365 # . . push args - 366 68/push "F - test-scan-next-byte-skips-whitespace"/imm32 - 367 68/push 0x61/imm32/a - 368 50/push-EAX - 369 # . . call - 370 e8/call check-ints-equal/disp32 - 371 # . . discard args - 372 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP - 373 $test-scan-next-byte-skips-whitespace:end: - 374 # . epilog - 375 # don't restore ESP from EBP; manually reclaim locals - 376 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - 377 5d/pop-to-EBP - 378 c3/return - 379 - 380 test-scan-next-byte-skips-comment: - 381 # - check that the first two bytes of the input are assembled into the resulting number - 382 # This test uses exit-descriptors. Use EBP for setting up local variables. - 383 55/push-EBP - 384 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP - 385 # clear all streams - 386 # . clear-stream(_test-stream) - 387 # . . push args - 388 68/push _test-stream/imm32 - 389 # . . call - 390 e8/call clear-stream/disp32 - 391 # . . discard args - 392 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP - 393 # . clear-stream(_test-buffered-file+4) - 394 # . . push args - 395 b8/copy-to-EAX _test-buffered-file/imm32 - 396 05/add-to-EAX 4/imm32 - 397 50/push-EAX - 398 # . . call - 399 e8/call clear-stream/disp32 - 400 # . . discard args - 401 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP - 402 # . clear-stream(_test-error-stream) - 403 # . . push args - 404 68/push _test-error-stream/imm32 - 405 # . . call - 406 e8/call clear-stream/disp32 - 407 # . . discard args - 408 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP - 409 # initialize '_test-stream' to input with leading comment - 410 # . write(_test-stream, comment) - 411 # . . push args - 412 68/push "#x"/imm32 - 413 68/push _test-stream/imm32 - 414 # . . call - 415 e8/call write/disp32 - 416 # . . discard args - 417 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - 418 # . write(_test-stream, Newline) - 419 # . . push args - 420 68/push Newline/imm32 - 421 68/push _test-stream/imm32 - 422 # . . call - 423 e8/call write/disp32 - 424 # . . discard args - 425 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - 426 # . write(_test-stream, real text) - 427 # . . push args - 428 68/push "ab"/imm32 - 429 68/push _test-stream/imm32 - 430 # . . call - 431 e8/call write/disp32 - 432 # . . discard args - 433 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - 434 # initialize exit-descriptor 'ed' for the call to 'scan-next-byte' below - 435 # . var ed/ECX : exit-descriptor - 436 81 5/subop/subtract 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # subtract from ESP - 437 8d/copy-address 0/mod/indirect 4/rm32/sib 4/base/ESP 4/index/none . 1/r32/ECX . . # copy ESP to ECX - 438 # . tailor-exit-descriptor(ed, 12) - 439 # . . push args - 440 68/push 0xc/imm32/nbytes-of-args-for-scan-next-byte - 441 51/push-ECX/ed - 442 # . . call - 443 e8/call tailor-exit-descriptor/disp32 - 444 # . . discard args - 445 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - 446 # EAX = scan-next-byte(_test-buffered-file, _test-error-stream, ed) - 447 # . . push args - 448 51/push-ECX/ed - 449 68/push _test-error-stream/imm32 - 450 68/push _test-buffered-file/imm32 - 451 # . . call - 452 e8/call scan-next-byte/disp32 - 453 # registers except ESP may be clobbered at this point - 454 # pop args to scan-next-bytes - 455 # . . discard first 2 args - 456 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - 457 # . . restore ed - 458 59/pop-to-ECX - 459 # check that scan-next-byte didn't abort - 460 # . check-ints-equal(ed->value, 0, msg) - 461 # . . push args - 462 68/push "F - test-scan-next-byte-skips-comment: unexpected abort"/imm32 - 463 68/push 0/imm32 - 464 # . . push ed->value - 465 ff 6/subop/push 1/mod/*+disp8 1/rm32/ECX . . . . 4/disp8 . # push *(ECX+4) - 466 # . . call - 467 e8/call check-ints-equal/disp32 - 468 # . . discard args - 469 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP - 470 # return if abort - 471 81 7/subop/compare 1/mod/*+disp8 1/rm32/ECX . . . . 4/disp8 0/imm32 # compare *(ECX+4) - 472 75/jump-if-not-equal $test-scan-next-byte-skips-comment:end/disp8 - 473 # check-ints-equal(EAX, 0x61/a, msg) - 474 # . . push args - 475 68/push "F - test-scan-next-byte-skips-comment"/imm32 - 476 68/push 0x61/imm32/a - 477 50/push-EAX - 478 # . . call - 479 e8/call check-ints-equal/disp32 - 480 # . . discard args - 481 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP - 482 $test-scan-next-byte-skips-comment:end: - 483 # . epilog - 484 # don't restore ESP from EBP; manually reclaim locals - 485 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - 486 5d/pop-to-EBP - 487 c3/return - 488 - 489 test-scan-next-byte-skips-comment-and-whitespace: - 490 # - check that the first two bytes of the input are assembled into the resulting number - 491 # This test uses exit-descriptors. Use EBP for setting up local variables. - 492 55/push-EBP - 493 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP - 494 # clear all streams - 495 # . clear-stream(_test-stream) - 496 # . . push args - 497 68/push _test-stream/imm32 - 498 # . . call - 499 e8/call clear-stream/disp32 - 500 # . . discard args - 501 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP - 502 # . clear-stream(_test-buffered-file+4) - 503 # . . push args - 504 b8/copy-to-EAX _test-buffered-file/imm32 - 505 05/add-to-EAX 4/imm32 - 506 50/push-EAX - 507 # . . call - 508 e8/call clear-stream/disp32 - 509 # . . discard args - 510 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP - 511 # . clear-stream(_test-error-stream) - 512 # . . push args - 513 68/push _test-error-stream/imm32 - 514 # . . call - 515 e8/call clear-stream/disp32 - 516 # . . discard args - 517 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP - 518 # initialize '_test-stream' to input with leading comment and more whitespace after newline - 519 # . write(_test-stream, comment) - 520 # . . push args - 521 68/push "#x"/imm32 - 522 68/push _test-stream/imm32 - 523 # . . call - 524 e8/call write/disp32 - 525 # . . discard args - 526 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - 527 # . write(_test-stream, Newline) - 528 # . . push args - 529 68/push Newline/imm32 - 530 68/push _test-stream/imm32 - 531 # . . call - 532 e8/call write/disp32 - 533 # . . discard args - 534 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - 535 # . write(_test-stream, real text) - 536 # . . push args - 537 68/push " ab"/imm32 - 538 68/push _test-stream/imm32 - 539 # . . call - 540 e8/call write/disp32 - 541 # . . discard args - 542 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - 543 # initialize exit-descriptor 'ed' for the call to 'scan-next-byte' below - 544 # . var ed/ECX : exit-descriptor - 545 81 5/subop/subtract 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # subtract from ESP - 546 8d/copy-address 0/mod/indirect 4/rm32/sib 4/base/ESP 4/index/none . 1/r32/ECX . . # copy ESP to ECX - 547 # . tailor-exit-descriptor(ed, 12) - 548 # . . push args - 549 68/push 0xc/imm32/nbytes-of-args-for-scan-next-byte - 550 51/push-ECX/ed - 551 # . . call - 552 e8/call tailor-exit-descriptor/disp32 - 553 # . . discard args - 554 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - 555 # EAX = scan-next-byte(_test-buffered-file, _test-error-stream, ed) - 556 # . . push args - 557 51/push-ECX/ed - 558 68/push _test-error-stream/imm32 - 559 68/push _test-buffered-file/imm32 - 560 # . . call - 561 e8/call scan-next-byte/disp32 - 562 # registers except ESP may be clobbered at this point - 563 # pop args to scan-next-bytes - 564 # . . discard first 2 args - 565 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - 566 # . . restore ed - 567 59/pop-to-ECX - 568 # check that scan-next-byte didn't abort - 569 # . check-ints-equal(ed->value, 0, msg) - 570 # . . push args - 571 68/push "F - test-scan-next-byte-skips-comment-and-whitespace: unexpected abort"/imm32 - 572 68/push 0/imm32 - 573 # . . push ed->value - 574 ff 6/subop/push 1/mod/*+disp8 1/rm32/ECX . . . . 4/disp8 . # push *(ECX+4) - 575 # . . call - 576 e8/call check-ints-equal/disp32 - 577 # . . discard args - 578 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP - 579 # return if abort - 580 81 7/subop/compare 1/mod/*+disp8 1/rm32/ECX . . . . 4/disp8 0/imm32 # compare *(ECX+4) - 581 75/jump-if-not-equal $test-scan-next-byte-skips-comment-and-whitespace:end/disp8 - 582 # check-ints-equal(EAX, 0x61/a, msg) - 583 # . . push args - 584 68/push "F - test-scan-next-byte-skips-comment-and-whitespace"/imm32 - 585 68/push 0x61/imm32/a - 586 50/push-EAX - 587 # . . call - 588 e8/call check-ints-equal/disp32 - 589 # . . discard args - 590 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP - 591 $test-scan-next-byte-skips-comment-and-whitespace:end: - 592 # . epilog - 593 # don't restore ESP from EBP; manually reclaim locals - 594 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - 595 5d/pop-to-EBP - 596 c3/return - 597 - 598 test-scan-next-byte-skips-whitespace-and-comment: - 599 # - check that the first two bytes of the input are assembled into the resulting number - 600 # This test uses exit-descriptors. Use EBP for setting up local variables. - 601 55/push-EBP - 602 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP - 603 # clear all streams - 604 # . clear-stream(_test-stream) - 605 # . . push args - 606 68/push _test-stream/imm32 - 607 # . . call - 608 e8/call clear-stream/disp32 - 609 # . . discard args - 610 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP - 611 # . clear-stream(_test-buffered-file+4) - 612 # . . push args - 613 b8/copy-to-EAX _test-buffered-file/imm32 - 614 05/add-to-EAX 4/imm32 - 615 50/push-EAX - 616 # . . call - 617 e8/call clear-stream/disp32 - 618 # . . discard args - 619 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP - 620 # . clear-stream(_test-error-stream) - 621 # . . push args - 622 68/push _test-error-stream/imm32 - 623 # . . call - 624 e8/call clear-stream/disp32 - 625 # . . discard args - 626 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP - 627 # initialize '_test-stream' to input with leading whitespace and comment - 628 # . write(_test-stream, comment) - 629 # . . push args - 630 68/push " #x"/imm32 - 631 68/push _test-stream/imm32 - 632 # . . call - 633 e8/call write/disp32 - 634 # . . discard args - 635 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - 636 # . write(_test-stream, Newline) - 637 # . . push args - 638 68/push Newline/imm32 - 639 68/push _test-stream/imm32 - 640 # . . call - 641 e8/call write/disp32 - 642 # . . discard args - 643 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - 644 # . write(_test-stream, real text) - 645 # . . push args - 646 68/push "ab"/imm32 - 647 68/push _test-stream/imm32 - 648 # . . call - 649 e8/call write/disp32 - 650 # . . discard args - 651 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - 652 # initialize exit-descriptor 'ed' for the call to 'scan-next-byte' below - 653 # . var ed/ECX : exit-descriptor - 654 81 5/subop/subtract 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # subtract from ESP - 655 8d/copy-address 0/mod/indirect 4/rm32/sib 4/base/ESP 4/index/none . 1/r32/ECX . . # copy ESP to ECX - 656 # . tailor-exit-descriptor(ed, 12) - 657 # . . push args - 658 68/push 0xc/imm32/nbytes-of-args-for-scan-next-byte - 659 51/push-ECX/ed - 660 # . . call - 661 e8/call tailor-exit-descriptor/disp32 - 662 # . . discard args - 663 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - 664 # EAX = scan-next-byte(_test-buffered-file, _test-error-stream, ed) - 665 # . . push args - 666 51/push-ECX/ed - 667 68/push _test-error-stream/imm32 - 668 68/push _test-buffered-file/imm32 - 669 # . . call - 670 e8/call scan-next-byte/disp32 - 671 # registers except ESP may be clobbered at this point - 672 # pop args to scan-next-bytes - 673 # . . discard first 2 args - 674 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - 675 # . . restore ed - 676 59/pop-to-ECX - 677 # check that scan-next-byte didn't abort - 678 # . check-ints-equal(ed->value, 0, msg) - 679 # . . push args - 680 68/push "F - test-scan-next-byte-skips-whitespace-and-comment: unexpected abort"/imm32 - 681 68/push 0/imm32 - 682 # . . push ed->value - 683 ff 6/subop/push 1/mod/*+disp8 1/rm32/ECX . . . . 4/disp8 . # push *(ECX+4) - 684 # . . call - 685 e8/call check-ints-equal/disp32 - 686 # . . discard args - 687 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP - 688 # return if abort - 689 81 7/subop/compare 1/mod/*+disp8 1/rm32/ECX . . . . 4/disp8 0/imm32 # compare *(ECX+4) - 690 75/jump-if-not-equal $test-scan-next-byte-skips-whitespace-and-comment:end/disp8 - 691 # check-ints-equal(EAX, 0x61/a, msg) - 692 # . . push args - 693 68/push "F - test-scan-next-byte-skips-whitespace-and-comment"/imm32 - 694 68/push 0x61/imm32/a - 695 50/push-EAX - 696 # . . call - 697 e8/call check-ints-equal/disp32 - 698 # . . discard args - 699 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP - 700 $test-scan-next-byte-skips-whitespace-and-comment:end: - 701 # . epilog - 702 # don't restore ESP from EBP; manually reclaim locals - 703 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - 704 5d/pop-to-EBP - 705 c3/return - 706 - 707 test-scan-next-byte-reads-final-byte: - 708 # - check that the first two bytes of the input are assembled into the resulting number - 709 # This test uses exit-descriptors. Use EBP for setting up local variables. - 710 55/push-EBP - 711 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP - 712 # clear all streams - 713 # . clear-stream(_test-stream) - 714 # . . push args - 715 68/push _test-stream/imm32 - 716 # . . call - 717 e8/call clear-stream/disp32 - 718 # . . discard args - 719 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP - 720 # . clear-stream(_test-buffered-file+4) - 721 # . . push args - 722 b8/copy-to-EAX _test-buffered-file/imm32 - 723 05/add-to-EAX 4/imm32 - 724 50/push-EAX - 725 # . . call - 726 e8/call clear-stream/disp32 - 727 # . . discard args - 728 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP - 729 # . clear-stream(_test-error-stream) - 730 # . . push args - 731 68/push _test-error-stream/imm32 - 732 # . . call - 733 e8/call clear-stream/disp32 - 734 # . . discard args - 735 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP - 736 # initialize '_test-stream' to input with single character - 737 # . write(_test-stream, character) - 738 # . . push args - 739 68/push "a"/imm32 - 740 68/push _test-stream/imm32 - 741 # . . call - 742 e8/call write/disp32 - 743 # . . discard args - 744 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - 745 # initialize exit-descriptor 'ed' for the call to 'scan-next-byte' below - 746 # . var ed/ECX : exit-descriptor - 747 81 5/subop/subtract 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # subtract from ESP - 748 8d/copy-address 0/mod/indirect 4/rm32/sib 4/base/ESP 4/index/none . 1/r32/ECX . . # copy ESP to ECX - 749 # . tailor-exit-descriptor(ed, 12) - 750 # . . push args - 751 68/push 0xc/imm32/nbytes-of-args-for-scan-next-byte - 752 51/push-ECX/ed - 753 # . . call - 754 e8/call tailor-exit-descriptor/disp32 - 755 # . . discard args - 756 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - 757 # EAX = scan-next-byte(_test-buffered-file, _test-error-stream, ed) - 758 # . . push args - 759 51/push-ECX/ed - 760 68/push _test-error-stream/imm32 - 761 68/push _test-buffered-file/imm32 - 762 # . . call - 763 e8/call scan-next-byte/disp32 - 764 # registers except ESP may be clobbered at this point - 765 # pop args to scan-next-bytes - 766 # . . discard first 2 args - 767 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - 768 # . . restore ed - 769 59/pop-to-ECX - 770 # check that scan-next-byte didn't abort - 771 # . check-ints-equal(ed->value, 0, msg) - 772 # . . push args - 773 68/push "F - test-scan-next-byte-reads-final-byte: unexpected abort"/imm32 - 774 68/push 0/imm32 - 775 # . . push ed->value - 776 ff 6/subop/push 1/mod/*+disp8 1/rm32/ECX . . . . 4/disp8 . # push *(ECX+4) - 777 # . . call - 778 e8/call check-ints-equal/disp32 - 779 # . . discard args - 780 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP - 781 # return if abort - 782 81 7/subop/compare 1/mod/*+disp8 1/rm32/ECX . . . . 4/disp8 0/imm32 # compare *(ECX+4) - 783 75/jump-if-not-equal $test-scan-next-byte-reads-final-byte:end/disp8 - 784 # check-ints-equal(EAX, 0x61/a, msg) - 785 # . . push args - 786 68/push "F - test-scan-next-byte-reads-final-byte"/imm32 - 787 68/push 0x61/imm32/a - 788 50/push-EAX - 789 # . . call - 790 e8/call check-ints-equal/disp32 - 791 # . . discard args - 792 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP - 793 $test-scan-next-byte-reads-final-byte:end: - 794 # . epilog - 795 # don't restore ESP from EBP; manually reclaim locals - 796 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - 797 5d/pop-to-EBP - 798 c3/return - 799 - 800 is-hex-lowercase-byte?: # c : byte -> bool/EAX - 801 # . prolog - 802 55/push-EBP - 803 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP - 804 # . save registers - 805 51/push-ECX - 806 # ECX = c - 807 8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . 1/r32/ECX 8/disp8 . # copy *(EBP+8) to ECX - 808 # return false if c < '0' - 809 b8/copy-to-EAX 0/imm32/false - 810 81 7/subop/compare 3/mod/direct 1/rm32/ECX . . . . . 0x30/imm32 # compare ECX - 811 7c/jump-if-lesser $is-hex-lowercase-byte?:end/disp8 - 812 # return false if c > 'f' - 813 81 7/subop/compare 3/mod/direct 1/rm32/ECX . . . . . 0x66/imm32 # compare ECX - 814 7f/jump-if-greater $is-hex-lowercase-byte?:end/disp8 - 815 # return true if c <= '9' - 816 b8/copy-to-EAX 1/imm32/true - 817 81 7/subop/compare 3/mod/direct 1/rm32/ECX . . . . . 0x39/imm32 # compare ECX - 818 7e/jump-if-lesser-or-equal $is-hex-lowercase-byte?:end/disp8 - 819 # return true if c >= 'a' - 820 81 7/subop/compare 3/mod/direct 1/rm32/ECX . . . . . 0x61/imm32 # compare ECX - 821 7d/jump-if-greater-or-equal $is-hex-lowercase-byte?:end/disp8 - 822 # otherwise return false - 823 b8/copy-to-EAX 0/imm32/false - 824 $is-hex-lowercase-byte?:end: - 825 # . restore registers - 826 59/pop-to-ECX - 827 # . epilog - 828 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . . # copy EBP to ESP - 829 5d/pop-to-EBP - 830 c3/return - 831 - 832 test-hex-below-0: - 833 # is-hex-lowercase-byte?(0x2f) - 834 # . . push args - 835 68/push 0x2f/imm32 - 836 # . . call - 837 e8/call is-hex-lowercase-byte?/disp32 - 838 # . . discard args - 839 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP - 840 # check-ints-equal(EAX, 0, msg) - 841 # . . push args - 842 68/push "F - test-hex-below-0"/imm32 - 843 68/push 0/imm32/false - 844 50/push-EAX - 845 # . . call - 846 e8/call check-ints-equal/disp32 - 847 # . . discard args - 848 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP - 849 c3/return - 850 - 851 test-hex-0-to-9: - 852 # is-hex-lowercase-byte?(0x30) - 853 # . . push args - 854 68/push 0x30/imm32 - 855 # . . call - 856 e8/call is-hex-lowercase-byte?/disp32 - 857 # . . discard args - 858 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP - 859 # check-ints-equal(EAX, 1, msg) - 860 # . . push args - 861 68/push "F - test-hex-at-0"/imm32 - 862 68/push 1/imm32/true - 863 50/push-EAX - 864 # . . call - 865 e8/call check-ints-equal/disp32 - 866 # . . discard args - 867 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP - 868 # is-hex-lowercase-byte?(0x39) - 869 # . . push args - 870 68/push 0x39/imm32 - 871 # . . call - 872 e8/call is-hex-lowercase-byte?/disp32 - 873 # . . discard args - 874 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP - 875 # check-ints-equal(EAX, 1, msg) - 876 # . . push args - 877 68/push "F - test-hex-at-9"/imm32 - 878 68/push 1/imm32/true - 879 50/push-EAX - 880 # . . call - 881 e8/call check-ints-equal/disp32 - 882 # . . discard args - 883 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP - 884 c3/return - 885 - 886 test-hex-above-9-to-a: - 887 # is-hex-lowercase-byte?(0x3a) - 888 # . . push args - 889 68/push 0x3a/imm32 - 890 # . . call - 891 e8/call is-hex-lowercase-byte?/disp32 - 892 # . . discard args - 893 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP - 894 # check-ints-equal(EAX, 0, msg) - 895 # . . push args - 896 68/push "F - test-hex-above-9-to-a"/imm32 - 897 68/push 0/imm32/false - 898 50/push-EAX - 899 # . . call - 900 e8/call check-ints-equal/disp32 - 901 # . . discard args - 902 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP - 903 c3/return - 904 - 905 test-hex-a-to-f: - 906 # is-hex-lowercase-byte?(0x61) - 907 # . . push args - 908 68/push 0x61/imm32 - 909 # . . call - 910 e8/call is-hex-lowercase-byte?/disp32 - 911 # . . discard args - 912 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP - 913 # check-ints-equal(EAX, 1, msg) - 914 # . . push args - 915 68/push "F - test-hex-at-a"/imm32 - 916 68/push 1/imm32/true - 917 50/push-EAX - 918 # . . call - 919 e8/call check-ints-equal/disp32 - 920 # . . discard args - 921 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP - 922 # is-hex-lowercase-byte?(0x66) - 923 # . . push args - 924 68/push 0x66/imm32 - 925 # . . call - 926 e8/call is-hex-lowercase-byte?/disp32 - 927 # . . discard args - 928 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP - 929 # check-ints-equal(EAX, 1, msg) - 930 # . . push args - 931 68/push "F - test-hex-at-f"/imm32 - 932 68/push 1/imm32/true - 933 50/push-EAX - 934 # . . call - 935 e8/call check-ints-equal/disp32 - 936 # . . discard args - 937 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP - 938 c3/return - 939 - 940 test-hex-above-f: - 941 # is-hex-lowercase-byte?(0x67) - 942 # . . push args - 943 68/push 0x67/imm32 - 944 # . . call - 945 e8/call is-hex-lowercase-byte?/disp32 - 946 # . . discard args - 947 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP - 948 # check-ints-equal(EAX, 0, msg) - 949 # . . push args - 950 68/push "F - test-hex-above-f"/imm32 - 951 68/push 0/imm32/false - 952 50/push-EAX - 953 # . . call - 954 e8/call check-ints-equal/disp32 - 955 # . . discard args - 956 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP - 957 c3/return - 958 - 959 skip-until-newline: # in : (address buffered-file) -> <void> - 960 # pseudocode: - 961 # push EAX - 962 # repeatedly: - 963 # EAX = read-byte(in) - 964 # if EAX == 0xffffffff break - 965 # if EAX == 0x0a break - 966 # pop EAX - 967 # . prolog - 968 55/push-EBP - 969 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP - 970 # . save registers - 971 50/push-EAX - 972 $skip-until-newline:loop: - 973 # . EAX = read-byte(in) - 974 # . . push args - 975 ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 8/disp8 . # push *(EBP+8) - 976 # . . call - 977 e8/call read-byte/disp32 - 978 # . . discard args - 979 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP - 980 # . if EAX == 0xffffffff break - 981 81 7/subop/compare 3/mod/direct 0/rm32/EAX . . . . . 0xffffffff/imm32 # compare EAX - 982 74/jump-if-equal $skip-until-newline:end/disp8 - 983 $aa: - 984 # . if EAX != 0xa/newline loop - 985 81 7/subop/compare 3/mod/direct 0/rm32/EAX . . . . . 0xa/imm32 # compare EAX - 986 75/jump-if-not-equal $skip-until-newline:loop/disp8 - 987 $skip-until-newline:end: - 988 # . restore registers - 989 58/pop-to-EAX - 990 # . epilog - 991 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . . # copy EBP to ESP - 992 5d/pop-to-EBP - 993 c3/return - 994 - 995 test-skip-until-newline: - 996 # - check that the read pointer points after the newline - 997 # setup - 998 # . clear-stream(_test-stream) - 999 # . . push args -1000 68/push _test-stream/imm32 -1001 # . . call -1002 e8/call clear-stream/disp32 -1003 # . . discard args -1004 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP -1005 # . clear-stream(_test-buffered-file+4) -1006 # . . push args -1007 b8/copy-to-EAX _test-buffered-file/imm32 -1008 05/add-to-EAX 4/imm32 -1009 50/push-EAX -1010 # . . call -1011 e8/call clear-stream/disp32 -1012 # . . discard args -1013 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP -1014 # initialize '_test-stream' to "abc\nde" -1015 # . write(_test-stream, "abc") -1016 # . . push args -1017 68/push "abc"/imm32 -1018 68/push _test-stream/imm32 -1019 # . . call -1020 e8/call write/disp32 -1021 # . . discard args -1022 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP -1023 # . write(_test-stream, Newline) -1024 # . . push args -1025 68/push Newline/imm32 -1026 68/push _test-stream/imm32 -1027 # . . call -1028 e8/call write/disp32 -1029 # . . discard args -1030 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP -1031 # . write(_test-stream, "de") -1032 # . . push args -1033 68/push "de"/imm32 -1034 68/push _test-stream/imm32 -1035 # . . call -1036 e8/call write/disp32 -1037 # . . discard args -1038 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP -1039 # skip-until-newline(_test-buffered-file) -1040 # . . push args -1041 68/push _test-buffered-file/imm32 -1042 # . . call -1043 e8/call skip-until-newline/disp32 -1044 # . . discard args -1045 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP -1046 # check-ints-equal(_test-buffered-file->read, 4, msg) -1047 # . . push args -1048 68/push "F - test-skip-until-newline"/imm32 -1049 68/push 4/imm32 -1050 b8/copy-to-EAX _test-buffered-file/imm32 -1051 ff 6/subop/push 1/mod/*+disp8 0/rm32/EAX . . . . 8/disp8 . # push *(EAX+8) -1052 # . . call -1053 e8/call check-ints-equal/disp32 -1054 # . . discard args -1055 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP -1056 # . end -1057 c3/return -1058 -1059 == data -1060 -1061 _test-output-stream: -1062 # current write index -1063 00 00 00 00 -1064 # current read index -1065 00 00 00 00 -1066 # length (= 8) -1067 08 00 00 00 -1068 # data -1069 00 00 00 00 00 00 00 00 # 8 bytes -1070 -1071 _test-error-stream: -1072 # current write index -1073 00 00 00 00 -1074 # current read index -1075 00 00 00 00 -1076 # length (= 8) -1077 08 00 00 00 -1078 # data -1079 00 00 00 00 00 00 00 00 # 8 bytes -1080 -1081 # . . vim:nowrap:textwidth=0 + 178 # otherwise error-byte(ed, err, msg, EAX) + 179 # . . push args + 180 50/push-EAX + 181 68/push "scan-next-byte: invalid byte"/imm32 + 182 ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0xc/disp8 . # push *(EBP+12) + 183 ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 0x10/disp8 . # push *(EBP+16) + 184 # . . call + 185 e8/call error-byte/disp32 # never returns + 186 $scan-next-byte:end: + 187 # . restore registers + 188 # . epilog + 189 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . . # copy EBP to ESP + 190 5d/pop-to-EBP + 191 c3/return + 192 + 193 test-scan-next-byte: + 194 # - check that the first byte of the input is returned + 195 # This test uses exit-descriptors. Use EBP for setting up local variables. + 196 55/push-EBP + 197 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP + 198 # clear all streams + 199 # . clear-stream(_test-stream) + 200 # . . push args + 201 68/push _test-stream/imm32 + 202 # . . call + 203 e8/call clear-stream/disp32 + 204 # . . discard args + 205 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP + 206 # . clear-stream(_test-buffered-file+4) + 207 # . . push args + 208 b8/copy-to-EAX _test-buffered-file/imm32 + 209 05/add-to-EAX 4/imm32 + 210 50/push-EAX + 211 # . . call + 212 e8/call clear-stream/disp32 + 213 # . . discard args + 214 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP + 215 # . clear-stream(_test-error-stream) + 216 # . . push args + 217 68/push _test-error-stream/imm32 + 218 # . . call + 219 e8/call clear-stream/disp32 + 220 # . . discard args + 221 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP + 222 # initialize '_test-stream' to "abc" + 223 # . write(_test-stream, "abc") + 224 # . . push args + 225 68/push "abc"/imm32 + 226 68/push _test-stream/imm32 + 227 # . . call + 228 e8/call write/disp32 + 229 # . . discard args + 230 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + 231 # initialize exit-descriptor 'ed' for the call to 'scan-next-byte' below + 232 # . var ed/ECX : exit-descriptor + 233 81 5/subop/subtract 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # subtract from ESP + 234 8d/copy-address 0/mod/indirect 4/rm32/sib 4/base/ESP 4/index/none . 1/r32/ECX . . # copy ESP to ECX + 235 # . tailor-exit-descriptor(ed, 12) + 236 # . . push args + 237 68/push 0xc/imm32/nbytes-of-args-for-scan-next-byte + 238 51/push-ECX/ed + 239 # . . call + 240 e8/call tailor-exit-descriptor/disp32 + 241 # . . discard args + 242 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + 243 # EAX = scan-next-byte(_test-buffered-file, _test-error-stream, ed) + 244 # . . push args + 245 51/push-ECX/ed + 246 68/push _test-error-stream/imm32 + 247 68/push _test-buffered-file/imm32 + 248 # . . call + 249 e8/call scan-next-byte/disp32 + 250 # registers except ESP may be clobbered at this point + 251 # pop args to scan-next-bytes + 252 # . . discard first 2 args + 253 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + 254 # . . restore ed + 255 59/pop-to-ECX + 256 # check that scan-next-byte didn't abort + 257 # . check-ints-equal(ed->value, 0, msg) + 258 # . . push args + 259 68/push "F - test-scan-next-byte: unexpected abort"/imm32 + 260 68/push 0/imm32 + 261 # . . push ed->value + 262 ff 6/subop/push 1/mod/*+disp8 1/rm32/ECX . . . . 4/disp8 . # push *(ECX+4) + 263 # . . call + 264 e8/call check-ints-equal/disp32 + 265 # . . discard args + 266 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP + 267 # return if abort + 268 81 7/subop/compare 1/mod/*+disp8 1/rm32/ECX . . . . 4/disp8 0/imm32 # compare *(ECX+4) + 269 75/jump-if-not-equal $test-scan-next-byte:end/disp8 + 270 # check-ints-equal(EAX, 0x61/a, msg) + 271 # . . push args + 272 68/push "F - test-scan-next-byte"/imm32 + 273 68/push 0x61/imm32/a + 274 50/push-EAX + 275 # . . call + 276 e8/call check-ints-equal/disp32 + 277 # . . discard args + 278 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP + 279 $test-scan-next-byte:end: + 280 # . epilog + 281 # don't restore ESP from EBP; manually reclaim locals + 282 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + 283 5d/pop-to-EBP + 284 c3/return + 285 + 286 test-scan-next-byte-skips-whitespace: + 287 # - check that the first byte after whitespace is returned + 288 # This test uses exit-descriptors. Use EBP for setting up local variables. + 289 55/push-EBP + 290 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP + 291 # clear all streams + 292 # . clear-stream(_test-stream) + 293 # . . push args + 294 68/push _test-stream/imm32 + 295 # . . call + 296 e8/call clear-stream/disp32 + 297 # . . discard args + 298 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP + 299 # . clear-stream(_test-buffered-file+4) + 300 # . . push args + 301 b8/copy-to-EAX _test-buffered-file/imm32 + 302 05/add-to-EAX 4/imm32 + 303 50/push-EAX + 304 # . . call + 305 e8/call clear-stream/disp32 + 306 # . . discard args + 307 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP + 308 # . clear-stream(_test-error-stream) + 309 # . . push args + 310 68/push _test-error-stream/imm32 + 311 # . . call + 312 e8/call clear-stream/disp32 + 313 # . . discard args + 314 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP + 315 # initialize '_test-stream' to input with leading whitespace + 316 # . write(_test-stream, text) + 317 # . . push args + 318 68/push " abc"/imm32 + 319 68/push _test-stream/imm32 + 320 # . . call + 321 e8/call write/disp32 + 322 # . . discard args + 323 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + 324 # initialize exit-descriptor 'ed' for the call to 'scan-next-byte' below + 325 # . var ed/ECX : exit-descriptor + 326 81 5/subop/subtract 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # subtract from ESP + 327 8d/copy-address 0/mod/indirect 4/rm32/sib 4/base/ESP 4/index/none . 1/r32/ECX . . # copy ESP to ECX + 328 # . tailor-exit-descriptor(ed, 12) + 329 # . . push args + 330 68/push 0xc/imm32/nbytes-of-args-for-scan-next-byte + 331 51/push-ECX/ed + 332 # . . call + 333 e8/call tailor-exit-descriptor/disp32 + 334 # . . discard args + 335 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + 336 # EAX = scan-next-byte(_test-buffered-file, _test-error-stream, ed) + 337 # . . push args + 338 51/push-ECX/ed + 339 68/push _test-error-stream/imm32 + 340 68/push _test-buffered-file/imm32 + 341 # . . call + 342 e8/call scan-next-byte/disp32 + 343 # registers except ESP may be clobbered at this point + 344 # pop args to scan-next-bytes + 345 # . . discard first 2 args + 346 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + 347 # . . restore ed + 348 59/pop-to-ECX + 349 # check that scan-next-byte didn't abort + 350 # . check-ints-equal(ed->value, 0, msg) + 351 # . . push args + 352 68/push "F - test-scan-next-byte-skips-whitespace: unexpected abort"/imm32 + 353 68/push 0/imm32 + 354 # . . push ed->value + 355 ff 6/subop/push 1/mod/*+disp8 1/rm32/ECX . . . . 4/disp8 . # push *(ECX+4) + 356 # . . call + 357 e8/call check-ints-equal/disp32 + 358 # . . discard args + 359 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP + 360 # return if abort + 361 81 7/subop/compare 1/mod/*+disp8 1/rm32/ECX . . . . 4/disp8 0/imm32 # compare *(ECX+4) + 362 75/jump-if-not-equal $test-scan-next-byte-skips-whitespace:end/disp8 + 363 # check-ints-equal(EAX, 0x61/a, msg) + 364 # . . push args + 365 68/push "F - test-scan-next-byte-skips-whitespace"/imm32 + 366 68/push 0x61/imm32/a + 367 50/push-EAX + 368 # . . call + 369 e8/call check-ints-equal/disp32 + 370 # . . discard args + 371 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP + 372 $test-scan-next-byte-skips-whitespace:end: + 373 # . epilog + 374 # don't restore ESP from EBP; manually reclaim locals + 375 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + 376 5d/pop-to-EBP + 377 c3/return + 378 + 379 test-scan-next-byte-skips-comment: + 380 # - check that the first byte after a comment (and newline) is returned + 381 # This test uses exit-descriptors. Use EBP for setting up local variables. + 382 55/push-EBP + 383 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP + 384 # clear all streams + 385 # . clear-stream(_test-stream) + 386 # . . push args + 387 68/push _test-stream/imm32 + 388 # . . call + 389 e8/call clear-stream/disp32 + 390 # . . discard args + 391 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP + 392 # . clear-stream(_test-buffered-file+4) + 393 # . . push args + 394 b8/copy-to-EAX _test-buffered-file/imm32 + 395 05/add-to-EAX 4/imm32 + 396 50/push-EAX + 397 # . . call + 398 e8/call clear-stream/disp32 + 399 # . . discard args + 400 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP + 401 # . clear-stream(_test-error-stream) + 402 # . . push args + 403 68/push _test-error-stream/imm32 + 404 # . . call + 405 e8/call clear-stream/disp32 + 406 # . . discard args + 407 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP + 408 # initialize '_test-stream' to input with leading comment + 409 # . write(_test-stream, comment) + 410 # . . push args + 411 68/push "#x"/imm32 + 412 68/push _test-stream/imm32 + 413 # . . call + 414 e8/call write/disp32 + 415 # . . discard args + 416 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + 417 # . write(_test-stream, Newline) + 418 # . . push args + 419 68/push Newline/imm32 + 420 68/push _test-stream/imm32 + 421 # . . call + 422 e8/call write/disp32 + 423 # . . discard args + 424 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + 425 # . write(_test-stream, real text) + 426 # . . push args + 427 68/push "ab"/imm32 + 428 68/push _test-stream/imm32 + 429 # . . call + 430 e8/call write/disp32 + 431 # . . discard args + 432 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + 433 # initialize exit-descriptor 'ed' for the call to 'scan-next-byte' below + 434 # . var ed/ECX : exit-descriptor + 435 81 5/subop/subtract 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # subtract from ESP + 436 8d/copy-address 0/mod/indirect 4/rm32/sib 4/base/ESP 4/index/none . 1/r32/ECX . . # copy ESP to ECX + 437 # . tailor-exit-descriptor(ed, 12) + 438 # . . push args + 439 68/push 0xc/imm32/nbytes-of-args-for-scan-next-byte + 440 51/push-ECX/ed + 441 # . . call + 442 e8/call tailor-exit-descriptor/disp32 + 443 # . . discard args + 444 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + 445 # EAX = scan-next-byte(_test-buffered-file, _test-error-stream, ed) + 446 # . . push args + 447 51/push-ECX/ed + 448 68/push _test-error-stream/imm32 + 449 68/push _test-buffered-file/imm32 + 450 # . . call + 451 e8/call scan-next-byte/disp32 + 452 # registers except ESP may be clobbered at this point + 453 # pop args to scan-next-bytes + 454 # . . discard first 2 args + 455 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + 456 # . . restore ed + 457 59/pop-to-ECX + 458 # check that scan-next-byte didn't abort + 459 # . check-ints-equal(ed->value, 0, msg) + 460 # . . push args + 461 68/push "F - test-scan-next-byte-skips-comment: unexpected abort"/imm32 + 462 68/push 0/imm32 + 463 # . . push ed->value + 464 ff 6/subop/push 1/mod/*+disp8 1/rm32/ECX . . . . 4/disp8 . # push *(ECX+4) + 465 # . . call + 466 e8/call check-ints-equal/disp32 + 467 # . . discard args + 468 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP + 469 # return if abort + 470 81 7/subop/compare 1/mod/*+disp8 1/rm32/ECX . . . . 4/disp8 0/imm32 # compare *(ECX+4) + 471 75/jump-if-not-equal $test-scan-next-byte-skips-comment:end/disp8 + 472 # check-ints-equal(EAX, 0x61/a, msg) + 473 # . . push args + 474 68/push "F - test-scan-next-byte-skips-comment"/imm32 + 475 68/push 0x61/imm32/a + 476 50/push-EAX + 477 # . . call + 478 e8/call check-ints-equal/disp32 + 479 # . . discard args + 480 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP + 481 $test-scan-next-byte-skips-comment:end: + 482 # . epilog + 483 # don't restore ESP from EBP; manually reclaim locals + 484 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + 485 5d/pop-to-EBP + 486 c3/return + 487 + 488 test-scan-next-byte-skips-comment-and-whitespace: + 489 # - check that the first byte after a comment and any further whitespace is returned + 490 # This test uses exit-descriptors. Use EBP for setting up local variables. + 491 55/push-EBP + 492 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP + 493 # clear all streams + 494 # . clear-stream(_test-stream) + 495 # . . push args + 496 68/push _test-stream/imm32 + 497 # . . call + 498 e8/call clear-stream/disp32 + 499 # . . discard args + 500 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP + 501 # . clear-stream(_test-buffered-file+4) + 502 # . . push args + 503 b8/copy-to-EAX _test-buffered-file/imm32 + 504 05/add-to-EAX 4/imm32 + 505 50/push-EAX + 506 # . . call + 507 e8/call clear-stream/disp32 + 508 # . . discard args + 509 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP + 510 # . clear-stream(_test-error-stream) + 511 # . . push args + 512 68/push _test-error-stream/imm32 + 513 # . . call + 514 e8/call clear-stream/disp32 + 515 # . . discard args + 516 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP + 517 # initialize '_test-stream' to input with leading comment and more whitespace after newline + 518 # . write(_test-stream, comment) + 519 # . . push args + 520 68/push "#x"/imm32 + 521 68/push _test-stream/imm32 + 522 # . . call + 523 e8/call write/disp32 + 524 # . . discard args + 525 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + 526 # . write(_test-stream, Newline) + 527 # . . push args + 528 68/push Newline/imm32 + 529 68/push _test-stream/imm32 + 530 # . . call + 531 e8/call write/disp32 + 532 # . . discard args + 533 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + 534 # . write(_test-stream, real text) + 535 # . . push args + 536 68/push " ab"/imm32 + 537 68/push _test-stream/imm32 + 538 # . . call + 539 e8/call write/disp32 + 540 # . . discard args + 541 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + 542 # initialize exit-descriptor 'ed' for the call to 'scan-next-byte' below + 543 # . var ed/ECX : exit-descriptor + 544 81 5/subop/subtract 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # subtract from ESP + 545 8d/copy-address 0/mod/indirect 4/rm32/sib 4/base/ESP 4/index/none . 1/r32/ECX . . # copy ESP to ECX + 546 # . tailor-exit-descriptor(ed, 12) + 547 # . . push args + 548 68/push 0xc/imm32/nbytes-of-args-for-scan-next-byte + 549 51/push-ECX/ed + 550 # . . call + 551 e8/call tailor-exit-descriptor/disp32 + 552 # . . discard args + 553 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + 554 # EAX = scan-next-byte(_test-buffered-file, _test-error-stream, ed) + 555 # . . push args + 556 51/push-ECX/ed + 557 68/push _test-error-stream/imm32 + 558 68/push _test-buffered-file/imm32 + 559 # . . call + 560 e8/call scan-next-byte/disp32 + 561 # registers except ESP may be clobbered at this point + 562 # pop args to scan-next-bytes + 563 # . . discard first 2 args + 564 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + 565 # . . restore ed + 566 59/pop-to-ECX + 567 # check that scan-next-byte didn't abort + 568 # . check-ints-equal(ed->value, 0, msg) + 569 # . . push args + 570 68/push "F - test-scan-next-byte-skips-comment-and-whitespace: unexpected abort"/imm32 + 571 68/push 0/imm32 + 572 # . . push ed->value + 573 ff 6/subop/push 1/mod/*+disp8 1/rm32/ECX . . . . 4/disp8 . # push *(ECX+4) + 574 # . . call + 575 e8/call check-ints-equal/disp32 + 576 # . . discard args + 577 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP + 578 # return if abort + 579 81 7/subop/compare 1/mod/*+disp8 1/rm32/ECX . . . . 4/disp8 0/imm32 # compare *(ECX+4) + 580 75/jump-if-not-equal $test-scan-next-byte-skips-comment-and-whitespace:end/disp8 + 581 # check-ints-equal(EAX, 0x61/a, msg) + 582 # . . push args + 583 68/push "F - test-scan-next-byte-skips-comment-and-whitespace"/imm32 + 584 68/push 0x61/imm32/a + 585 50/push-EAX + 586 # . . call + 587 e8/call check-ints-equal/disp32 + 588 # . . discard args + 589 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP + 590 $test-scan-next-byte-skips-comment-and-whitespace:end: + 591 # . epilog + 592 # don't restore ESP from EBP; manually reclaim locals + 593 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + 594 5d/pop-to-EBP + 595 c3/return + 596 + 597 test-scan-next-byte-skips-whitespace-and-comment: + 598 # - check that the first byte after any whitespace and comments is returned + 599 # This test uses exit-descriptors. Use EBP for setting up local variables. + 600 55/push-EBP + 601 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP + 602 # clear all streams + 603 # . clear-stream(_test-stream) + 604 # . . push args + 605 68/push _test-stream/imm32 + 606 # . . call + 607 e8/call clear-stream/disp32 + 608 # . . discard args + 609 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP + 610 # . clear-stream(_test-buffered-file+4) + 611 # . . push args + 612 b8/copy-to-EAX _test-buffered-file/imm32 + 613 05/add-to-EAX 4/imm32 + 614 50/push-EAX + 615 # . . call + 616 e8/call clear-stream/disp32 + 617 # . . discard args + 618 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP + 619 # . clear-stream(_test-error-stream) + 620 # . . push args + 621 68/push _test-error-stream/imm32 + 622 # . . call + 623 e8/call clear-stream/disp32 + 624 # . . discard args + 625 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP + 626 # initialize '_test-stream' to input with leading whitespace and comment + 627 # . write(_test-stream, comment) + 628 # . . push args + 629 68/push " #x"/imm32 + 630 68/push _test-stream/imm32 + 631 # . . call + 632 e8/call write/disp32 + 633 # . . discard args + 634 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + 635 # . write(_test-stream, Newline) + 636 # . . push args + 637 68/push Newline/imm32 + 638 68/push _test-stream/imm32 + 639 # . . call + 640 e8/call write/disp32 + 641 # . . discard args + 642 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + 643 # . write(_test-stream, real text) + 644 # . . push args + 645 68/push "ab"/imm32 + 646 68/push _test-stream/imm32 + 647 # . . call + 648 e8/call write/disp32 + 649 # . . discard args + 650 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + 651 # initialize exit-descriptor 'ed' for the call to 'scan-next-byte' below + 652 # . var ed/ECX : exit-descriptor + 653 81 5/subop/subtract 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # subtract from ESP + 654 8d/copy-address 0/mod/indirect 4/rm32/sib 4/base/ESP 4/index/none . 1/r32/ECX . . # copy ESP to ECX + 655 # . tailor-exit-descriptor(ed, 12) + 656 # . . push args + 657 68/push 0xc/imm32/nbytes-of-args-for-scan-next-byte + 658 51/push-ECX/ed + 659 # . . call + 660 e8/call tailor-exit-descriptor/disp32 + 661 # . . discard args + 662 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + 663 # EAX = scan-next-byte(_test-buffered-file, _test-error-stream, ed) + 664 # . . push args + 665 51/push-ECX/ed + 666 68/push _test-error-stream/imm32 + 667 68/push _test-buffered-file/imm32 + 668 # . . call + 669 e8/call scan-next-byte/disp32 + 670 # registers except ESP may be clobbered at this point + 671 # pop args to scan-next-bytes + 672 # . . discard first 2 args + 673 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + 674 # . . restore ed + 675 59/pop-to-ECX + 676 # check that scan-next-byte didn't abort + 677 # . check-ints-equal(ed->value, 0, msg) + 678 # . . push args + 679 68/push "F - test-scan-next-byte-skips-whitespace-and-comment: unexpected abort"/imm32 + 680 68/push 0/imm32 + 681 # . . push ed->value + 682 ff 6/subop/push 1/mod/*+disp8 1/rm32/ECX . . . . 4/disp8 . # push *(ECX+4) + 683 # . . call + 684 e8/call check-ints-equal/disp32 + 685 # . . discard args + 686 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP + 687 # return if abort + 688 81 7/subop/compare 1/mod/*+disp8 1/rm32/ECX . . . . 4/disp8 0/imm32 # compare *(ECX+4) + 689 75/jump-if-not-equal $test-scan-next-byte-skips-whitespace-and-comment:end/disp8 + 690 # check-ints-equal(EAX, 0x61/a, msg) + 691 # . . push args + 692 68/push "F - test-scan-next-byte-skips-whitespace-and-comment"/imm32 + 693 68/push 0x61/imm32/a + 694 50/push-EAX + 695 # . . call + 696 e8/call check-ints-equal/disp32 + 697 # . . discard args + 698 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP + 699 $test-scan-next-byte-skips-whitespace-and-comment:end: + 700 # . epilog + 701 # don't restore ESP from EBP; manually reclaim locals + 702 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + 703 5d/pop-to-EBP + 704 c3/return + 705 + 706 test-scan-next-byte-reads-final-byte: + 707 # - check that the final byte in input is returned + 708 # This test uses exit-descriptors. Use EBP for setting up local variables. + 709 55/push-EBP + 710 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP + 711 # clear all streams + 712 # . clear-stream(_test-stream) + 713 # . . push args + 714 68/push _test-stream/imm32 + 715 # . . call + 716 e8/call clear-stream/disp32 + 717 # . . discard args + 718 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP + 719 # . clear-stream(_test-buffered-file+4) + 720 # . . push args + 721 b8/copy-to-EAX _test-buffered-file/imm32 + 722 05/add-to-EAX 4/imm32 + 723 50/push-EAX + 724 # . . call + 725 e8/call clear-stream/disp32 + 726 # . . discard args + 727 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP + 728 # . clear-stream(_test-error-stream) + 729 # . . push args + 730 68/push _test-error-stream/imm32 + 731 # . . call + 732 e8/call clear-stream/disp32 + 733 # . . discard args + 734 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP + 735 # initialize '_test-stream' to input with single character + 736 # . write(_test-stream, character) + 737 # . . push args + 738 68/push "a"/imm32 + 739 68/push _test-stream/imm32 + 740 # . . call + 741 e8/call write/disp32 + 742 # . . discard args + 743 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + 744 # initialize exit-descriptor 'ed' for the call to 'scan-next-byte' below + 745 # . var ed/ECX : exit-descriptor + 746 81 5/subop/subtract 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # subtract from ESP + 747 8d/copy-address 0/mod/indirect 4/rm32/sib 4/base/ESP 4/index/none . 1/r32/ECX . . # copy ESP to ECX + 748 # . tailor-exit-descriptor(ed, 12) + 749 # . . push args + 750 68/push 0xc/imm32/nbytes-of-args-for-scan-next-byte + 751 51/push-ECX/ed + 752 # . . call + 753 e8/call tailor-exit-descriptor/disp32 + 754 # . . discard args + 755 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + 756 # EAX = scan-next-byte(_test-buffered-file, _test-error-stream, ed) + 757 # . . push args + 758 51/push-ECX/ed + 759 68/push _test-error-stream/imm32 + 760 68/push _test-buffered-file/imm32 + 761 # . . call + 762 e8/call scan-next-byte/disp32 + 763 # registers except ESP may be clobbered at this point + 764 # pop args to scan-next-bytes + 765 # . . discard first 2 args + 766 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + 767 # . . restore ed + 768 59/pop-to-ECX + 769 # check that scan-next-byte didn't abort + 770 # . check-ints-equal(ed->value, 0, msg) + 771 # . . push args + 772 68/push "F - test-scan-next-byte-reads-final-byte: unexpected abort"/imm32 + 773 68/push 0/imm32 + 774 # . . push ed->value + 775 ff 6/subop/push 1/mod/*+disp8 1/rm32/ECX . . . . 4/disp8 . # push *(ECX+4) + 776 # . . call + 777 e8/call check-ints-equal/disp32 + 778 # . . discard args + 779 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP + 780 # return if abort + 781 81 7/subop/compare 1/mod/*+disp8 1/rm32/ECX . . . . 4/disp8 0/imm32 # compare *(ECX+4) + 782 75/jump-if-not-equal $test-scan-next-byte-reads-final-byte:end/disp8 + 783 # check-ints-equal(EAX, 0x61/a, msg) + 784 # . . push args + 785 68/push "F - test-scan-next-byte-reads-final-byte"/imm32 + 786 68/push 0x61/imm32/a + 787 50/push-EAX + 788 # . . call + 789 e8/call check-ints-equal/disp32 + 790 # . . discard args + 791 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP + 792 $test-scan-next-byte-reads-final-byte:end: + 793 # . epilog + 794 # don't restore ESP from EBP; manually reclaim locals + 795 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + 796 5d/pop-to-EBP + 797 c3/return + 798 + 799 is-hex-lowercase-byte?: # c : byte -> bool/EAX + 800 # . prolog + 801 55/push-EBP + 802 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP + 803 # . save registers + 804 51/push-ECX + 805 # ECX = c + 806 8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . 1/r32/ECX 8/disp8 . # copy *(EBP+8) to ECX + 807 # return false if c < '0' + 808 b8/copy-to-EAX 0/imm32/false + 809 81 7/subop/compare 3/mod/direct 1/rm32/ECX . . . . . 0x30/imm32 # compare ECX + 810 7c/jump-if-lesser $is-hex-lowercase-byte?:end/disp8 + 811 # return false if c > 'f' + 812 81 7/subop/compare 3/mod/direct 1/rm32/ECX . . . . . 0x66/imm32 # compare ECX + 813 7f/jump-if-greater $is-hex-lowercase-byte?:end/disp8 + 814 # return true if c <= '9' + 815 b8/copy-to-EAX 1/imm32/true + 816 81 7/subop/compare 3/mod/direct 1/rm32/ECX . . . . . 0x39/imm32 # compare ECX + 817 7e/jump-if-lesser-or-equal $is-hex-lowercase-byte?:end/disp8 + 818 # return true if c >= 'a' + 819 81 7/subop/compare 3/mod/direct 1/rm32/ECX . . . . . 0x61/imm32 # compare ECX + 820 7d/jump-if-greater-or-equal $is-hex-lowercase-byte?:end/disp8 + 821 # otherwise return false + 822 b8/copy-to-EAX 0/imm32/false + 823 $is-hex-lowercase-byte?:end: + 824 # . restore registers + 825 59/pop-to-ECX + 826 # . epilog + 827 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . . # copy EBP to ESP + 828 5d/pop-to-EBP + 829 c3/return + 830 + 831 test-hex-below-0: + 832 # is-hex-lowercase-byte?(0x2f) + 833 # . . push args + 834 68/push 0x2f/imm32 + 835 # . . call + 836 e8/call is-hex-lowercase-byte?/disp32 + 837 # . . discard args + 838 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP + 839 # check-ints-equal(EAX, 0, msg) + 840 # . . push args + 841 68/push "F - test-hex-below-0"/imm32 + 842 68/push 0/imm32/false + 843 50/push-EAX + 844 # . . call + 845 e8/call check-ints-equal/disp32 + 846 # . . discard args + 847 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP + 848 c3/return + 849 + 850 test-hex-0-to-9: + 851 # is-hex-lowercase-byte?(0x30) + 852 # . . push args + 853 68/push 0x30/imm32 + 854 # . . call + 855 e8/call is-hex-lowercase-byte?/disp32 + 856 # . . discard args + 857 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP + 858 # check-ints-equal(EAX, 1, msg) + 859 # . . push args + 860 68/push "F - test-hex-at-0"/imm32 + 861 68/push 1/imm32/true + 862 50/push-EAX + 863 # . . call + 864 e8/call check-ints-equal/disp32 + 865 # . . discard args + 866 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP + 867 # is-hex-lowercase-byte?(0x39) + 868 # . . push args + 869 68/push 0x39/imm32 + 870 # . . call + 871 e8/call is-hex-lowercase-byte?/disp32 + 872 # . . discard args + 873 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP + 874 # check-ints-equal(EAX, 1, msg) + 875 # . . push args + 876 68/push "F - test-hex-at-9"/imm32 + 877 68/push 1/imm32/true + 878 50/push-EAX + 879 # . . call + 880 e8/call check-ints-equal/disp32 + 881 # . . discard args + 882 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP + 883 c3/return + 884 + 885 test-hex-above-9-to-a: + 886 # is-hex-lowercase-byte?(0x3a) + 887 # . . push args + 888 68/push 0x3a/imm32 + 889 # . . call + 890 e8/call is-hex-lowercase-byte?/disp32 + 891 # . . discard args + 892 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP + 893 # check-ints-equal(EAX, 0, msg) + 894 # . . push args + 895 68/push "F - test-hex-above-9-to-a"/imm32 + 896 68/push 0/imm32/false + 897 50/push-EAX + 898 # . . call + 899 e8/call check-ints-equal/disp32 + 900 # . . discard args + 901 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP + 902 c3/return + 903 + 904 test-hex-a-to-f: + 905 # is-hex-lowercase-byte?(0x61) + 906 # . . push args + 907 68/push 0x61/imm32 + 908 # . . call + 909 e8/call is-hex-lowercase-byte?/disp32 + 910 # . . discard args + 911 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP + 912 # check-ints-equal(EAX, 1, msg) + 913 # . . push args + 914 68/push "F - test-hex-at-a"/imm32 + 915 68/push 1/imm32/true + 916 50/push-EAX + 917 # . . call + 918 e8/call check-ints-equal/disp32 + 919 # . . discard args + 920 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP + 921 # is-hex-lowercase-byte?(0x66) + 922 # . . push args + 923 68/push 0x66/imm32 + 924 # . . call + 925 e8/call is-hex-lowercase-byte?/disp32 + 926 # . . discard args + 927 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP + 928 # check-ints-equal(EAX, 1, msg) + 929 # . . push args + 930 68/push "F - test-hex-at-f"/imm32 + 931 68/push 1/imm32/true + 932 50/push-EAX + 933 # . . call + 934 e8/call check-ints-equal/disp32 + 935 # . . discard args + 936 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP + 937 c3/return + 938 + 939 test-hex-above-f: + 940 # is-hex-lowercase-byte?(0x67) + 941 # . . push args + 942 68/push 0x67/imm32 + 943 # . . call + 944 e8/call is-hex-lowercase-byte?/disp32 + 945 # . . discard args + 946 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP + 947 # check-ints-equal(EAX, 0, msg) + 948 # . . push args + 949 68/push "F - test-hex-above-f"/imm32 + 950 68/push 0/imm32/false + 951 50/push-EAX + 952 # . . call + 953 e8/call check-ints-equal/disp32 + 954 # . . discard args + 955 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP + 956 c3/return + 957 + 958 skip-until-newline: # in : (address buffered-file) -> <void> + 959 # pseudocode: + 960 # push EAX + 961 # repeatedly: + 962 # EAX = read-byte(in) + 963 # if EAX == 0xffffffff break + 964 # if EAX == 0x0a break + 965 # pop EAX + 966 # . prolog + 967 55/push-EBP + 968 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP + 969 # . save registers + 970 50/push-EAX + 971 $skip-until-newline:loop: + 972 # . EAX = read-byte(in) + 973 # . . push args + 974 ff 6/subop/push 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . . 8/disp8 . # push *(EBP+8) + 975 # . . call + 976 e8/call read-byte/disp32 + 977 # . . discard args + 978 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP + 979 # . if EAX == 0xffffffff break + 980 81 7/subop/compare 3/mod/direct 0/rm32/EAX . . . . . 0xffffffff/imm32 # compare EAX + 981 74/jump-if-equal $skip-until-newline:end/disp8 + 982 $aa: + 983 # . if EAX != 0xa/newline loop + 984 81 7/subop/compare 3/mod/direct 0/rm32/EAX . . . . . 0xa/imm32 # compare EAX + 985 75/jump-if-not-equal $skip-until-newline:loop/disp8 + 986 $skip-until-newline:end: + 987 # . restore registers + 988 58/pop-to-EAX + 989 # . epilog + 990 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . . # copy EBP to ESP + 991 5d/pop-to-EBP + 992 c3/return + 993 + 994 test-skip-until-newline: + 995 # - check that the read pointer points after the newline + 996 # setup + 997 # . clear-stream(_test-stream) + 998 # . . push args + 999 68/push _test-stream/imm32 +1000 # . . call +1001 e8/call clear-stream/disp32 +1002 # . . discard args +1003 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP +1004 # . clear-stream(_test-buffered-file+4) +1005 # . . push args +1006 b8/copy-to-EAX _test-buffered-file/imm32 +1007 05/add-to-EAX 4/imm32 +1008 50/push-EAX +1009 # . . call +1010 e8/call clear-stream/disp32 +1011 # . . discard args +1012 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP +1013 # initialize '_test-stream' to "abc\nde" +1014 # . write(_test-stream, "abc") +1015 # . . push args +1016 68/push "abc"/imm32 +1017 68/push _test-stream/imm32 +1018 # . . call +1019 e8/call write/disp32 +1020 # . . discard args +1021 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP +1022 # . write(_test-stream, Newline) +1023 # . . push args +1024 68/push Newline/imm32 +1025 68/push _test-stream/imm32 +1026 # . . call +1027 e8/call write/disp32 +1028 # . . discard args +1029 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP +1030 # . write(_test-stream, "de") +1031 # . . push args +1032 68/push "de"/imm32 +1033 68/push _test-stream/imm32 +1034 # . . call +1035 e8/call write/disp32 +1036 # . . discard args +1037 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP +1038 # skip-until-newline(_test-buffered-file) +1039 # . . push args +1040 68/push _test-buffered-file/imm32 +1041 # . . call +1042 e8/call skip-until-newline/disp32 +1043 # . . discard args +1044 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP +1045 # check-ints-equal(_test-buffered-file->read, 4, msg) +1046 # . . push args +1047 68/push "F - test-skip-until-newline"/imm32 +1048 68/push 4/imm32 +1049 b8/copy-to-EAX _test-buffered-file/imm32 +1050 ff 6/subop/push 1/mod/*+disp8 0/rm32/EAX . . . . 8/disp8 . # push *(EAX+8) +1051 # . . call +1052 e8/call check-ints-equal/disp32 +1053 # . . discard args +1054 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP +1055 # . end +1056 c3/return +1057 +1058 == data +1059 +1060 _test-output-stream: +1061 # current write index +1062 00 00 00 00 +1063 # current read index +1064 00 00 00 00 +1065 # length (= 8) +1066 08 00 00 00 +1067 # data +1068 00 00 00 00 00 00 00 00 # 8 bytes +1069 +1070 _test-error-stream: +1071 # current write index +1072 00 00 00 00 +1073 # current read index +1074 00 00 00 00 +1075 # length (= 8) +1076 08 00 00 00 +1077 # data +1078 00 00 00 00 00 00 00 00 # 8 bytes +1079 +1080 # . . vim:nowrap:textwidth=0 -- cgit 1.4.1-2-gfad0