From 9c1056f531217f3c1c12b3b3a648ca1cffe4beab Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Fri, 29 Mar 2019 00:47:30 -0700 Subject: 5033 --- html/subx/071read-line.subx.html | 547 ++++++++++++++++++--------------------- 1 file changed, 249 insertions(+), 298 deletions(-) (limited to 'html/subx/071read-line.subx.html') diff --git a/html/subx/071read-line.subx.html b/html/subx/071read-line.subx.html index 585446ee..557b130a 100644 --- a/html/subx/071read-line.subx.html +++ b/html/subx/071read-line.subx.html @@ -18,11 +18,12 @@ a { color:inherit; } .Constant { color: #008787; } .LineNr { } .subxS1Comment { color: #0000af; } -.SpecialChar { color: #d70000; } +.CommentedCode { color: #8a8a8a; } .subxFunction { color: #af5f00; text-decoration: underline; } .subxTest { color: #5f8700; } .Normal { color: #000000; background-color: #c6c6c6; padding-bottom: 1px; } .subxS2Comment { color: #8a8a8a; } +.SpecialChar { color: #d70000; } .subxH1Comment { color: #005faf; text-decoration: underline; } --> @@ -64,303 +65,253 @@ if ('onhashchange' in window) { 3 # . op subop mod rm32 base index scale r32 4 # . 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 5 - 6 # read bytes from 'f' until (and including) a newline and store them into 's' - 7 # return true if no data found, false otherwise - 8 # just abort if 's' is too small - 9 read-line: # f : (address buffered-file), s : (address stream byte) -> eof?/EAX - 10 # pseudocode: - 11 # loop: - 12 # if (s->write >= s->length) abort - 13 # if (f->read >= f->write) populate stream from file - 14 # if (f->write == 0) break - 15 # AL = f->data[f->read] - 16 # s->data[s->write] = AL - 17 # ++f->read - 18 # ++s->write - 19 # if (AL == '\n') break - 20 # . prolog - 21 55/push-EBP - 22 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP - 23 # . save registers - 24 51/push-ECX - 25 52/push-EDX - 26 56/push-ESI - 27 57/push-EDI - 28 # ESI = f - 29 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 6/r32/ESI 8/disp8 . # copy *(EBP+8) to ESI - 30 # ECX = f->read - 31 8b/copy 1/mod/*+disp8 6/rm32/ESI . . . 1/r32/ECX 8/disp8 . # copy *(ESI+8) to ECX - 32 # EDI = s - 33 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 7/r32/EDI 0xc/disp8 . # copy *(EBP+12) to EDI - 34 # EDX = s->write - 35 8b/copy 0/mod/indirect 7/rm32/EDI . . . 2/r32/EDX . . # copy *EDI to EDX - 36 $read-line:loop: - 37 # if (s->write >= s->length) abort - 38 3b/compare 1/mod/*+disp8 7/rm32/EDI . . . 2/r32/EDX 8/disp8 . # compare EDX with *(EDI+8) - 39 7d/jump-if-greater-or-equal $read-line:abort/disp8 - 40 # if (f->read >= f->write) populate stream from file - 41 3b/compare 1/mod/*+disp8 6/rm32/ESI . . . 1/r32/ECX 4/disp8 . # compare ECX with *(ESI+4) - 42 7c/jump-if-lesser $read-line:from-stream/disp8 - 43 # . clear-stream(stream = f+4) - 44 # . . push args - 45 8d/copy-address 1/mod/*+disp8 6/rm32/ESI . . . 0/r32/EAX 4/disp8 . # copy ESI+4 to EAX - 46 50/push-EAX - 47 # . . call - 48 e8/call clear-stream/disp32 - 49 # . . discard args - 50 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP - 51 # . f->read must now be 0; update its cache at ECX - 52 31/xor 3/mod/direct 1/rm32/ECX . . . 1/r32/ECX . . # clear ECX - 53 # . EAX = read(f->fd, stream = f+4) - 54 # . . push args - 55 50/push-EAX - 56 ff 6/subop/push 0/mod/indirect 6/rm32/ESI . . . . . . # push *ESI - 57 # . . call - 58 e8/call read/disp32 - 59 # . . discard args - 60 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP - 61 # if (f->write == 0) return true - 62 # since f->read was initially 0, EAX is the same as f->write - 63 # . if (EAX == 0) return true - 64 81 7/subop/compare 3/mod/direct 0/rm32/EAX . . . . . 0/imm32 # compare EAX - 65 75/jump-if-not-equal $read-line:from-stream/disp8 - 66 b8/copy-to-EAX 0xffffffff/imm32/Eof - 67 eb/jump $read-line:end/disp8 - 68 $read-line:from-stream: - 69 # AL = f->data[f->read] - 70 31/xor 3/mod/direct 0/rm32/EAX . . . 0/r32/EAX . . # clear EAX - 71 8a/copy-byte 1/mod/*+disp8 4/rm32/sib 6/base/ESI 1/index/ECX . 0/r32/AL 0x10/disp8 . # copy byte at *(ESI+ECX+16) to AL - 72 # s->data[s->write] = AL - 73 88/copy-byte 1/mod/*+disp8 4/rm32/sib 7/base/EDI 2/index/EDX . 0/r32/AL 0xc/disp8 . # copy AL to *(EDI+EDX+12) - 74 # ++f->read - 75 41/increment-ECX - 76 # ++s->write - 77 42/increment-EDX - 78 # if (AL == '\n') return false - 79 81 7/subop/compare 3/mod/direct 0/rm32/EAX . . . . . 0xa/imm32 # compare EAX - 80 75/jump-if-not-equal $read-line:loop/disp8 - 81 31/xor 3/mod/direct 0/rm32/EAX . . . 0/r32/EAX . . # clear EAX - 82 $read-line:end: - 83 # save f->read - 84 89/copy 1/mod/*+disp8 6/rm32/ESI . . . 1/r32/ECX 8/disp8 . # copy ECX to *(ESI+8) - 85 # save s->write - 86 89/copy 0/mod/indirect 7/rm32/EDI . . . 2/r32/EDX . . # copy EDX to *EDI - 87 # . restore registers - 88 5f/pop-to-EDI - 89 5e/pop-to-ESI - 90 5a/pop-to-EDX - 91 59/pop-to-ECX - 92 # . epilog - 93 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . . # copy EBP to ESP - 94 5d/pop-to-EBP - 95 c3/return - 96 - 97 $read-line:abort: - 98 # . _write(2/stderr, error) - 99 # . . push args -100 68/push "read-line: line too long"/imm32 -101 68/push 2/imm32/stderr -102 # . . call -103 e8/call _write/disp32 -104 # . . discard args -105 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP -106 # . syscall(exit, 1) -107 bb/copy-to-EBX 1/imm32 -108 b8/copy-to-EAX 1/imm32/exit -109 cd/syscall 0x80/imm8 -110 # never gets here -111 -112 test-read-line: -113 # - check that read-line stops at a newline -114 # setup -115 # . clear-stream(_test-stream) -116 # . . push args -117 68/push _test-stream/imm32 -118 # . . call -119 e8/call clear-stream/disp32 -120 # . . discard args -121 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP -122 # . clear-stream(_test-buffered-file+4) -123 # . . push args -124 b8/copy-to-EAX _test-buffered-file/imm32 -125 05/add-to-EAX 4/imm32 -126 50/push-EAX -127 # . . call -128 e8/call clear-stream/disp32 -129 # . . discard args -130 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP -131 # . clear-stream(_test-tmp-stream) -132 # . . push args -133 68/push _test-tmp-stream/imm32 -134 # . . call -135 e8/call clear-stream/disp32 -136 # . . discard args -137 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP -138 # write(_test-stream, "ab\ncd") -139 # . write(_test-stream, "ab") -140 # . . push args -141 68/push "ab"/imm32 -142 68/push _test-stream/imm32 -143 # . . call -144 e8/call write/disp32 -145 # . . discard args -146 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP -147 # . write(_test-stream, "\n") -148 # . . push args -149 68/push Newline/imm32 -150 68/push _test-stream/imm32 -151 # . . call -152 e8/call write/disp32 -153 # . . discard args -154 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP -155 # . write(_test-stream, "cd") -156 # . . push args -157 68/push "cd"/imm32 -158 68/push _test-stream/imm32 -159 # . . call -160 e8/call write/disp32 -161 # . . discard args -162 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP -163 # read a line from _test-stream (buffered by _test-buffered-file) into _test-tmp-stream -164 # . EAX = read-line(_test-buffered-file, _test-tmp-stream) -165 # . . push args -166 68/push _test-tmp-stream/imm32 -167 68/push _test-buffered-file/imm32 -168 # . . call -169 e8/call read-line/disp32 -170 # . . discard args -171 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP -172 # check-ints-equal(EAX, 0/not-at-Eof, msg) -173 # . . push args -174 68/push "F - test-read-line: return value"/imm32 -175 68/push 0/imm32/not-at-Eof -176 50/push-EAX -177 # . . call -178 e8/call check-ints-equal/disp32 -179 # . . discard args -180 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP -181 # check-next-stream-line-equal(_test-tmp-stream, "ab", msg) -182 # . . push args -183 68/push "F - test-read-line"/imm32 -184 68/push "ab"/imm32 -185 68/push _test-tmp-stream/imm32 -186 # . . call -187 e8/call check-next-stream-line-equal/disp32 -188 # . . discard args -189 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP -190 # end -191 c3/return -192 -193 test-read-line-returns-true-on-Eof: -194 # setup -195 # . clear-stream(_test-stream) -196 # . . push args -197 68/push _test-stream/imm32 -198 # . . call -199 e8/call clear-stream/disp32 -200 # . . discard args -201 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP -202 # . clear-stream(_test-buffered-file+4) -203 # . . push args -204 b8/copy-to-EAX _test-buffered-file/imm32 -205 05/add-to-EAX 4/imm32 -206 50/push-EAX -207 # . . call -208 e8/call clear-stream/disp32 -209 # . . discard args -210 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP -211 # . clear-stream(_test-tmp-stream) -212 # . . push args -213 68/push _test-tmp-stream/imm32 -214 # . . call -215 e8/call clear-stream/disp32 -216 # . . discard args -217 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP -218 # write nothing -219 # EAX = read-line(_test-buffered-file, _test-tmp-stream) -220 # . . push args -221 68/push _test-tmp-stream/imm32 -222 68/push _test-buffered-file/imm32 -223 # . . call -224 e8/call read-line/disp32 -225 # . . discard args -226 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP -227 # check-ints-equal(EAX, Eof, msg) -228 # . . push args -229 68/push "F - test-read-line-returns-true-on-Eof"/imm32 -230 68/push 0xffffffff/imm32/Eof -231 50/push-EAX -232 # . . call -233 e8/call check-ints-equal/disp32 -234 # . . discard args -235 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP -236 # end -237 c3/return -238 -239 test-read-line-reads-final-line-until-Eof: -240 # setup -241 # . clear-stream(_test-stream) -242 # . . push args -243 68/push _test-stream/imm32 -244 # . . call -245 e8/call clear-stream/disp32 -246 # . . discard args -247 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP -248 # . clear-stream(_test-buffered-file+4) -249 # . . push args -250 b8/copy-to-EAX _test-buffered-file/imm32 -251 05/add-to-EAX 4/imm32 -252 50/push-EAX -253 # . . call -254 e8/call clear-stream/disp32 -255 # . . discard args -256 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP -257 # . clear-stream(_test-tmp-stream) -258 # . . push args -259 68/push _test-tmp-stream/imm32 -260 # . . call -261 e8/call clear-stream/disp32 -262 # . . discard args -263 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP -264 # write(_test-stream, "cd") -265 # . . push args -266 68/push "cd"/imm32 -267 68/push _test-stream/imm32 -268 # . . call -269 e8/call write/disp32 -270 # . . discard args -271 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP -272 # read a line from _test-stream (buffered by _test-buffered-file) into _test-tmp-stream -273 # . EAX = read-line(_test-buffered-file, _test-tmp-stream) -274 # . . push args -275 68/push _test-tmp-stream/imm32 -276 68/push _test-buffered-file/imm32 -277 # . . call -278 e8/call read-line/disp32 -279 # . . discard args -280 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP -281 # check-ints-equal(EAX, Eof, msg) -282 # . . push args -283 68/push "F - test-read-line-reads-final-line-until-Eof: return value"/imm32 -284 68/push 0xffffffff/imm32/Eof -285 50/push-EAX -286 # . . call -287 e8/call check-ints-equal/disp32 -288 # . . discard args -289 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP -290 # check-stream-equal(_test-tmp-stream, "cd", msg) -291 # . . push args -292 68/push "F - test-read-line-reads-final-line-until-Eof"/imm32 -293 68/push "cd"/imm32 -294 68/push _test-tmp-stream/imm32 -295 # . . call -296 e8/call check-stream-equal/disp32 -297 # . . discard args -298 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP -299 # end -300 c3/return -301 -302 # . . vim:nowrap:textwidth=0 + 6 #? Entry: # run a single test, while debugging + 7 #? e8/call test-read-line/disp32 + 8 #? # syscall(exit, Num-test-failures) + 9 #? 8b/copy 0/mod/indirect 5/rm32/.disp32 . . 3/r32/EBX Num-test-failures/disp32 # copy *Num-test-failures to EBX + 10 #? b8/copy-to-EAX 1/imm32/exit + 11 #? cd/syscall 0x80/imm8 + 12 + 13 # read bytes from 'f' until (and including) a newline and store them into 's' + 14 # 's' fails to grow if and only if no data found + 15 # just abort if 's' is too small + 16 read-line: # f : (address buffered-file), s : (address stream byte) -> <void> + 17 # pseudocode: + 18 # while true + 19 # if (s->write >= s->length) abort + 20 # if (f->read >= f->write) populate stream from file + 21 # if (f->write == 0) break + 22 # AL = f->data[f->read] + 23 # s->data[s->write] = AL + 24 # ++f->read + 25 # ++s->write + 26 # if (AL == '\n') break + 27 # . prolog + 28 55/push-EBP + 29 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP + 30 # . save registers + 31 50/push-EAX + 32 51/push-ECX + 33 52/push-EDX + 34 56/push-ESI + 35 57/push-EDI + 36 # ESI = f + 37 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 6/r32/ESI 8/disp8 . # copy *(EBP+8) to ESI + 38 # ECX = f->read + 39 8b/copy 1/mod/*+disp8 6/rm32/ESI . . . 1/r32/ECX 8/disp8 . # copy *(ESI+8) to ECX + 40 # EDI = s + 41 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 7/r32/EDI 0xc/disp8 . # copy *(EBP+12) to EDI + 42 # EDX = s->write + 43 8b/copy 0/mod/indirect 7/rm32/EDI . . . 2/r32/EDX . . # copy *EDI to EDX + 44 $read-line:loop: + 45 # if (s->write >= s->length) abort + 46 3b/compare 1/mod/*+disp8 7/rm32/EDI . . . 2/r32/EDX 8/disp8 . # compare EDX with *(EDI+8) + 47 7d/jump-if-greater-or-equal $read-line:abort/disp8 + 48 # if (f->read >= f->write) populate stream from file + 49 3b/compare 1/mod/*+disp8 6/rm32/ESI . . . 1/r32/ECX 4/disp8 . # compare ECX with *(ESI+4) + 50 7c/jump-if-lesser $read-line:from-stream/disp8 + 51 # . clear-stream(stream = f+4) + 52 # . . push args + 53 8d/copy-address 1/mod/*+disp8 6/rm32/ESI . . . 0/r32/EAX 4/disp8 . # copy ESI+4 to EAX + 54 50/push-EAX + 55 # . . call + 56 e8/call clear-stream/disp32 + 57 # . . discard args + 58 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP + 59 # . f->read must now be 0; update its cache at ECX + 60 31/xor 3/mod/direct 1/rm32/ECX . . . 1/r32/ECX . . # clear ECX + 61 # . EAX = read(f->fd, stream = f+4) + 62 # . . push args + 63 50/push-EAX + 64 ff 6/subop/push 0/mod/indirect 6/rm32/ESI . . . . . . # push *ESI + 65 # . . call + 66 e8/call read/disp32 + 67 # . . discard args + 68 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + 69 # if (f->write == 0) break + 70 # since f->read was initially 0, EAX is the same as f->write + 71 # . if (EAX == 0) return true + 72 81 7/subop/compare 3/mod/direct 0/rm32/EAX . . . . . 0/imm32 # compare EAX + 73 74/jump-if-equal $read-line:end/disp8 + 74 $read-line:from-stream: + 75 # AL = f->data[f->read] + 76 31/xor 3/mod/direct 0/rm32/EAX . . . 0/r32/EAX . . # clear EAX + 77 8a/copy-byte 1/mod/*+disp8 4/rm32/sib 6/base/ESI 1/index/ECX . 0/r32/AL 0x10/disp8 . # copy byte at *(ESI+ECX+16) to AL + 78 # s->data[s->write] = AL + 79 88/copy-byte 1/mod/*+disp8 4/rm32/sib 7/base/EDI 2/index/EDX . 0/r32/AL 0xc/disp8 . # copy AL to *(EDI+EDX+12) + 80 # ++f->read + 81 41/increment-ECX + 82 # ++s->write + 83 42/increment-EDX + 84 # if (AL == '\n') return + 85 81 7/subop/compare 3/mod/direct 0/rm32/EAX . . . . . 0xa/imm32 # compare EAX + 86 75/jump-if-not-equal $read-line:loop/disp8 + 87 $read-line:end: + 88 # save f->read + 89 89/copy 1/mod/*+disp8 6/rm32/ESI . . . 1/r32/ECX 8/disp8 . # copy ECX to *(ESI+8) + 90 # save s->write + 91 89/copy 0/mod/indirect 7/rm32/EDI . . . 2/r32/EDX . . # copy EDX to *EDI + 92 # . restore registers + 93 5f/pop-to-EDI + 94 5e/pop-to-ESI + 95 5a/pop-to-EDX + 96 59/pop-to-ECX + 97 58/pop-to-EAX + 98 # . epilog + 99 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . . # copy EBP to ESP +100 5d/pop-to-EBP +101 c3/return +102 +103 $read-line:abort: +104 # . _write(2/stderr, error) +105 # . . push args +106 68/push "read-line: line too long"/imm32 +107 68/push 2/imm32/stderr +108 # . . call +109 e8/call _write/disp32 +110 # . . discard args +111 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP +112 # . _write(2/stderr, Newline) +113 # . . push args +114 68/push Newline/imm32 +115 68/push 2/imm32/stderr +116 # . . call +117 e8/call _write/disp32 +118 # . . discard args +119 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP +120 # . syscall(exit, 1) +121 bb/copy-to-EBX 1/imm32 +122 b8/copy-to-EAX 1/imm32/exit +123 cd/syscall 0x80/imm8 +124 # never gets here +125 +126 test-read-line: +127 # - check that read-line stops at a newline +128 # setup +129 # . clear-stream(_test-stream) +130 # . . push args +131 68/push _test-stream/imm32 +132 # . . call +133 e8/call clear-stream/disp32 +134 # . . discard args +135 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP +136 # . clear-stream(_test-buffered-file+4) +137 # . . push args +138 b8/copy-to-EAX _test-buffered-file/imm32 +139 05/add-to-EAX 4/imm32 +140 50/push-EAX +141 # . . call +142 e8/call clear-stream/disp32 +143 # . . discard args +144 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP +145 # . clear-stream(_test-tmp-stream) +146 # . . push args +147 68/push _test-tmp-stream/imm32 +148 # . . call +149 e8/call clear-stream/disp32 +150 # . . discard args +151 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP +152 # write(_test-stream, "ab\ncd") +153 # . write(_test-stream, "ab") +154 # . . push args +155 68/push "ab"/imm32 +156 68/push _test-stream/imm32 +157 # . . call +158 e8/call write/disp32 +159 # . . discard args +160 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP +161 # . write(_test-stream, "\n") +162 # . . push args +163 68/push Newline/imm32 +164 68/push _test-stream/imm32 +165 # . . call +166 e8/call write/disp32 +167 # . . discard args +168 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP +169 # . write(_test-stream, "cd") +170 # . . push args +171 68/push "cd"/imm32 +172 68/push _test-stream/imm32 +173 # . . call +174 e8/call write/disp32 +175 # . . discard args +176 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP +177 # read a line from _test-stream (buffered by _test-buffered-file) into _test-tmp-stream +178 # . EAX = read-line(_test-buffered-file, _test-tmp-stream) +179 # . . push args +180 68/push _test-tmp-stream/imm32 +181 68/push _test-buffered-file/imm32 +182 # . . call +183 e8/call read-line/disp32 +184 # . . discard args +185 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP +186 # check-next-stream-line-equal(_test-tmp-stream, "ab", msg) +187 # . . push args +188 68/push "F - test-read-line"/imm32 +189 68/push "ab"/imm32 +190 68/push _test-tmp-stream/imm32 +191 # . . call +192 e8/call check-next-stream-line-equal/disp32 +193 # . . discard args +194 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP +195 # end +196 c3/return +197 +198 test-read-line-reads-final-line-until-Eof: +199 # setup +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-tmp-stream) +217 # . . push args +218 68/push _test-tmp-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 # write(_test-stream, "cd") +224 # . . push args +225 68/push "cd"/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 # read a line from _test-stream (buffered by _test-buffered-file) into _test-tmp-stream +232 # . EAX = read-line(_test-buffered-file, _test-tmp-stream) +233 # . . push args +234 68/push _test-tmp-stream/imm32 +235 68/push _test-buffered-file/imm32 +236 # . . call +237 e8/call read-line/disp32 +238 # . . discard args +239 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP +240 # check-stream-equal(_test-tmp-stream, "cd", msg) +241 # . . push args +242 68/push "F - test-read-line-reads-final-line-until-Eof"/imm32 +243 68/push "cd"/imm32 +244 68/push _test-tmp-stream/imm32 +245 # . . call +246 e8/call check-stream-equal/disp32 +247 # . . discard args +248 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP +249 # end +250 c3/return +251 +252 # . . vim:nowrap:textwidth=0 -- cgit 1.4.1-2-gfad0