about summary refs log tree commit diff stats
path: root/subx/apps
diff options
context:
space:
mode:
Diffstat (limited to 'subx/apps')
-rwxr-xr-xsubx/apps/crenshaw2-1bin9157 -> 10778 bytes
-rwxr-xr-xsubx/apps/crenshaw2-1bbin9716 -> 11337 bytes
-rwxr-xr-xsubx/apps/factorialbin8075 -> 9696 bytes
-rwxr-xr-xsubx/apps/handlebin8868 -> 10489 bytes
-rwxr-xr-xsubx/apps/hexbin12671 -> 14292 bytes
-rw-r--r--subx/apps/pack.subx24
6 files changed, 22 insertions, 2 deletions
diff --git a/subx/apps/crenshaw2-1 b/subx/apps/crenshaw2-1
index 20ac912a..354683d2 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 37145d9c..37576192 100755
--- a/subx/apps/crenshaw2-1b
+++ b/subx/apps/crenshaw2-1b
Binary files differdiff --git a/subx/apps/factorial b/subx/apps/factorial
index c05e588f..72217cdd 100755
--- a/subx/apps/factorial
+++ b/subx/apps/factorial
Binary files differdiff --git a/subx/apps/handle b/subx/apps/handle
index d6d0a7f5..ce489c0a 100755
--- a/subx/apps/handle
+++ b/subx/apps/handle
Binary files differdiff --git a/subx/apps/hex b/subx/apps/hex
index 932a3ceb..936ebdce 100755
--- a/subx/apps/hex
+++ b/subx/apps/hex
Binary files differdiff --git a/subx/apps/pack.subx b/subx/apps/pack.subx
index 1cf57867..bad21e0f 100644
--- a/subx/apps/pack.subx
+++ b/subx/apps/pack.subx
@@ -117,7 +117,7 @@ $main:end:
 #   word = name until '/', then 0 or more metadata separated by '/'
 #
 # we won't bother saving the internal structure of lines; reparsing should be cheap using two primitives:
-#   next-token(stream, delim char) -> slice (start, end pointer)
+#   next-token(stream, delim char) -> slice (start, end pointers)
 #   slice-equal?(slice, kernel string)
 
 # helpers:
@@ -136,7 +136,6 @@ $main:end:
 #   emit(out : &buffered-file, word : &slice)
 #   has-metadata?(word : &slice, s : &kernel-string) -> bool
 
-# the main entry point
 convert:  # in : (address buffered-file), out : (address buffered-file), err : (address buffered-file), ed : (address exit-descriptor) -> <void>
     # pseudocode:
     #   line = new-stream(512, 1)
@@ -157,6 +156,27 @@ convert:  # in : (address buffered-file), out : (address buffered-file), err : (
     5d/pop-to-EBP
     c3/return
 
+# (re)compute the bounds of the next word in the line
+next-word:  # line : (address stream byte), out : (address slice)
+    # . prolog
+    55/push-EBP
+    89/copy                         3/mod/direct    5/rm32/EBP    .           .             .           4/r32/ESP   .               .                 # copy ESP to EBP
+    # . save registers
+    # skip-whitespace(line)
+    # . . push args
+    ff          6/subop/push        1/mod/*+disp8   5/rm32/EBP    .           .             .           .           8/disp8         .                 # push *(EBP+8)
+    # . . call
+    e8/call  skip-whitespace/disp32
+    # . . discard args
+    81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add to ESP
+    # if line->data[line->read] == '#' return (&line->data[line->read], &line->data[line->write])
+    # return next-token(line, ' ')
+    # . restore registers
+    # . epilog
+    89/copy                         3/mod/direct    4/rm32/ESP    .           .             .           5/r32/EBP   .               .                 # copy EBP to ESP
+    5d/pop-to-EBP
+    c3/return
+
 == data
 
 # . . vim:nowrap:textwidth=0