diff options
author | Kartik Agaram <vc@akkartik.com> | 2019-01-14 17:29:10 -0800 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2019-01-14 17:29:10 -0800 |
commit | 3f97166cf7360c1b8f607ba37bb350790e83101d (patch) | |
tree | 1a9e57b1c1a13a078474c8f85fd220fe4160e82b | |
parent | 509f0a12ca3d2061b1555ded31dead23f00ed854 (diff) | |
download | mu-3f97166cf7360c1b8f607ba37bb350790e83101d.tar.gz |
4927
-rw-r--r-- | html/subx/069slice.subx.html | 187 | ||||
-rw-r--r-- | subx/069slice.subx | 133 | ||||
-rwxr-xr-x | subx/apps/crenshaw2-1 | bin | 13826 -> 14065 bytes | |||
-rwxr-xr-x | subx/apps/crenshaw2-1b | bin | 14385 -> 14624 bytes | |||
-rwxr-xr-x | subx/apps/factorial | bin | 12744 -> 12983 bytes | |||
-rwxr-xr-x | subx/apps/handle | bin | 13537 -> 13776 bytes | |||
-rwxr-xr-x | subx/apps/hex | bin | 16805 -> 17044 bytes | |||
-rw-r--r-- | subx/apps/pack.subx | 25 |
8 files changed, 306 insertions, 39 deletions
diff --git a/html/subx/069slice.subx.html b/html/subx/069slice.subx.html index 498d891a..65930bd3 100644 --- a/html/subx/069slice.subx.html +++ b/html/subx/069slice.subx.html @@ -223,8 +223,8 @@ if ('onhashchange' in window) { <span id="L161" class="LineNr">161 </span> 55/push-EBP <span id="L162" class="LineNr">162 </span> 89/copy 3/mod/direct 5/rm32/EBP <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/ESP <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy ESP to EBP</span> <span id="L163" class="LineNr">163 </span> <span class="subxComment"># var slice/ECX</span> -<span id="L164" class="LineNr">164 </span> 68/push <a href='069slice.subx.html#L383'>_test-slice-data-3</a>/imm32/end -<span id="L165" class="LineNr">165 </span> 68/push <a href='069slice.subx.html#L377'>_test-slice-data-0</a>/imm32/start +<span id="L164" class="LineNr">164 </span> 68/push <a href='069slice.subx.html#L516'>_test-slice-data-3</a>/imm32/end +<span id="L165" class="LineNr">165 </span> 68/push <a href='069slice.subx.html#L510'>_test-slice-data-0</a>/imm32/start <span id="L166" class="LineNr">166 </span> 89/copy 3/mod/direct 1/rm32/ECX <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/ESP <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy ESP to ECX</span> <span id="L167" class="LineNr">167 </span> <span class="subxComment"># EAX = slice-equal?(ECX, "Abc")</span> <span id="L168" class="LineNr">168 </span> <span class="subxS2Comment"># . . push args</span> @@ -254,8 +254,8 @@ if ('onhashchange' in window) { <span id="L192" class="LineNr">192 </span> 55/push-EBP <span id="L193" class="LineNr">193 </span> 89/copy 3/mod/direct 5/rm32/EBP <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/ESP <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy ESP to EBP</span> <span id="L194" class="LineNr">194 </span> <span class="subxComment"># var slice/ECX</span> -<span id="L195" class="LineNr">195 </span> 68/push <a href='069slice.subx.html#L385'>_test-slice-data-4</a>/imm32/end -<span id="L196" class="LineNr">196 </span> 68/push <a href='069slice.subx.html#L379'>_test-slice-data-1</a>/imm32/start +<span id="L195" class="LineNr">195 </span> 68/push <a href='069slice.subx.html#L518'>_test-slice-data-4</a>/imm32/end +<span id="L196" class="LineNr">196 </span> 68/push <a href='069slice.subx.html#L512'>_test-slice-data-1</a>/imm32/start <span id="L197" class="LineNr">197 </span> 89/copy 3/mod/direct 1/rm32/ECX <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/ESP <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy ESP to ECX</span> <span id="L198" class="LineNr">198 </span> <span class="subxComment"># EAX = slice-equal?(ECX, "Abc")</span> <span id="L199" class="LineNr">199 </span> <span class="subxS2Comment"># . . push args</span> @@ -285,8 +285,8 @@ if ('onhashchange' in window) { <span id="L223" class="LineNr">223 </span> 55/push-EBP <span id="L224" class="LineNr">224 </span> 89/copy 3/mod/direct 5/rm32/EBP <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/ESP <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy ESP to EBP</span> <span id="L225" class="LineNr">225 </span> <span class="subxComment"># var slice/ECX</span> -<span id="L226" class="LineNr">226 </span> 68/push <a href='069slice.subx.html#L385'>_test-slice-data-4</a>/imm32/end -<span id="L227" class="LineNr">227 </span> 68/push <a href='069slice.subx.html#L377'>_test-slice-data-0</a>/imm32/start +<span id="L226" class="LineNr">226 </span> 68/push <a href='069slice.subx.html#L518'>_test-slice-data-4</a>/imm32/end +<span id="L227" class="LineNr">227 </span> 68/push <a href='069slice.subx.html#L510'>_test-slice-data-0</a>/imm32/start <span id="L228" class="LineNr">228 </span> 89/copy 3/mod/direct 1/rm32/ECX <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/ESP <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy ESP to ECX</span> <span id="L229" class="LineNr">229 </span> <span class="subxComment"># EAX = slice-equal?(ECX, "Abc")</span> <span id="L230" class="LineNr">230 </span> <span class="subxS2Comment"># . . push args</span> @@ -316,8 +316,8 @@ if ('onhashchange' in window) { <span id="L254" class="LineNr">254 </span> 55/push-EBP <span id="L255" class="LineNr">255 </span> 89/copy 3/mod/direct 5/rm32/EBP <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/ESP <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy ESP to EBP</span> <span id="L256" class="LineNr">256 </span> <span class="subxComment"># var slice/ECX</span> -<span id="L257" class="LineNr">257 </span> 68/push <a href='069slice.subx.html#L379'>_test-slice-data-1</a>/imm32/end -<span id="L258" class="LineNr">258 </span> 68/push <a href='069slice.subx.html#L377'>_test-slice-data-0</a>/imm32/start +<span id="L257" class="LineNr">257 </span> 68/push <a href='069slice.subx.html#L512'>_test-slice-data-1</a>/imm32/end +<span id="L258" class="LineNr">258 </span> 68/push <a href='069slice.subx.html#L510'>_test-slice-data-0</a>/imm32/start <span id="L259" class="LineNr">259 </span> 89/copy 3/mod/direct 1/rm32/ECX <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/ESP <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy ESP to ECX</span> <span id="L260" class="LineNr">260 </span> <span class="subxComment"># EAX = slice-equal?(ECX, "Abc")</span> <span id="L261" class="LineNr">261 </span> <span class="subxS2Comment"># . . push args</span> @@ -347,8 +347,8 @@ if ('onhashchange' in window) { <span id="L285" class="LineNr">285 </span> 55/push-EBP <span id="L286" class="LineNr">286 </span> 89/copy 3/mod/direct 5/rm32/EBP <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/ESP <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy ESP to EBP</span> <span id="L287" class="LineNr">287 </span> <span class="subxComment"># var slice/ECX</span> -<span id="L288" class="LineNr">288 </span> 68/push <a href='069slice.subx.html#L377'>_test-slice-data-0</a>/imm32/end -<span id="L289" class="LineNr">289 </span> 68/push <a href='069slice.subx.html#L377'>_test-slice-data-0</a>/imm32/start +<span id="L288" class="LineNr">288 </span> 68/push <a href='069slice.subx.html#L510'>_test-slice-data-0</a>/imm32/end +<span id="L289" class="LineNr">289 </span> 68/push <a href='069slice.subx.html#L510'>_test-slice-data-0</a>/imm32/start <span id="L290" class="LineNr">290 </span> 89/copy 3/mod/direct 1/rm32/ECX <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/ESP <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy ESP to ECX</span> <span id="L291" class="LineNr">291 </span> <span class="subxComment"># EAX = slice-equal?(ECX, "Abc")</span> <span id="L292" class="LineNr">292 </span> <span class="subxS2Comment"># . . push args</span> @@ -378,8 +378,8 @@ if ('onhashchange' in window) { <span id="L316" class="LineNr">316 </span> 55/push-EBP <span id="L317" class="LineNr">317 </span> 89/copy 3/mod/direct 5/rm32/EBP <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/ESP <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy ESP to EBP</span> <span id="L318" class="LineNr">318 </span> <span class="subxComment"># var slice/ECX</span> -<span id="L319" class="LineNr">319 </span> 68/push <a href='069slice.subx.html#L381'>_test-slice-data-2</a>/imm32/end -<span id="L320" class="LineNr">320 </span> 68/push <a href='069slice.subx.html#L377'>_test-slice-data-0</a>/imm32/start +<span id="L319" class="LineNr">319 </span> 68/push <a href='069slice.subx.html#L514'>_test-slice-data-2</a>/imm32/end +<span id="L320" class="LineNr">320 </span> 68/push <a href='069slice.subx.html#L510'>_test-slice-data-0</a>/imm32/start <span id="L321" class="LineNr">321 </span> 89/copy 3/mod/direct 1/rm32/ECX <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/ESP <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy ESP to ECX</span> <span id="L322" class="LineNr">322 </span> <span class="subxComment"># EAX = slice-equal?(ECX, "")</span> <span id="L323" class="LineNr">323 </span> <span class="subxS2Comment"># . . push args</span> @@ -409,8 +409,8 @@ if ('onhashchange' in window) { <span id="L347" class="LineNr">347 </span> 55/push-EBP <span id="L348" class="LineNr">348 </span> 89/copy 3/mod/direct 5/rm32/EBP <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/ESP <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy ESP to EBP</span> <span id="L349" class="LineNr">349 </span> <span class="subxComment"># var slice/ECX</span> -<span id="L350" class="LineNr">350 </span> 68/push <a href='069slice.subx.html#L377'>_test-slice-data-0</a>/imm32/end -<span id="L351" class="LineNr">351 </span> 68/push <a href='069slice.subx.html#L377'>_test-slice-data-0</a>/imm32/start +<span id="L350" class="LineNr">350 </span> 68/push <a href='069slice.subx.html#L510'>_test-slice-data-0</a>/imm32/end +<span id="L351" class="LineNr">351 </span> 68/push <a href='069slice.subx.html#L510'>_test-slice-data-0</a>/imm32/start <span id="L352" class="LineNr">352 </span> 89/copy 3/mod/direct 1/rm32/ECX <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/ESP <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy ESP to ECX</span> <span id="L353" class="LineNr">353 </span> <span class="subxComment"># EAX = slice-equal?(ECX, "")</span> <span id="L354" class="LineNr">354 </span> <span class="subxS2Comment"># . . push args</span> @@ -434,19 +434,152 @@ if ('onhashchange' in window) { <span id="L372" class="LineNr">372 </span> 5d/pop-to-EBP <span id="L373" class="LineNr">373 </span> c3/return <span id="L374" class="LineNr">374 </span> -<span id="L375" class="LineNr">375 </span>== data -<span id="L376" class="LineNr">376 </span> -<span id="L377" class="LineNr">377 </span><span class="subxMinorFunction">_test-slice-data-0</span>: -<span id="L378" class="LineNr">378 </span> 41/A -<span id="L379" class="LineNr">379 </span><span class="subxMinorFunction">_test-slice-data-1</span>: -<span id="L380" class="LineNr">380 </span> 62/b -<span id="L381" class="LineNr">381 </span><span class="subxMinorFunction">_test-slice-data-2</span>: -<span id="L382" class="LineNr">382 </span> 63/c -<span id="L383" class="LineNr">383 </span><span class="subxMinorFunction">_test-slice-data-3</span>: -<span id="L384" class="LineNr">384 </span> 64/d -<span id="L385" class="LineNr">385 </span><span class="subxMinorFunction">_test-slice-data-4</span>: -<span id="L386" class="LineNr">386 </span> -<span id="L387" class="LineNr">387 </span><span class="subxS1Comment"># . _. vim:nowrap:textwidth=0</span> +<span id="L375" class="LineNr">375 </span><span class="subxFunction">write-slice</span>: <span class="subxComment"># out : (address buffered-file), s : (address slice)</span> +<span id="L376" class="LineNr">376 </span> <span class="subxS1Comment"># . prolog</span> +<span id="L377" class="LineNr">377 </span> 55/push-EBP +<span id="L378" class="LineNr">378 </span> 89/copy 3/mod/direct 5/rm32/EBP <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/ESP <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy ESP to EBP</span> +<span id="L379" class="LineNr">379 </span> <span class="subxS1Comment"># . save registers</span> +<span id="L380" class="LineNr">380 </span> 50/push-EAX +<span id="L381" class="LineNr">381 </span> 51/push-ECX +<span id="L382" class="LineNr">382 </span> 52/push-EDX +<span id="L383" class="LineNr">383 </span> 53/push-EBX +<span id="L384" class="LineNr">384 </span> 56/push-ESI +<span id="L385" class="LineNr">385 </span> 57/push-EDI +<span id="L386" class="LineNr">386 </span> <span class="subxComment"># ESI = s</span> +<span id="L387" class="LineNr">387 </span> 8b/copy 1/mod/*+disp8 5/rm32/EBP <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 6/r32/ESI 0xc/disp8 <span class="Normal"> . </span> <span class="subxComment"># copy *(EBP+12) to ESI</span> +<span id="L388" class="LineNr">388 </span> <span class="subxComment"># curr/ECX = s->start</span> +<span id="L389" class="LineNr">389 </span> 8b/copy 0/mod/indirect 6/rm32/ESI <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 1/r32/ECX <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy *ESI to ECX</span> +<span id="L390" class="LineNr">390 </span> <span class="subxComment"># max/ESI = s->end</span> +<span id="L391" class="LineNr">391 </span> 8b/copy 1/mod/*+disp8 6/rm32/ESI <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 6/r32/ESI 4/disp8 <span class="Normal"> . </span> <span class="subxComment"># copy *(ESI+4) to ESI</span> +<span id="L392" class="LineNr">392 </span> <span class="subxComment"># EDI = f</span> +<span id="L393" class="LineNr">393 </span> 8b/copy 1/mod/*+disp8 5/rm32/EBP <span class="Normal"> . </span> <span class="Normal"> . </span> 7/r32/EDI 8/disp8 <span class="Normal"> . </span> <span class="subxComment"># copy *(EBP+8) to EDI</span> +<span id="L394" class="LineNr">394 </span> <span class="subxComment"># EDX = f->length</span> +<span id="L395" class="LineNr">395 </span> 8b/copy 1/mod/*+disp8 7/rm32/EDI <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 2/r32/EDX 0xc/disp8 <span class="Normal"> . </span> <span class="subxComment"># copy *(EDI+12) to EDX</span> +<span id="L396" class="LineNr">396 </span> <span class="subxComment"># EBX = f->write</span> +<span id="L397" class="LineNr">397 </span> 8b/copy 1/mod/*+disp8 7/rm32/EDI <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 3/r32/EBX 4/disp8 <span class="Normal"> . </span> <span class="subxComment"># copy *(EDI+4) to EBX</span> +<span id="L398" class="LineNr">398 </span><span class="Constant">$write-slice:loop</span>: +<span id="L399" class="LineNr">399 </span> <span class="subxComment"># if (curr >= max) break</span> +<span id="L400" class="LineNr">400 </span> 39/compare 3/mod/direct 1/rm32/ECX <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 6/r32/ESI <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># compare ECX with ESI</span> +<span id="L401" class="LineNr">401 </span> 7d/jump-if-greater-or-equal $write-slice:loop-end/disp8 +<span id="L402" class="LineNr">402 </span> <span class="subxComment"># if (f->write >= f->length) flush and clear f's stream</span> +<span id="L403" class="LineNr">403 </span> 39/compare 3/mod/direct 3/rm32/EBX <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 2/r32/EDX <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># compare EBX with EDX</span> +<span id="L404" class="LineNr">404 </span> 7c/jump-if-lesser $write-slice:to-stream/disp8 +<span id="L405" class="LineNr">405 </span> <span class="subxS1Comment"># . persist f->write</span> +<span id="L406" class="LineNr">406 </span> 89/copy 1/mod/*+disp8 7/rm32/EDI <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 3/r32/EBX 4/disp8 <span class="Normal"> . </span> <span class="subxComment"># copy EBX to *(EDI+4)</span> +<span id="L407" class="LineNr">407 </span> <span class="subxS1Comment"># . flush(f)</span> +<span id="L408" class="LineNr">408 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L409" class="LineNr">409 </span> 57/push-EDI +<span id="L410" class="LineNr">410 </span> <span class="subxS2Comment"># . . call</span> +<span id="L411" class="LineNr">411 </span> e8/call <a href='062write-byte.subx.html#L86'>flush</a>/disp32 +<span id="L412" class="LineNr">412 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L413" class="LineNr">413 </span> 81 0/subop/add 3/mod/direct 4/rm32/ESP <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/imm32 <span class="subxComment"># add to ESP</span> +<span id="L414" class="LineNr">414 </span> <span class="subxS1Comment"># . clear-stream(stream = f+4)</span> +<span id="L415" class="LineNr">415 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L416" class="LineNr">416 </span> 8d/copy-address 1/mod/*+disp8 7/rm32/EDI <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0/r32/EAX 4/disp8 <span class="Normal"> . </span> <span class="subxComment"># copy EDI+4 to EAX</span> +<span id="L417" class="LineNr">417 </span> 50/push-EAX +<span id="L418" class="LineNr">418 </span> <span class="subxS2Comment"># . . call</span> +<span id="L419" class="LineNr">419 </span> e8/call <a href='056write.subx.html#L85'>clear-stream</a>/disp32 +<span id="L420" class="LineNr">420 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L421" class="LineNr">421 </span> 81 0/subop/add 3/mod/direct 4/rm32/ESP <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/imm32 <span class="subxComment"># add to ESP</span> +<span id="L422" class="LineNr">422 </span> <span class="subxS1Comment"># . f->write must now be 0; update its cache at EBX</span> +<span id="L423" class="LineNr">423 </span> 31/xor 3/mod/direct 3/rm32/EBX <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 3/r32/EBX <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># clear EBX</span> +<span id="L424" class="LineNr">424 </span><span class="Constant">$write-slice:to-stream</span>: +<span id="L425" class="LineNr">425 </span> <span class="subxComment"># f->data[f->write] = *in</span> +<span id="L426" class="LineNr">426 </span> <span class="subxS1Comment"># . AL = *in</span> +<span id="L427" class="LineNr">427 </span> 31/xor 3/mod/direct 0/rm32/EAX <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0/r32/EAX <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># clear EAX</span> +<span id="L428" class="LineNr">428 </span> 8a/copy-byte 0/mod/indirect 1/rm32/ECX <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0/r32/AL <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy byte at *ECX to AL</span> +<span id="L429" class="LineNr">429 </span> <span class="subxS1Comment"># . f->data[f->write] = AL</span> +<span id="L430" class="LineNr">430 </span> 88/copy-byte 1/mod/*+disp8 4/rm32/sib 7/base/EDI 3/index/EBX <span class="Normal"> . </span> 0/r32/AL 0x10/disp8 <span class="Normal"> . </span> <span class="subxComment"># copy AL to *(EDI+EBX+16)</span> +<span id="L431" class="LineNr">431 </span> <span class="subxComment"># ++f->write</span> +<span id="L432" class="LineNr">432 </span> 43/increment-EBX +<span id="L433" class="LineNr">433 </span> <span class="subxComment"># ++in</span> +<span id="L434" class="LineNr">434 </span> 41/increment-ECX +<span id="L435" class="LineNr">435 </span> eb/jump $write-slice:loop/disp8 +<span id="L436" class="LineNr">436 </span><span class="Constant">$write-slice:loop-end</span>: +<span id="L437" class="LineNr">437 </span> <span class="subxComment"># persist necessary variables from registers</span> +<span id="L438" class="LineNr">438 </span> 89/copy 1/mod/*+disp8 7/rm32/EDI <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 3/r32/EBX 4/disp8 <span class="Normal"> . </span> <span class="subxComment"># copy EBX to *(EDI+4)</span> +<span id="L439" class="LineNr">439 </span><span class="Constant">$write-slice:end</span>: +<span id="L440" class="LineNr">440 </span> <span class="subxS1Comment"># . restore registers</span> +<span id="L441" class="LineNr">441 </span> 5f/pop-to-EDI +<span id="L442" class="LineNr">442 </span> 5e/pop-to-ESI +<span id="L443" class="LineNr">443 </span> 5b/pop-to-EBX +<span id="L444" class="LineNr">444 </span> 5a/pop-to-EDX +<span id="L445" class="LineNr">445 </span> 59/pop-to-ECX +<span id="L446" class="LineNr">446 </span> 58/pop-to-EAX +<span id="L447" class="LineNr">447 </span> <span class="subxS1Comment"># . epilog</span> +<span id="L448" class="LineNr">448 </span> 89/copy 3/mod/direct 4/rm32/ESP <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 5/r32/EBP <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy EBP to ESP</span> +<span id="L449" class="LineNr">449 </span> 5d/pop-to-EBP +<span id="L450" class="LineNr">450 </span> c3/return +<span id="L451" class="LineNr">451 </span> +<span id="L452" class="LineNr">452 </span><span class="subxTest">test-write-slice</span>: +<span id="L453" class="LineNr">453 </span> <span class="subxS1Comment"># . prolog</span> +<span id="L454" class="LineNr">454 </span> 55/push-EBP +<span id="L455" class="LineNr">455 </span> 89/copy 3/mod/direct 5/rm32/EBP <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/ESP <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy ESP to EBP</span> +<span id="L456" class="LineNr">456 </span> <span class="subxComment"># setup</span> +<span id="L457" class="LineNr">457 </span> <span class="subxS1Comment"># . clear-stream(_test-stream)</span> +<span id="L458" class="LineNr">458 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L459" class="LineNr">459 </span> 68/push <a href='056write.subx.html#L193'>_test-stream</a>/imm32 +<span id="L460" class="LineNr">460 </span> <span class="subxS2Comment"># . . call</span> +<span id="L461" class="LineNr">461 </span> e8/call <a href='056write.subx.html#L85'>clear-stream</a>/disp32 +<span id="L462" class="LineNr">462 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L463" class="LineNr">463 </span> 81 0/subop/add 3/mod/direct 4/rm32/ESP <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/imm32 <span class="subxComment"># add to ESP</span> +<span id="L464" class="LineNr">464 </span> <span class="subxS1Comment"># . clear-stream(_test-buffered-file+4)</span> +<span id="L465" class="LineNr">465 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L466" class="LineNr">466 </span> b8/copy-to-EAX <a href='059read-byte.subx.html#L290'>_test-buffered-file</a>/imm32 +<span id="L467" class="LineNr">467 </span> 05/add-to-EAX 4/imm32 +<span id="L468" class="LineNr">468 </span> 50/push-EAX +<span id="L469" class="LineNr">469 </span> <span class="subxS2Comment"># . . call</span> +<span id="L470" class="LineNr">470 </span> e8/call <a href='056write.subx.html#L85'>clear-stream</a>/disp32 +<span id="L471" class="LineNr">471 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L472" class="LineNr">472 </span> 81 0/subop/add 3/mod/direct 4/rm32/ESP <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/imm32 <span class="subxComment"># add to ESP</span> +<span id="L473" class="LineNr">473 </span> <span class="subxComment"># var slice/ECX = "Abc"</span> +<span id="L474" class="LineNr">474 </span> 68/push <a href='069slice.subx.html#L516'>_test-slice-data-3</a>/imm32/end +<span id="L475" class="LineNr">475 </span> 68/push <a href='069slice.subx.html#L510'>_test-slice-data-0</a>/imm32/start +<span id="L476" class="LineNr">476 </span> 89/copy 3/mod/direct 1/rm32/ECX <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/r32/ESP <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy ESP to ECX</span> +<span id="L477" class="LineNr">477 </span> <span class="subxComment"># write-slice(_test-buffered-file, slice)</span> +<span id="L478" class="LineNr">478 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L479" class="LineNr">479 </span> 51/push-ECX +<span id="L480" class="LineNr">480 </span> 68/push <a href='059read-byte.subx.html#L290'>_test-buffered-file</a>/imm32 +<span id="L481" class="LineNr">481 </span> <span class="subxS2Comment"># . . call</span> +<span id="L482" class="LineNr">482 </span> e8/call <a href='069slice.subx.html#L375'>write-slice</a>/disp32 +<span id="L483" class="LineNr">483 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L484" class="LineNr">484 </span> 81 0/subop/add 3/mod/direct 4/rm32/ESP <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 8/imm32 <span class="subxComment"># add to ESP</span> +<span id="L485" class="LineNr">485 </span> <span class="subxComment"># flush(_test-buffered-file)</span> +<span id="L486" class="LineNr">486 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L487" class="LineNr">487 </span> 68/push <a href='059read-byte.subx.html#L290'>_test-buffered-file</a>/imm32 +<span id="L488" class="LineNr">488 </span> <span class="subxS2Comment"># . . call</span> +<span id="L489" class="LineNr">489 </span> e8/call <a href='062write-byte.subx.html#L86'>flush</a>/disp32 +<span id="L490" class="LineNr">490 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L491" class="LineNr">491 </span> 81 0/subop/add 3/mod/direct 4/rm32/ESP <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 4/imm32 <span class="subxComment"># add to ESP</span> +<span id="L492" class="LineNr">492 </span> <span class="subxComment"># check-ints-equal(*_test-stream->data, "Abc", msg)</span> +<span id="L493" class="LineNr">493 </span> <span class="subxS2Comment"># . . push args</span> +<span id="L494" class="LineNr">494 </span> 68/push <span class="Constant">"F - test-write-slice"</span>/imm32 +<span id="L495" class="LineNr">495 </span> 68/push 0x636241/imm32 +<span id="L496" class="LineNr">496 </span> <span class="subxS2Comment"># . . push *_test-stream->data</span> +<span id="L497" class="LineNr">497 </span> b8/copy-to-EAX <a href='056write.subx.html#L193'>_test-stream</a>/imm32 +<span id="L498" class="LineNr">498 </span> ff 6/subop/push 1/mod/*+disp8 0/rm32/EAX <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0xc/disp8 <span class="Normal"> . </span> <span class="subxComment"># push *(EAX+12)</span> +<span id="L499" class="LineNr">499 </span> <span class="subxS2Comment"># . . call</span> +<span id="L500" class="LineNr">500 </span> e8/call <a href='051test.subx.html#L24'>check-ints-equal</a>/disp32 +<span id="L501" class="LineNr">501 </span> <span class="subxS2Comment"># . . discard args</span> +<span id="L502" class="LineNr">502 </span> 81 0/subop/add 3/mod/direct 4/rm32/ESP <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0xc/imm32 <span class="subxComment"># add to ESP</span> +<span id="L503" class="LineNr">503 </span> <span class="subxS1Comment"># . epilog</span> +<span id="L504" class="LineNr">504 </span> 89/copy 3/mod/direct 4/rm32/ESP <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 5/r32/EBP <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="subxComment"># copy EBP to ESP</span> +<span id="L505" class="LineNr">505 </span> 5d/pop-to-EBP +<span id="L506" class="LineNr">506 </span> c3/return +<span id="L507" class="LineNr">507 </span> +<span id="L508" class="LineNr">508 </span>== data +<span id="L509" class="LineNr">509 </span> +<span id="L510" class="LineNr">510 </span><span class="subxMinorFunction">_test-slice-data-0</span>: +<span id="L511" class="LineNr">511 </span> 41/A +<span id="L512" class="LineNr">512 </span><span class="subxMinorFunction">_test-slice-data-1</span>: +<span id="L513" class="LineNr">513 </span> 62/b +<span id="L514" class="LineNr">514 </span><span class="subxMinorFunction">_test-slice-data-2</span>: +<span id="L515" class="LineNr">515 </span> 63/c +<span id="L516" class="LineNr">516 </span><span class="subxMinorFunction">_test-slice-data-3</span>: +<span id="L517" class="LineNr">517 </span> 64/d +<span id="L518" class="LineNr">518 </span><span class="subxMinorFunction">_test-slice-data-4</span>: +<span id="L519" class="LineNr">519 </span> +<span id="L520" class="LineNr">520 </span><span class="subxS1Comment"># . _. vim:nowrap:textwidth=0</span> </pre> </body> </html> diff --git a/subx/069slice.subx b/subx/069slice.subx index a652ed4d..7be920ec 100644 --- a/subx/069slice.subx +++ b/subx/069slice.subx @@ -372,6 +372,139 @@ test-slice-equal-empty-with-empty: 5d/pop-to-EBP c3/return +write-slice: # out : (address buffered-file), s : (address slice) + # . prolog + 55/push-EBP + 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP + # . save registers + 50/push-EAX + 51/push-ECX + 52/push-EDX + 53/push-EBX + 56/push-ESI + 57/push-EDI + # ESI = s + 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 6/r32/ESI 0xc/disp8 . # copy *(EBP+12) to ESI + # curr/ECX = s->start + 8b/copy 0/mod/indirect 6/rm32/ESI . . . 1/r32/ECX . . # copy *ESI to ECX + # max/ESI = s->end + 8b/copy 1/mod/*+disp8 6/rm32/ESI . . . 6/r32/ESI 4/disp8 . # copy *(ESI+4) to ESI + # EDI = f + 8b/copy 1/mod/*+disp8 5/rm32/EBP . . 7/r32/EDI 8/disp8 . # copy *(EBP+8) to EDI + # EDX = f->length + 8b/copy 1/mod/*+disp8 7/rm32/EDI . . . 2/r32/EDX 0xc/disp8 . # copy *(EDI+12) to EDX + # EBX = f->write + 8b/copy 1/mod/*+disp8 7/rm32/EDI . . . 3/r32/EBX 4/disp8 . # copy *(EDI+4) to EBX +$write-slice:loop: + # if (curr >= max) break + 39/compare 3/mod/direct 1/rm32/ECX . . . 6/r32/ESI . . # compare ECX with ESI + 7d/jump-if-greater-or-equal $write-slice:loop-end/disp8 + # if (f->write >= f->length) flush and clear f's stream + 39/compare 3/mod/direct 3/rm32/EBX . . . 2/r32/EDX . . # compare EBX with EDX + 7c/jump-if-lesser $write-slice:to-stream/disp8 + # . persist f->write + 89/copy 1/mod/*+disp8 7/rm32/EDI . . . 3/r32/EBX 4/disp8 . # copy EBX to *(EDI+4) + # . flush(f) + # . . push args + 57/push-EDI + # . . call + e8/call flush/disp32 + # . . discard args + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP + # . clear-stream(stream = f+4) + # . . push args + 8d/copy-address 1/mod/*+disp8 7/rm32/EDI . . . 0/r32/EAX 4/disp8 . # copy EDI+4 to EAX + 50/push-EAX + # . . call + e8/call clear-stream/disp32 + # . . discard args + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP + # . f->write must now be 0; update its cache at EBX + 31/xor 3/mod/direct 3/rm32/EBX . . . 3/r32/EBX . . # clear EBX +$write-slice:to-stream: + # f->data[f->write] = *in + # . AL = *in + 31/xor 3/mod/direct 0/rm32/EAX . . . 0/r32/EAX . . # clear EAX + 8a/copy-byte 0/mod/indirect 1/rm32/ECX . . . 0/r32/AL . . # copy byte at *ECX to AL + # . f->data[f->write] = AL + 88/copy-byte 1/mod/*+disp8 4/rm32/sib 7/base/EDI 3/index/EBX . 0/r32/AL 0x10/disp8 . # copy AL to *(EDI+EBX+16) + # ++f->write + 43/increment-EBX + # ++in + 41/increment-ECX + eb/jump $write-slice:loop/disp8 +$write-slice:loop-end: + # persist necessary variables from registers + 89/copy 1/mod/*+disp8 7/rm32/EDI . . . 3/r32/EBX 4/disp8 . # copy EBX to *(EDI+4) +$write-slice:end: + # . restore registers + 5f/pop-to-EDI + 5e/pop-to-ESI + 5b/pop-to-EBX + 5a/pop-to-EDX + 59/pop-to-ECX + 58/pop-to-EAX + # . epilog + 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . . # copy EBP to ESP + 5d/pop-to-EBP + c3/return + +test-write-slice: + # . prolog + 55/push-EBP + 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . . # copy ESP to EBP + # setup + # . clear-stream(_test-stream) + # . . push args + 68/push _test-stream/imm32 + # . . call + e8/call clear-stream/disp32 + # . . discard args + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP + # . clear-stream(_test-buffered-file+4) + # . . push args + b8/copy-to-EAX _test-buffered-file/imm32 + 05/add-to-EAX 4/imm32 + 50/push-EAX + # . . call + e8/call clear-stream/disp32 + # . . discard args + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP + # var slice/ECX = "Abc" + 68/push _test-slice-data-3/imm32/end + 68/push _test-slice-data-0/imm32/start + 89/copy 3/mod/direct 1/rm32/ECX . . . 4/r32/ESP . . # copy ESP to ECX + # write-slice(_test-buffered-file, slice) + # . . push args + 51/push-ECX + 68/push _test-buffered-file/imm32 + # . . call + e8/call write-slice/disp32 + # . . discard args + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32 # add to ESP + # flush(_test-buffered-file) + # . . push args + 68/push _test-buffered-file/imm32 + # . . call + e8/call flush/disp32 + # . . discard args + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32 # add to ESP + # check-ints-equal(*_test-stream->data, "Abc", msg) + # . . push args + 68/push "F - test-write-slice"/imm32 + 68/push 0x636241/imm32 + # . . push *_test-stream->data + b8/copy-to-EAX _test-stream/imm32 + ff 6/subop/push 1/mod/*+disp8 0/rm32/EAX . . . . 0xc/disp8 . # push *(EAX+12) + # . . call + e8/call check-ints-equal/disp32 + # . . discard args + 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32 # add to ESP + # . epilog + 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . . # copy EBP to ESP + 5d/pop-to-EBP + c3/return + == data _test-slice-data-0: diff --git a/subx/apps/crenshaw2-1 b/subx/apps/crenshaw2-1 index 525d4983..614fa178 100755 --- a/subx/apps/crenshaw2-1 +++ b/subx/apps/crenshaw2-1 Binary files differdiff --git a/subx/apps/crenshaw2-1b b/subx/apps/crenshaw2-1b index 2b040406..633bc760 100755 --- a/subx/apps/crenshaw2-1b +++ b/subx/apps/crenshaw2-1b Binary files differdiff --git a/subx/apps/factorial b/subx/apps/factorial index 924ce4bc..0126f320 100755 --- a/subx/apps/factorial +++ b/subx/apps/factorial Binary files differdiff --git a/subx/apps/handle b/subx/apps/handle index 5cbed69e..b2b4b70c 100755 --- a/subx/apps/handle +++ b/subx/apps/handle Binary files differdiff --git a/subx/apps/hex b/subx/apps/hex index 2cca804f..1ef41c17 100755 --- a/subx/apps/hex +++ b/subx/apps/hex Binary files differdiff --git a/subx/apps/pack.subx b/subx/apps/pack.subx index b2b7a32a..5cd693b8 100644 --- a/subx/apps/pack.subx +++ b/subx/apps/pack.subx @@ -78,28 +78,28 @@ $main:end: # - To pack an instruction, following the C++ version: # read line # parse words -# read first word as opcode and emit -# if 0f or f2 or f3 read second opcode and emit -# if 'f2 0f' or 'f3 0f' read third opcode and emit +# read first word as opcode and write-slice +# if 0f or f2 or f3 read second opcode and write-slice +# if 'f2 0f' or 'f3 0f' read third opcode and write-slice # scan words # if has metadata 'mod', parse into mod # if has metadata 'rm32', parse into rm32 # if has metadata 'r32', parse into r32 # if has metadata 'subop', parse into r32 -# if at least one of the 3 was present, emit modrm byte +# if at least one of the 3 was present, print-byte # scan words # if has metadata 'base', parse into base # if has metadata 'index', parse into index # if has metadata 'scale', parse into scale -# if at least one of the 3 was present, emit sib byte +# if at least one of the 3 was present, print-byte # parse errors => <abort> # scan words -# if has metadata 'disp8', emit-maybe -# if has metadata 'disp16', emit-maybe as 2 bytes -# if has metadata 'disp32', emit-maybe as 4 bytes +# if has metadata 'disp8', emit as 1 byte +# if has metadata 'disp16', emit as 2 bytes +# if has metadata 'disp32', emit as 4 bytes # scan words -# if has metadata 'imm8', emit-maybe -# if has metadata 'imm32', emit-maybe as 4 bytes +# if has metadata 'imm8', emit +# if has metadata 'imm32', emit as 4 bytes # finally, emit line prefixed with a ' # ' # simplifications since we perform zero error handling (continuing to rely on the C++ version for that): @@ -121,8 +121,9 @@ $main:end: # slice-equal?(slice, kernel string) # helpers: -# emit-maybe(out : &buffered-file, n : int, width : int) -# emit(out : &buffered-file, word : &slice) +# emit(out : &buffered-file, word : &slice, width : int) +# if slice is all hex digits, parse and print appropriate digits +# otherwise just write-slice # has-metadata?(word : &slice, s : &kernel-string) -> bool convert: # in : (address buffered-file), out : (address buffered-file), err : (address buffered-file), ed : (address exit-descriptor) -> <void> |