about summary refs log tree commit diff stats
path: root/subx/apps
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2019-05-19 13:35:25 -0700
committerKartik Agaram <vc@akkartik.com>2019-05-19 13:35:56 -0700
commit28d9bee065558f5228a97e11add0566c818c4010 (patch)
treea73b8ccf90e1ec5c181233ba74e089d8f17d3740 /subx/apps
parentedcfadff5fd86f1ed52399c432d37773105e5a71 (diff)
downloadmu-28d9bee065558f5228a97e11add0566c818c4010.tar.gz
minor style tweaks for emit-metadata
Diffstat (limited to 'subx/apps')
-rwxr-xr-xsubx/apps/dquotesbin26597 -> 26597 bytes
-rw-r--r--subx/apps/dquotes.subx67
2 files changed, 27 insertions, 40 deletions
diff --git a/subx/apps/dquotes b/subx/apps/dquotes
index 14581ef8..7d98f4d2 100755
--- a/subx/apps/dquotes
+++ b/subx/apps/dquotes
Binary files differdiff --git a/subx/apps/dquotes.subx b/subx/apps/dquotes.subx
index 2d308f5b..bfcb3616 100644
--- a/subx/apps/dquotes.subx
+++ b/subx/apps/dquotes.subx
@@ -1269,6 +1269,15 @@ test-emit-string-literal-data-handles-escape-sequences:
 
 # emit everything from a word except the initial datum
 emit-metadata:  # out : (address buffered-file), word : (address slice)
+    # pseudocode
+    #   curr = word->start
+    #   while true
+    #     if curr == word->end
+    #       return
+    #     if *curr == '/'
+    #       break
+    #     ++curr
+    #   write-slice-buffered(out, slice{curr, word->end})
     # . prolog
     55/push-EBP
     89/copy                         3/mod/direct    5/rm32/EBP    .           .             .           4/r32/ESP   .               .                 # copy ESP to EBP
@@ -1276,57 +1285,35 @@ emit-metadata:  # out : (address buffered-file), word : (address slice)
     50/push-EAX
     51/push-ECX
     52/push-EDX
-
-    # PSEUDOCODE
-    # ECX = (char *) word->start
-    # while true:
-    #   if ECX == word->end: return
-    #   if *(ECX++) == '/': break
-    # write-slice-buffered(out, {ECX, word->end})
-
     # ECX = word
-    8b/copy/word                    1/mod/*+disp8   5/rm32/EBP    .           .             .           1/r32/ECX   0xc/disp8       .                 # copy *(EBP+12) to ECX
-    # EDX = word->end
-    8b/copy/word->end               1/mod/*+disp8   1/rm32/ECX    .           .             .           2/r32/EDX   4/disp8         .                 # copy *(ECX+4) to EDX
-    # ECX = word->start
-    8b/copy/word->start             0/mod/indirect  1/rm32/ECX    .           .             .           1/r32/ECX   .               .                 # copy *ECX to ECX
-
+    8b/copy                         1/mod/*+disp8   5/rm32/EBP    .           .             .           1/r32/ECX   0xc/disp8       .                 # copy *(EBP+12) to ECX
+    # end/EDX = word->end
+    8b/copy                         1/mod/*+disp8   1/rm32/ECX    .           .             .           2/r32/EDX   4/disp8         .                 # copy *(ECX+4) to EDX
+    # curr/ECX = word->start
+    8b/copy                         0/mod/indirect  1/rm32/ECX    .           .             .           1/r32/ECX   .               .                 # copy *ECX to ECX
     # clear out EAX
-    b8/copy-to-EAX 0/imm32
-    # while *start != '/':
-$skip-datum-loop:
-    # . start == end?
-    39/compare-ECX-and              3/mod/direct    2/rm32/EDX    .           .             .           1/r32/ECX   .               .                 # EDX == ECX
-    # . if so, return from function (it's only datum, or empty)
+    b8/copy-to-EAX  0/imm32
+$emit-metadata:skip-datum-loop:
+    # if (curr == end) return
+    39/compare                      3/mod/direct    1/rm32/ECX    .           .             .           2/r32/EDX   .               .                 # compare ECX and EDX
     74/jump-if-equal  $emit-metadata:end/disp8
-
-    # . start++
-    41/increment-ECX                                                                                                                                  # ECX++
-
-    # . EAX = *start
+    # ++curr
+    41/increment-ECX
+    # if (*curr == '/') break
     8a/copy-byte                    0/mod/indirect  1/rm32/ECX    .           .             .           0/r32/EAX   .               .                 # copy *ECX to EAX
-
-    # . EAX != '/'?
     3d/compare-EAX-and  0x2f/imm32
-    # . if so, continue looping
-    75/jump-if-not-equal  $skip-datum-loop/disp8
-    # end
-
+    75/jump-if-not-equal  $emit-metadata:skip-datum-loop/disp8
     # write-slice-buffered(out, &{start, end})
-    # . push end
+    # . . local var
     52/push-EDX
-    # . push start
     51/push-ECX
-    # . push &{start, end}
+    # . . push args
     54/push-ESP
-
-    # . push out
     ff          6/subop/push        1/mod/*+disp8   5/rm32/EBP    .           .             .           .           8/disp8         .                 # push *(EBP+8)
-
+    # . . call
     e8/call  write-slice-buffered/disp32
-    # . discard args
-    81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           0x10/imm32      .                 # add 16 to ESP
-
+    # . . discard args
+    81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           0x10/imm32      .                 # add to ESP
 $emit-metadata:end:
     # . restore registers
     5a/pop-to-EDX