about summary refs log tree commit diff stats
path: root/subx
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2019-06-05 19:30:31 -0700
committerKartik Agaram <vc@akkartik.com>2019-06-05 19:32:45 -0700
commit43f1c41dbed3517a277253383448817f9a3d5556 (patch)
treeab45d49c750d05b84263c61c3b09b99bf60d8df4 /subx
parent965dd1bf56253d4b6104a2f57b48d06f6287fe31 (diff)
downloadmu-43f1c41dbed3517a277253383448817f9a3d5556.tar.gz
start fleshing out trace support some more
I think the path to readable tests for survey.subx passes through
white-box tests.
Diffstat (limited to 'subx')
-rw-r--r--subx/056trace.subx28
-rwxr-xr-xsubx/apps/assortbin24081 -> 24092 bytes
-rwxr-xr-xsubx/apps/crenshaw2-1bin21308 -> 21319 bytes
-rwxr-xr-xsubx/apps/crenshaw2-1bbin21867 -> 21878 bytes
-rwxr-xr-xsubx/apps/factorialbin20224 -> 20235 bytes
-rwxr-xr-xsubx/apps/handlebin21030 -> 21041 bytes
-rwxr-xr-xsubx/apps/hexbin24317 -> 24328 bytes
-rwxr-xr-xsubx/apps/packbin39732 -> 39743 bytes
8 files changed, 23 insertions, 5 deletions
diff --git a/subx/056trace.subx b/subx/056trace.subx
index cedc512a..2e483bad 100644
--- a/subx/056trace.subx
+++ b/subx/056trace.subx
@@ -43,18 +43,36 @@ _test-trace-stream:
 
 # Allocate a new segment for the trace stream, initialize its length, and save its address to Trace-stream.
 # The Trace-stream segment will consist of variable-length lines separated by newlines (0x0a)
-initialize-trace-stream:
-    # EAX = new-segment(0x1000)
+initialize-trace-stream:  # n : int -> <void>
+    # . 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
+    # ECX = n
+    8b/copy                         1/mod/*+disp8   5/rm32/EBP    .           .             .           1/r32/ECX   8/disp8         .                 # copy *(EBP+8) to ECX
+    # EAX = new-segment(n)
     # . . push args
-    68/push  0x1000/imm32/N
+    51/push-ECX
     # . . call
     e8/call  new-segment/disp32
     # . . discard args
     81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add to ESP
     # copy EAX to *Trace-stream
     89/copy                         0/mod/indirect  5/rm32/.disp32            .             .           0/r32/EAX   Trace-stream/disp32               # copy EAX to *Trace-stream
-    # Trace-stream->length = 0x1000/N - 12
-    c7          0/subop/copy        1/mod/*+disp8   0/rm32/EAX    .           .             .           .           8/disp8         0xff4/imm32       # copy 0xff4 to *(EAX+8)
+    # Trace-stream->length = n - 12
+    # . ECX -= 12
+    81          5/subop/subtract    3/mod/direct    1/rm32/ECX    .           .             .           .           .               0xc/imm32         # subtract from ECX
+    # . Trace-stream->length = ECX
+    89/copy                         1/mod/*+disp8   0/rm32/EAX    .           .             .           1/r32/ECX   8/disp8         .                 # copy ECX to *(EAX+8)
+$initialize-trace-stream:end:
+    # . restore registers
+    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
 
 # Append a string to the given trace stream.
diff --git a/subx/apps/assort b/subx/apps/assort
index 32023675..b9ba016b 100755
--- a/subx/apps/assort
+++ b/subx/apps/assort
Binary files differdiff --git a/subx/apps/crenshaw2-1 b/subx/apps/crenshaw2-1
index def09e48..43fae481 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 705ac0ad..0a3c2c44 100755
--- a/subx/apps/crenshaw2-1b
+++ b/subx/apps/crenshaw2-1b
Binary files differdiff --git a/subx/apps/factorial b/subx/apps/factorial
index 2330d6ad..3439987b 100755
--- a/subx/apps/factorial
+++ b/subx/apps/factorial
Binary files differdiff --git a/subx/apps/handle b/subx/apps/handle
index 974e57a2..b6b806d5 100755
--- a/subx/apps/handle
+++ b/subx/apps/handle
Binary files differdiff --git a/subx/apps/hex b/subx/apps/hex
index 4bce98eb..3eb6a5b7 100755
--- a/subx/apps/hex
+++ b/subx/apps/hex
Binary files differdiff --git a/subx/apps/pack b/subx/apps/pack
index d1e98aa6..b8bd13aa 100755
--- a/subx/apps/pack
+++ b/subx/apps/pack
Binary files differ
358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432