From e99038ea514a8703b170689d5a0730c8d2e542e7 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Mon, 18 Feb 2019 22:43:01 -0800 Subject: 4982 --- html/subx/055stream.subx.html | 122 ++++++++++++++++++++---------------------- 1 file changed, 57 insertions(+), 65 deletions(-) (limited to 'html/subx/055stream.subx.html') diff --git a/html/subx/055stream.subx.html b/html/subx/055stream.subx.html index e3e1e815..e339250c 100644 --- a/html/subx/055stream.subx.html +++ b/html/subx/055stream.subx.html @@ -18,7 +18,6 @@ a { color:inherit; } .Constant { color: #008787; } .LineNr { } .subxS1Comment { color: #0000af; } -.SpecialChar { color: #d70000; } .subxFunction { color: #af5f00; text-decoration: underline; } .Normal { color: #000000; background-color: #c6c6c6; padding-bottom: 1px; } .subxS2Comment { color: #8a8a8a; } @@ -73,70 +72,63 @@ if ('onhashchange' in window) { 14 # . op subop mod rm32 base index scale r32 15 # . 1-3 bytes 3 bits 2 bits 3 bits 3 bits 3 bits 2 bits 2 bits 0/1/2/4 bytes 0/1/2/4 bytes 16 -17 # main: -18 e8/call run-tests/disp32 # 'run-tests' is a function created automatically by SubX. It calls all functions that start with 'test-'. -19 # syscall(exit, Num-test-failures) -20 8b/copy 0/mod/indirect 5/rm32/.disp32 . . 3/r32/EBX Num-test-failures/disp32 # copy *Num-test-failures to EBX -21 b8/copy-to-EAX 1/imm32/exit -22 cd/syscall 0x80/imm8 -23 -24 clear-stream: # f : (address stream) -> <void> -25 # . prolog -26 55/push-EBP -27 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP -28 # . save registers -29 50/push-EAX -30 51/push-ECX -31 # EAX = f -32 8b/copy 1/mod/*+disp8 5/rm32/EBP . . 0/r32/EAX 8/disp8 . # copy *(EBP+8) to EAX -33 # ECX = f->length -34 8b/copy 1/mod/*+disp8 0/rm32/EAX . . . 1/r32/ECX 8/disp8 . # copy *(EAX+8) to ECX -35 # ECX = &f->data[f->length] -36 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/EAX 1/index/ECX . 1/r32/ECX 0xc/disp8 . # copy EAX+ECX+12 to ECX -37 # f->write = 0 -38 c7 0/subop/copy 0/mod/direct 0/rm32/EAX . . . . . 0/imm32 # copy to *EAX -39 # f->read = 0 -40 c7 0/subop/copy 1/mod/*+disp8 0/rm32/EAX . . . . 4/disp8 0/imm32 # copy to *(EAX+4) -41 # EAX = f->data -42 81 0/subop/add 3/mod/direct 0/rm32/EAX . . . . . 0xc/imm32 # add to EAX -43 # while (true) -44 $clear-stream:loop: -45 # if (EAX >= ECX) break -46 39/compare 3/mod/direct 0/rm32/EAX . . . 1/r32/ECX . . # compare EAX with ECX -47 7d/jump-if-greater-or-equal $clear-stream:end/disp8 -48 # *EAX = 0 -49 c6 0/subop/copy 0/mod/direct 0/rm32/EAX . . . . . 0/imm8 # copy byte to *EAX -50 # ++EAX -51 40/increment-EAX -52 eb/jump $clear-stream:loop/disp8 -53 $clear-stream:end: -54 # . restore registers -55 59/pop-to-ECX -56 58/pop-to-EAX -57 # . epilog -58 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . . # copy EBP to ESP -59 5d/pop-to-EBP -60 c3/return -61 -62 rewind-stream: # f : (address stream) -> <void> -63 # . prolog -64 55/push-EBP -65 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP -66 # . save registers -67 50/push-EAX -68 # EAX = f -69 8b/copy 1/mod/*+disp8 5/rm32/EBP . . 0/r32/EAX 8/disp8 . # copy *(EBP+8) to EAX -70 # f->read = 0 -71 c7 0/subop/copy 1/mod/*+disp8 0/rm32/EAX . . . . 4/disp8 0/imm32 # copy to *(EAX+4) -72 $rewind-stream:end: -73 # . restore registers -74 58/pop-to-EAX -75 # . epilog -76 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . . # copy EBP to ESP -77 5d/pop-to-EBP -78 c3/return -79 -80 # . . vim:nowrap:textwidth=0 +17 clear-stream: # f : (address stream) -> <void> +18 # . prolog +19 55/push-EBP +20 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP +21 # . save registers +22 50/push-EAX +23 51/push-ECX +24 # EAX = f +25 8b/copy 1/mod/*+disp8 5/rm32/EBP . . 0/r32/EAX 8/disp8 . # copy *(EBP+8) to EAX +26 # ECX = f->length +27 8b/copy 1/mod/*+disp8 0/rm32/EAX . . . 1/r32/ECX 8/disp8 . # copy *(EAX+8) to ECX +28 # ECX = &f->data[f->length] +29 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/EAX 1/index/ECX . 1/r32/ECX 0xc/disp8 . # copy EAX+ECX+12 to ECX +30 # f->write = 0 +31 c7 0/subop/copy 0/mod/direct 0/rm32/EAX . . . . . 0/imm32 # copy to *EAX +32 # f->read = 0 +33 c7 0/subop/copy 1/mod/*+disp8 0/rm32/EAX . . . . 4/disp8 0/imm32 # copy to *(EAX+4) +34 # EAX = f->data +35 81 0/subop/add 3/mod/direct 0/rm32/EAX . . . . . 0xc/imm32 # add to EAX +36 # while (true) +37 $clear-stream:loop: +38 # if (EAX >= ECX) break +39 39/compare 3/mod/direct 0/rm32/EAX . . . 1/r32/ECX . . # compare EAX with ECX +40 7d/jump-if-greater-or-equal $clear-stream:end/disp8 +41 # *EAX = 0 +42 c6 0/subop/copy 0/mod/direct 0/rm32/EAX . . . . . 0/imm8 # copy byte to *EAX +43 # ++EAX +44 40/increment-EAX +45 eb/jump $clear-stream:loop/disp8 +46 $clear-stream:end: +47 # . restore registers +48 59/pop-to-ECX +49 58/pop-to-EAX +50 # . epilog +51 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . . # copy EBP to ESP +52 5d/pop-to-EBP +53 c3/return +54 +55 rewind-stream: # f : (address stream) -> <void> +56 # . prolog +57 55/push-EBP +58 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP +59 # . save registers +60 50/push-EAX +61 # EAX = f +62 8b/copy 1/mod/*+disp8 5/rm32/EBP . . 0/r32/EAX 8/disp8 . # copy *(EBP+8) to EAX +63 # f->read = 0 +64 c7 0/subop/copy 1/mod/*+disp8 0/rm32/EAX . . . . 4/disp8 0/imm32 # copy to *(EAX+4) +65 $rewind-stream:end: +66 # . restore registers +67 58/pop-to-EAX +68 # . epilog +69 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . . # copy EBP to ESP +70 5d/pop-to-EBP +71 c3/return +72 +73 # . . vim:nowrap:textwidth=0 -- cgit 1.4.1-2-gfad0