about summary refs log tree commit diff stats
path: root/subx/apps
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2019-07-11 21:47:00 -0700
committerKartik Agaram <vc@akkartik.com>2019-07-11 21:47:00 -0700
commit98994d5bccb87935870fc0a96da8f1a63aaf9dfe (patch)
treea0457956e2fcda0b66a52a560d7d11db48ba07ac /subx/apps
parentbbfa2acacac164b7797838131d1ac9739b72fdad (diff)
downloadmu-98994d5bccb87935870fc0a96da8f1a63aaf9dfe.tar.gz
the problem: curr-segment-name is stale
It's a slice into the 'line' stream. But we want to preserve the current
segment name across lines.

Let's leak some memory.
Diffstat (limited to 'subx/apps')
-rw-r--r--subx/apps/survey.subx129
1 files changed, 126 insertions, 3 deletions
diff --git a/subx/apps/survey.subx b/subx/apps/survey.subx
index 5f776d38..a5e82759 100644
--- a/subx/apps/survey.subx
+++ b/subx/apps/survey.subx
@@ -436,6 +436,83 @@ $compute-offsets:word-loop:
     e8/call  next-word/disp32
     # . discard args
     81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
+    # dump word-slice {{{
+    # . write(2/stderr, "AA: ")
+    # . . push args
+    68/push  "AA: "/imm32
+    68/push  2/imm32/stderr
+    # . . call
+    e8/call  write/disp32
+    # . . discard args
+    81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
+    # . clear-stream(Stderr+4)
+    # . . save EAX
+    50/push-EAX
+    # . . push args
+    b8/copy-to-EAX  Stderr/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
+    # . . restore EAX
+    58/pop-to-EAX
+    # . write-slice-buffered(Stderr, word-slice)
+    # . . push args
+    52/push-EDX
+    68/push  Stderr/imm32
+    # . . call
+    e8/call  write-slice-buffered/disp32
+    # . . discard args
+    81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
+    # . flush(Stderr)
+    # . . push args
+    68/push  Stderr/imm32
+    # . . call
+    e8/call  flush/disp32
+    # . . discard args
+    81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add to ESP
+    # . write(2/stderr, "$\n")
+    # . . push args
+    68/push  "$\n"/imm32
+    68/push  2/imm32/stderr
+    # . . call
+    e8/call  write/disp32
+    # . . discard args
+    81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
+    # . write(2/stderr, "segment at start of word: ")
+    # . . push args
+    68/push  "segment at start of word: "/imm32
+    68/push  2/imm32/stderr
+    # . . call
+    e8/call  write/disp32
+    # . . discard args
+    81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
+    # . write-slice-buffered(Stderr, curr-segment-name)
+    # . . push args
+    68/push  compute-offsets:curr-segment-name/imm32
+    68/push  Stderr/imm32
+    # . . call
+    e8/call  write-slice-buffered/disp32
+    # . . discard args
+    81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
+    # . flush(Stderr)
+    # . . push args
+    68/push  Stderr/imm32
+    # . . call
+    e8/call  flush/disp32
+    # . . discard args
+    81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add to ESP
+    # . write(2/stderr, "$\n")
+    # . . push args
+    68/push  "$\n"/imm32
+    68/push  2/imm32/stderr
+    # . . call
+    e8/call  write/disp32
+    # . . discard args
+    81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
+    # }}}
     # if slice-empty?(word/EDX) break
     # . EAX = slice-empty?(word/EDX)
     52/push-EDX
@@ -453,7 +530,7 @@ $compute-offsets:word-loop:
     81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
     # . if (EAX != 0) continue
     3d/compare-EAX-and  0/imm32
-    75/jump-if-not-equal  $compute-offsets:word-loop/disp8
+    0f 85/jump-if-not-equal  $compute-offsets:word-loop/disp32
 $compute-offsets:label:
     # if (!is-label?(word-slice/EDX)) goto next check
     # . EAX = is-label?(word-slice/EDX)
@@ -468,7 +545,7 @@ $compute-offsets:label:
     74/jump-if-equal  $compute-offsets:segment/disp8
     # strip trailing ':' from word-slice
     ff          1/subop/decrement   1/mod/*+disp8   2/rm32/EDX    .           .             .           .           4/disp8         .                 # decrement *(EDX+4)
-    # x/EAX = get-or-insert-slice(labels, word-slice)
+    # x/EAX = get-or-insert-slice(labels, word-slice, row-size=16)
     # . . push args
     68/push  0x10/imm32/row-size
     52/push-EDX
@@ -565,6 +642,52 @@ $compute-offsets:construct-next-segment:
     e8/call  next-word/disp32
     # . discard args
     81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
+    # dump curr-segment-name {{{
+    # . write(2/stderr, "setting segment to: ")
+    # . . push args
+    68/push  "setting segment to: "/imm32
+    68/push  2/imm32/stderr
+    # . . call
+    e8/call  write/disp32
+    # . . discard args
+    81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
+    # . clear-stream(Stderr+4)
+    # . . save EAX
+    50/push-EAX
+    # . . push args
+    b8/copy-to-EAX  Stderr/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
+    # . . restore EAX
+    58/pop-to-EAX
+    # . write-slice-buffered(Stderr, curr-segment-name)
+    # . . push args
+    68/push  compute-offsets:curr-segment-name/imm32
+    68/push  Stderr/imm32
+    # . . call
+    e8/call  write-slice-buffered/disp32
+    # . . discard args
+    81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
+    # . flush(Stderr)
+    # . . push args
+    68/push  Stderr/imm32
+    # . . call
+    e8/call  flush/disp32
+    # . . discard args
+    81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add to ESP
+    # . write(2/stderr, "$\n")
+    # . . push args
+    68/push  "$\n"/imm32
+    68/push  2/imm32/stderr
+    # . . call
+    e8/call  write/disp32
+    # . . discard args
+    81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
+    # }}}
     # if slice-empty?(curr-segment-name) abort
     # . EAX = slice-empty?(curr-segment-name)
     68/push  compute-offsets:curr-segment-name/imm32
@@ -798,7 +921,7 @@ test-compute-offsets:
     e8/call  check-trace-contains/disp32
     # . . discard args
     81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               8/imm32           # add to ESP
-    # . check-trace-contains("segment 'data' is at file offset 0x5", msg)
+    # . check-trace-contains("segment 'data' is at file offset 0x00000005.", msg)
     # . . push args
     68/push  "F - test-compute-offsets/2"/imm32
     68/push  "segment 'data' is at file offset 0x00000005."/imm32