about summary refs log tree commit diff stats
path: root/subx
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2019-06-08 12:52:46 -0700
committerKartik Agaram <vc@akkartik.com>2019-06-08 12:53:52 -0700
commit35dd69f7ca0e2cec153822cc0856dd157e49fdad (patch)
tree48b7b80a25bc8771820d75fa1aeb0e79c902eca6 /subx
parent35272969cfe6fc81d706746362a7af2a0743275e (diff)
downloadmu-35dd69f7ca0e2cec153822cc0856dd157e49fdad.tar.gz
.
Diffstat (limited to 'subx')
-rw-r--r--subx/056trace.subx134
-rwxr-xr-xsubx/apps/assortbin25661 -> 25647 bytes
-rwxr-xr-xsubx/apps/crenshaw2-1bin21335 -> 21321 bytes
-rwxr-xr-xsubx/apps/crenshaw2-1bbin21894 -> 21880 bytes
-rwxr-xr-xsubx/apps/factorialbin20251 -> 20237 bytes
-rwxr-xr-xsubx/apps/handlebin21057 -> 21043 bytes
-rwxr-xr-xsubx/apps/hexbin24344 -> 24330 bytes
-rwxr-xr-xsubx/apps/packbin40575 -> 40561 bytes
-rwxr-xr-xsubx/apps/surveybin23888 -> 23874 bytes
9 files changed, 61 insertions, 73 deletions
diff --git a/subx/056trace.subx b/subx/056trace.subx
index c8d7cc2c..2f2fd0ea 100644
--- a/subx/056trace.subx
+++ b/subx/056trace.subx
@@ -83,7 +83,7 @@ $initialize-trace-stream:end:
 
 # Append a string to the given trace stream.
 # Silently give up if it's already full. Or truncate the string if there isn't enough room.
-trace:  # t : (address trace-stream), line : string
+trace:  # line : string
     # . prolog
     55/push-EBP
     89/copy                         3/mod/direct    5/rm32/EBP    .           .             .           4/r32/ESP   .               .                 # copy ESP to EBP
@@ -94,10 +94,10 @@ trace:  # t : (address trace-stream), line : string
     53/push-EBX
     56/push-ESI
     57/push-EDI
