From 7bc0f8c1d0a04c082a7295339ceedb0090959ac5 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Mon, 11 Feb 2019 23:01:20 -0800 Subject: 4957 --- html/subx/072slice.subx.html | 167 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 138 insertions(+), 29 deletions(-) (limited to 'html/subx/072slice.subx.html') diff --git a/html/subx/072slice.subx.html b/html/subx/072slice.subx.html index 6d3be6ad..535e2937 100644 --- a/html/subx/072slice.subx.html +++ b/html/subx/072slice.subx.html @@ -223,8 +223,8 @@ if ('onhashchange' in window) { 161 55/push-EBP 162 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP 163 # var slice/ECX -164 68/push _test-slice-data-3/imm32/end -165 68/push _test-slice-data-0/imm32/start +164 68/push _test-slice-data-3/imm32/end +165 68/push _test-slice-data-0/imm32/start 166 89/copy 3/mod/direct 1/rm32/ECX . . . 4/r32/ESP . . # copy ESP to ECX 167 # EAX = slice-equal?(ECX, "Abc") 168 # . . push args @@ -254,8 +254,8 @@ if ('onhashchange' in window) { 192 55/push-EBP 193 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP 194 # var slice/ECX -195 68/push _test-slice-data-4/imm32/end -196 68/push _test-slice-data-1/imm32/start +195 68/push _test-slice-data-4/imm32/end +196 68/push _test-slice-data-1/imm32/start 197 89/copy 3/mod/direct 1/rm32/ECX . . . 4/r32/ESP . . # copy ESP to ECX 198 # EAX = slice-equal?(ECX, "Abc") 199 # . . push args @@ -285,8 +285,8 @@ if ('onhashchange' in window) { 223 55/push-EBP 224 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP 225 # var slice/ECX -226 68/push _test-slice-data-4/imm32/end -227 68/push _test-slice-data-0/imm32/start +226 68/push _test-slice-data-4/imm32/end +227 68/push _test-slice-data-0/imm32/start 228 89/copy 3/mod/direct 1/rm32/ECX . . . 4/r32/ESP . . # copy ESP to ECX 229 # EAX = slice-equal?(ECX, "Abc") 230 # . . push args @@ -316,8 +316,8 @@ if ('onhashchange' in window) { 254 55/push-EBP 255 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP 256 # var slice/ECX -257 68/push _test-slice-data-1/imm32/end -258 68/push _test-slice-data-0/imm32/start +257 68/push _test-slice-data-1/imm32/end +258 68/push _test-slice-data-0/imm32/start 259 89/copy 3/mod/direct 1/rm32/ECX . . . 4/r32/ESP . . # copy ESP to ECX 260 # EAX = slice-equal?(ECX, "Abc") 261 # . . push args @@ -347,8 +347,8 @@ if ('onhashchange' in window) { 285 55/push-EBP 286 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP 287 # var slice/ECX -288 68/push _test-slice-data-0/imm32/end -289 68/push _test-slice-data-0/imm32/start +288 68/push _test-slice-data-0/imm32/end +289 68/push _test-slice-data-0/imm32/start 290 89/copy 3/mod/direct 1/rm32/ECX . . . 4/r32/ESP . . # copy ESP to ECX 291 # EAX = slice-equal?(ECX, "Abc") 292 # . . push args @@ -378,8 +378,8 @@ if ('onhashchange' in window) { 316 55/push-EBP 317 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP 318 # var slice/ECX -319 68/push _test-slice-data-2/imm32/end -320 68/push _test-slice-data-0/imm32/start +319 68/push _test-slice-data-2/imm32/end +320 68/push _test-slice-data-0/imm32/start 321 89/copy 3/mod/direct 1/rm32/ECX . . . 4/r32/ESP . . # copy ESP to ECX 322 # EAX = slice-equal?(ECX, "") 323 # . . push args @@ -409,8 +409,8 @@ if ('onhashchange' in window) { 347 55/push-EBP 348 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP 349 # var slice/ECX -350 68/push _test-slice-data-0/imm32/end -351 68/push _test-slice-data-0/imm32/start +350 68/push _test-slice-data-0/imm32/end +351 68/push _test-slice-data-0/imm32/start 352 89/copy 3/mod/direct 1/rm32/ECX . . . 4/r32/ESP . . # copy ESP to ECX 353 # EAX = slice-equal?(ECX, "") 354 # . . push args @@ -533,8 +533,8 @@ if ('onhashchange' in window) { 471 # . . discard args 472 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP 473 # var slice/ECX = "Abc" -474 68/push _test-slice-data-3/imm32/end -475 68/push _test-slice-data-0/imm32/start +474 68/push _test-slice-data-3/imm32/end +475 68/push _test-slice-data-0/imm32/start 476 89/copy 3/mod/direct 1/rm32/ECX . . . 4/r32/ESP . . # copy ESP to ECX 477 # write-slice(_test-buffered-file, slice) 478 # . . push args @@ -565,19 +565,128 @@ if ('onhashchange' in window) { 503 5d/pop-to-EBP 504 c3/return 505 -506 == data -507 -508 _test-slice-data-0: -509 41/A -510 _test-slice-data-1: -511 62/b -512 _test-slice-data-2: -513 63/c -514 _test-slice-data-3: -515 64/d -516 _test-slice-data-4: -517 -518 # . _. vim:nowrap:textwidth=0 +506 # write an entire stream's contents to a buffered-file +507 # ways to do this: +508 # - construct a 'maximal slice' and pass it to write-slice +509 # - flush the buffered-file and pass the stream directly to its fd (disabling buffering) +510 # we'll go with the first way for now +511 write-stream-buffered: # f : (address buffered-file), s : (address stream) +512 # . prolog +513 55/push-EBP +514 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP +515 # . save registers +516 50/push-EAX +517 56/push-ESI +518 # ESI = s +519 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 6/r32/ESI 0xc/disp8 . # copy *(EBP+12) to ESI +520 # var slice/ECX = {s->data, s->data + s->write} +521 # . push s->data + s->write +522 8b/copy 0/mod/indirect 6/rm32/ESI . . . 0/r32/EAX . . # copy *ESI to EAX +523 8d/copy-address 1/mod/*+disp8 4/rm32/sib 6/base/ESI 0/index/EAX . 0/r32/EAX 0xc/disp8 . # copy ESI+EAX+12 to EAX +524 50/push-EAX +525 # . push s->data +526 8d/copy-address 1/mod/*+disp8 6/rm32/ESI . . . 0/r32/EAX 0xc/disp8 . # copy ESI+12 to EAX +527 50/push-EAX +528 # . ECX = ESP +529 89/copy 3/mod/direct 1/rm32/ECX . . . 4/r32/ESP . . # copy ESP to ECX +530 # write-slice(f, slice) +531 # . . push args +532 51/push-ECX +533 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 . # push *(EBP+8) +534 # . . call +535 e8/call write-slice/disp32 +536 # . . discard args +537 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP +538 $write-stream-buffered:end: +539 # . restore registers +540 5e/pop-to-ESI +541 58/pop-to-EAX +542 # . epilog +543 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . . # copy EBP to ESP +544 5d/pop-to-EBP +545 c3/return +546 +547 test-write-stream-buffered: +548 # . prolog +549 55/push-EBP +550 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP +551 # setup +552 # . clear-stream(_test-stream) +553 # . . push args +554 68/push _test-stream/imm32 +555 # . . call +556 e8/call clear-stream/disp32 +557 # . . discard args +558 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP +559 # . clear-stream(_test-buffered-file+4) +560 # . . push args +561 b8/copy-to-EAX _test-buffered-file/imm32 +562 05/add-to-EAX 4/imm32 +563 50/push-EAX +564 # . . call +565 e8/call clear-stream/disp32 +566 # . . discard args +567 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP +568 # . clear-stream(_test-tmp-stream) +569 # . . push args +570 68/push _test-tmp-stream/imm32 +571 # . . call +572 e8/call clear-stream/disp32 +573 # . . discard args +574 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP +575 # initialize input +576 # . write(_test-tmp-stream, "abcd") +577 # . . push args +578 68/push "abcd"/imm32 +579 68/push _test-tmp-stream/imm32 +580 # . . call +581 e8/call write/disp32 +582 # . . discard args +583 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP +584 # perform the write-stream-buffered +585 # . write-stream-buffered(_test-buffered-file, _test-tmp-stream) +586 # . . push args +587 68/push _test-tmp-stream/imm32 +588 68/push _test-buffered-file/imm32 +589 # . . call +590 e8/call write-stream-buffered/disp32 +591 # . . discard args +592 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP +593 # check that the write happened as expected +594 # . flush(_test-buffered-file) +595 # . . push args +596 68/push _test-buffered-file/imm32 +597 # . . call +598 e8/call flush/disp32 +599 # . . discard args +600 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP +601 # . check-stream-equal(_test-stream, "abcd", msg) +602 # . . push args +603 68/push "F - test-write-stream-buffered"/imm32 +604 68/push "abcd"/imm32 +605 68/push _test-stream/imm32 +606 # . . call +607 e8/call check-stream-equal/disp32 +608 # . . discard args +609 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP +610 # . epilog +611 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . . # copy EBP to ESP +612 5d/pop-to-EBP +613 c3/return +614 +615 == data +616 +617 _test-slice-data-0: +618 41/A +619 _test-slice-data-1: +620 62/b +621 _test-slice-data-2: +622 63/c +623 _test-slice-data-3: +624 64/d +625 _test-slice-data-4: +626 +627 # . _. vim:nowrap:textwidth=0 -- cgit 1.4.1-2-gfad0