about summary refs log tree commit diff stats
path: root/apps/tests.subx
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-04-03 20:13:27 -0700
committerKartik Agaram <vc@akkartik.com>2020-05-18 00:44:46 -0700
commit94fca7058a2e2bd62393758fbb98cd3f8ace4b2a (patch)
treeb4a6b2f69ca0ae12103857d95c4748ec9c13c0e2 /apps/tests.subx
parentd538b29302b6b9e01c83c16bbe355615a204c95e (diff)
downloadmu-94fca7058a2e2bd62393758fbb98cd3f8ace4b2a.tar.gz
tests.subx now working
Diffstat (limited to 'apps/tests.subx')
-rw-r--r--apps/tests.subx29
1 files changed, 23 insertions, 6 deletions
diff --git a/apps/tests.subx b/apps/tests.subx
index b70e6e1a..ff09730a 100644
--- a/apps/tests.subx
+++ b/apps/tests.subx
@@ -71,7 +71,9 @@ subx-gen-run-tests:  # in: (addr buffered-file), out: (addr buffered-file)
     # pseudocode
     #   boolean tests-found = false
     #   var line: (stream byte 512)
-    #   var new-code-segment: (handle stream byte) = new-stream(Segment-size, 1)
+    #   var new-code-segment-handle: (handle stream byte)
+    #   new-stream(Segment-size, 1, new-code-stream-handle)
+    #   var new-code-segment: (addr stream byte) = lookup(new-code-stream-handle)
     #   write(new-code-segment, "\n== code\n")
     #   write(new-code-segment, "run-tests:\n")
     #   while true
@@ -100,6 +102,7 @@ subx-gen-run-tests:  # in: (addr buffered-file), out: (addr buffered-file)
     51/push-ecx
     52/push-edx
     53/push-ebx
+    56/push-esi
     57/push-edi
     # var line/ecx: (stream byte 512)
     81          5/subop/subtract    3/mod/direct    4/rm32/esp    .           .             .           .           .               0x200/imm32       # subtract from esp
@@ -113,17 +116,30 @@ subx-gen-run-tests:  # in: (addr buffered-file), out: (addr buffered-file)
     89/copy                         3/mod/direct    2/rm32/edx    .           .             .           4/r32/esp   .               .                 # copy esp to edx
     # tests-found?/ebx = false
     31/xor                          3/mod/direct    3/rm32/ebx    .           .             .           3/r32/ebx   .               .                 # clear ebx
-    # new-code-segment/edi = new-stream(Heap, Segment-size, 1)
-    # . eax = new-stream(Heap, Segment-size, 1)
+    # var new-code-stream-handle/esi: (handle stream byte)
+    68/push  0/imm32
+    68/push  0/imm32
+    89/copy                         3/mod/direct    6/rm32/esi    .           .             .           4/r32/esp   .               .                 # copy esp to esi
+    # new-stream(Heap, Segment-size, 1, new-code-stream-handle)
     # . . push args
+    56/push-esi
     68/push  1/imm32
     ff          6/subop/push        0/mod/indirect  5/rm32/.disp32            .             .           .           Segment-size/disp32               # push *Segment-size
     68/push  Heap/imm32
     # . . call
     e8/call  new-stream/disp32
     # . . discard args
-    81          0/subop/add         3/mod/direct    4/rm32/esp    .           .             .           .           .               0xc/imm32         # add to esp
-    # . edi = eax
+    81          0/subop/add         3/mod/direct    4/rm32/esp    .           .             .           .           .               0x10/imm32        # add to esp
+    # var new-code-stream/edi: (addr stream byte) = lookup(*new-code-stream-handle)
+    # . eax = lookup(*new-code-stream-handle)
+    # . . push args
+    ff          6/subop/push        1/mod/*+disp8   6/rm32/esi    .           .             .           .           4/disp8         .                 # push *(esi+4)
+    ff          6/subop/push        0/mod/indirect  6/rm32/esi    .           .             .           .           .               .                 # push *esi
+    # . . call
+    e8/call  lookup/disp32
+    # . . discard args
+    81          0/subop/add         3/mod/direct    4/rm32/esp    .           .             .           .           .               8/imm32           # add to esp
+    # . new-code-stream = eax
     89/copy                         3/mod/direct    7/rm32/edi    .           .             .           0/r32/eax   .               .                 # copy eax to edi
     # write(new-code-segment, "\n== code\n")
     # . . push args
@@ -269,9 +285,10 @@ $subx-gen-run-tests:end:
     # . . discard args
     81          0/subop/add         3/mod/direct    4/rm32/esp    .           .             .           .           .               4/imm32           # add to esp
     # . reclaim locals
-    81          0/subop/add         3/mod/direct    4/rm32/esp    .           .             .           .           .               0x214/imm32       # add to esp
+    81          0/subop/add         3/mod/direct    4/rm32/esp    .           .             .           .           .               0x21c/imm32       # add to esp
     # . restore registers
     5f/pop-to-edi
+    5e/pop-to-esi
     5b/pop-to-ebx
     5a/pop-to-edx
     59/pop-to-ecx