-    # EDI = t
-    8b/copy                         1/mod/*+disp8   5/rm32/EBP    .           .                         7/r32/EDI   8/disp8         .                 # copy *(EBP+8) to EDI
+    # EDI = *Trace-stream
+    8b/copy                         0/mod/indirect  5/rm32/.disp32            .             .           7/r32/EDI   Trace-stream/disp32               # copy *Trace-stream to EDI
     # ESI = line
-    8b/copy                         1/mod/*+disp8   5/rm32/EBP    .           .                         6/r32/ESI   0xc/disp8       .                 # copy *(EBP+12) to ESI
+    8b/copy                         1/mod/*+disp8   5/rm32/EBP    .           .                         6/r32/ESI   8/disp8         .                 # copy *(EBP+8) to ESI
     # ECX = t->write
     8b/copy                         0/mod/indirect  7/rm32/EDI    .           .             .           1/r32/ECX   .               .                 # copy *EDI to ECX
     # EDX = t->length
@@ -150,61 +150,19 @@ $trace:end:
     5d/pop-to-EBP
     c3/return
 
-clear-trace-stream:  # t : (address trace-stream)
-    # . 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
-    # EAX = t
-    8b/copy                         1/mod/*+disp8   5/rm32/EBP    .           .                         0/r32/EAX   8/disp8         .                 # copy *(EBP+8) to EAX
-    # ECX = t->length
-    8b/copy                         1/mod/*+disp8   0/rm32/EAX    .           .             .           1/r32/ECX   8/disp8         .                 # copy *(EAX+8) to ECX
-    # ECX = &t->data[t->length]
-    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
-    # t->write = 0
-    c7          0/subop/copy        0/mod/direct    0/rm32/EAX    .           .             .           .           .               0/imm32           # copy to *EAX
-    # t->read = 0
-    c7          0/subop/copy        1/mod/*+disp8   0/rm32/EAX    .           .             .           .           4/disp8         0/imm32           # copy to *(EAX+4)
-    # EAX = t->data
-    81          0/subop/add         3/mod/direct    0/rm32/EAX    .           .             .           .           .               0xc/imm32         # add to EAX
-$clear-trace-stream:loop:
-    # if (EAX >= ECX) break
-    39/compare                      3/mod/direct    0/rm32/EAX    .           .             .           1/r32/ECX   .               .                 # compare EAX with ECX
-    7d/jump-if-greater-or-equal  $clear-trace-stream:end/disp8
-    # *EAX = 0
-    c7          0/subop/copy        0/mod/direct    0/rm32/EAX    .           .             .           .           .               0/imm32           # copy to *EAX
-    # EAX += 4
-    81          0/subop/add         3/mod/direct    0/rm32/EAX    .           .             .           .           .               4/imm32           # add to EAX
-    eb/jump  $clear-trace-stream:loop/disp8
-$clear-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
-
-# - tests
-
 test-trace-single:
-    # clear-trace-stream(_test-trace-stream)
-    # . . push args
-    68/push  _test-trace-stream/imm32
-    # . . call
+    # *Trace-stream = _test-trace-stream
+    b8/copy-to-EAX  _test-trace-stream/imm32
+    89/copy                         0/mod/indirect  5/rm32/.disp32            .             .           0/r32/EAX   Trace-stream/disp32               # copy EAX to *Trace-stream
+    # clear-trace-stream()
     e8/call  clear-trace-stream/disp32
-    # . . discard args
-    81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add to ESP
-    # trace(_test-trace-stream, "Ab")
+    # trace("Ab")
     # . . push args
     68/push  "Ab"/imm32
-    68/push  _test-trace-stream/imm32
     # . . call
     e8/call  trace/disp32
     # . . discard args
-    81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
+    81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add to ESP
     # check-ints-equal(*_test-trace-stream->data, 41/A 62/b 0a/newline 00, msg)
     # . . push args
     68/push  "F - test-trace-single"/imm32
@@ -220,29 +178,25 @@ test-trace-single:
     c3/return
 
 test-trace-appends:
-    # clear-trace-stream(_test-trace-stream)
-    # . . push args
-    68/push  _test-trace-stream/imm32
-    # . . call
+    # *Trace-stream = _test-trace-stream
+    b8/copy-to-EAX  _test-trace-stream/imm32
+    89/copy                         0/mod/indirect  5/rm32/.disp32            .             .           0/r32/EAX   Trace-stream/disp32               # copy EAX to *Trace-stream
+    # clear-trace-stream()
     e8/call  clear-trace-stream/disp32
-    # . . discard args
-    81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add to ESP
-    # trace(_test-trace-stream, "C")
+    # trace("C")
     # . . push args
     68/push  "C"/imm32
-    68/push  _test-trace-stream/imm32
     # . . call
     e8/call  trace/disp32
     # . . discard args
-    81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
-    # trace(_test-trace-stream, "D")
+    81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add to ESP
+    # trace("D")
     # . . push args
     68/push  "D"/imm32
-    68/push  _test-trace-stream/imm32
     # . . call
     e8/call  trace/disp32
     # . . discard args
-    81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
+    81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add to ESP
     # check-ints-equal(*_test-trace-stream->data, 43/C 0a/newline 44/D 0a/newline, msg)
     # . . push args
     68/push  "F - test-trace-appends"/imm32
@@ -258,21 +212,18 @@ test-trace-appends:
     c3/return
 
 test-trace-empty-line:
-    # clear-trace-stream(_test-trace-stream)
-    # . . push args
-    68/push  _test-trace-stream/imm32
-    # . . call
+    # *Trace-stream = _test-trace-stream
+    b8/copy-to-EAX  _test-trace-stream/imm32
+    89/copy                         0/mod/indirect  5/rm32/.disp32            .             .           0/r32/EAX   Trace-stream/disp32               # copy EAX to *Trace-stream
+    # clear-trace-stream()
     e8/call  clear-trace-stream/disp32
-    # . . discard args
-    81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add to ESP
-    # trace(_test-trace-stream, "")
+    # trace("")
     # . . push args
     68/push  ""/imm32
-    68/push  _test-trace-stream/imm32
     # . . call
     e8/call  trace/disp32
     # . . discard args
-    81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
+    81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add to ESP
     # check-ints-equal(*_test-trace-stream->data, 0, msg)
     # . . push args
     68/push  "F - test-trace-empty-line"/imm32
@@ -287,6 +238,43 @@ test-trace-empty-line:
     # end
     c3/return
 
+clear-trace-stream:
+    # . 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
+    # EAX = *Trace-stream
+    8b/copy                         0/mod/indirect  5/rm32/.disp32            .             .           0/r32/EAX   Trace-stream/disp32               # copy *Trace-stream to EAX
+    # ECX = t->length
+    8b/copy                         1/mod/*+disp8   0/rm32/EAX    .           .             .           1/r32/ECX   8/disp8         .                 # copy *(EAX+8) to ECX
+    # ECX = &t->data[t->length]
+    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
+    # t->write = 0
+    c7          0/subop/copy        0/mod/direct    0/rm32/EAX    .           .             .           .           .               0/imm32           # copy to *EAX
+    # t->read = 0
+    c7          0/subop/copy        1/mod/*+disp8   0/rm32/EAX    .           .             .           .           4/disp8         0/imm32           # copy to *(EAX+4)
+    # EAX = t->data
+    81          0/subop/add         3/mod/direct    0/rm32/EAX    .           .             .           .           .               0xc/imm32         # add to EAX
+$clear-trace-stream:loop:
+    # if (EAX >= ECX) break
+    39/compare                      3/mod/direct    0/rm32/EAX    .           .             .           1/r32/ECX   .               .                 # compare EAX with ECX
+    7d/jump-if-greater-or-equal  $clear-trace-stream:end/disp8
+    # *EAX = 0
+    c7          0/subop/copy        0/mod/direct    0/rm32/EAX    .           .             .           .           .               0/imm32           # copy to *EAX
+    # EAX += 4
+    81          0/subop/add         3/mod/direct    0/rm32/EAX    .           .             .           .           .               4/imm32           # add to EAX
+    eb/jump  $clear-trace-stream:loop/disp8
+$clear-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
+
 # - helpers
 
 # 3-argument variant of _append
diff --git a/subx/apps/assort b/subx/apps/assort
index a37b8589..2489d235 100755
--- a/subx/apps/assort
+++ b/subx/apps/assort
Binary files differdiff --git a/subx/apps/crenshaw2-1 b/subx/apps/crenshaw2-1
index ba5de847..8cb5e471 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 dd419629..8fb03862 100755
--- a/subx/apps/crenshaw2-1b
+++ b/subx/apps/crenshaw2-1b
Binary files differdiff --git a/subx/apps/factorial b/subx/apps/factorial
index 292fd7eb..2836d43f 100755
--- a/subx/apps/factorial
+++ b/subx/apps/factorial
Binary files differdiff --git a/subx/apps/handle b/subx/apps/handle
index 5c815074..0cc21fb2 100755
--- a/subx/apps/handle
+++ b/subx/apps/handle
Binary files differdiff --git a/subx/apps/hex b/subx/apps/hex
index 62dc2792..821a2ae1 100755
--- a/subx/apps/hex
+++ b/subx/apps/hex
Binary files differdiff --git a/subx/apps/pack b/subx/apps/pack
index 407970b7..b2e21108 100755
--- a/subx/apps/pack
+++ b/subx/apps/pack
Binary files differdiff --git a/subx/apps/survey b/subx/apps/survey
index 989c88c7..f3079746 100755
--- a/subx/apps/survey
+++ b/subx/apps/survey
Binary files differ