diff --git a/108write.subx b/108write.subx index 988e21db..84060c62 100644 --- a/108write.subx +++ b/108write.subx @@ -25,6 +25,9 @@ write: # f: fd or (addr stream byte), s: (addr array byte) # . prologue 55/push-ebp 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . . # copy esp to ebp + # if (s == 0) return + 81 7/subop/compare 1/mod/*+disp8 5/rm32/ebp . . . . 0xc/disp8 0/imm32 # compare *(ebp+12) + 74/jump-if-= $write:end/disp8 # if (f < 0x08000000) _write(f, s) and return # f can't be a user-mode address, so treat it as a kernel file descriptor 81 7/subop/compare 1/mod/*+disp8 5/rm32/ebp . . . . 8/disp8 0x08000000/imm32 # compare *(ebp+8) 73/jump-if-addr>= $write:fake/disp8 diff --git a/310copy-bytes.subx b/310copy-bytes.subx index 7a90495b..eed337c0 100644 --- a/310copy-bytes.subx +++ b/310copy-bytes.subx @@ -113,3 +113,44 @@ test-stream-to-string: 89/<- %esp 5/r32/ebp 5d/pop-to-ebp c3/return + +# like stream-to-string but ignore surrounding quotes +# we might do other stuff here later +unquote-stream-to-string: # in: (addr stream _), out: (addr handle array _) + # . prologue + 55/push-ebp + 89/<- %ebp 4/r32/esp + # . save registers + 50/push-eax + 51/push-ecx + 52/push-edx + 56/push-esi + # esi = s + 8b/-> *(ebp+8) 6/r32/esi + # var len/ecx: int = s->write - s->read - 2 + 8b/-> *esi 1/r32/ecx + 2b/subtract *(esi+4) 1/r32/ecx + 81 7/subop/compare %ecx 2/imm32 + 7c/jump-if-< $unquote-stream-to-string:end/disp8 + 81 5/subop/subtract %ecx 2/imm32 + # allocate + (allocate-array Heap %ecx *(ebp+0xc)) + # var in/edx: (addr byte) = s->data + s->read + 1 + 8b/-> *(esi+4) 2/r32/edx + 8d/copy-address *(esi+edx+0xd) 2/r32/edx # Stream-data + 1 + # var dest/eax: (addr byte) = data for out + 8b/-> *(ebp+0xc) 0/r32/eax + (lookup *eax *(eax+4)) # => eax + 8d/copy-address *(eax+4) 0/r32/eax + # + (copy-bytes %edx %eax %ecx) +$unquote-stream-to-string:end: + # . restore registers + 5e/pop-to-esi + 5a/pop-to-edx + 59/pop-to-ecx + 58/pop-to-eax + # . epilogue + 89/<- %esp 5/r32/ebp + 5d/pop-to-ebp + c3/return diff --git a/400.mu b/400.mu index fb686e17..35fc88f0 100644 --- a/400.mu +++ b/400.mu @@ -177,6 +177,7 @@ sig new-buffered-file out: (addr handle buffered-file) sig stream-empty? s: (addr stream _) -> result/eax: boolean sig stream-full? s: (addr stream _) -> result/eax: boolean sig stream-to-string in: (addr stream _), out: (addr handle array _) +sig unquote-stream-to-string in: (addr stream _), out: (addr handle array _) sig stream-first s: (addr stream byte) -> result/eax: byte sig stream-final s: (addr stream byte) -> result/eax: byte diff --git a/apps/assort b/apps/assort index b96e8bce..91e7ff23 100755 Binary files a/apps/assort and b/apps/assort differ diff --git a/apps/braces b/apps/braces index 658a2906..0a07736c 100755 Binary files a/apps/braces and b/apps/braces differ diff --git a/apps/calls b/apps/calls index ca22ce03..d5637096 100755 Binary files a/apps/calls and b/apps/calls differ diff --git a/apps/crenshaw2-1 b/apps/crenshaw2-1 index 0b69e083..37f7b355 100755 Binary files a/apps/crenshaw2-1 and b/apps/crenshaw2-1 differ diff --git a/apps/crenshaw2-1b b/apps/crenshaw2-1b index 587b2655..75639828 100755 Binary files a/apps/crenshaw2-1b and b/apps/crenshaw2-1b differ diff --git a/apps/dquotes b/apps/dquotes index 71aac388..30d28e67 100755 Binary files a/apps/dquotes and b/apps/dquotes differ diff --git a/apps/factorial b/apps/factorial index c5676040..ebb0ba62 100755 Binary files a/apps/factorial and b/apps/factorial differ diff --git a/apps/hex b/apps/hex index 501feb40..198276d7 100755 Binary files a/apps/hex and b/apps/hex differ diff --git a/apps/mu b/apps/mu index d713a6eb..236b5d2a 100755 Binary files a/apps/mu and b/apps/mu differ diff --git a/apps/pack b/apps/pack index 79c773fb..070d0060 100755 Binary files a/apps/pack and b/apps/pack differ diff --git a/apps/sigils b/apps/sigils index d464f947..b6220832 100755 Binary files a/apps/sigils and b/apps/sigils differ diff --git a/apps/survey b/apps/survey index 24a7a699..893eb4f2 100755 Binary files a/apps/survey and b/apps/survey differ diff --git a/apps/tests b/apps/tests index f49cff1a..f43185f8 100755 Binary files a/apps/tests and b/apps/tests differ diff --git a/apps/tile/main.mu b/apps/tile/main.mu index d4f53535..08e6532b 100644 --- a/apps/tile/main.mu +++ b/apps/tile/main.mu @@ -77,12 +77,7 @@ fn test { initialize-environment-with-fake-screen env, 5, 0xa var g/eax: grapheme <- copy 0x22 # '"' process env, g - g <- copy 0x31 # '1' - process env, g - g <- copy 0x20 # space - process env, g - g <- copy 0x33 # '3' - process env, g + render env } fn repl { diff --git a/apps/tile/rpn.mu b/apps/tile/rpn.mu index 80ab47ae..cf0766b0 100644 --- a/apps/tile/rpn.mu +++ b/apps/tile/rpn.mu @@ -109,7 +109,7 @@ fn evaluate functions: (addr handle function), bindings: (addr table), scratch: break-if-!= var h: (handle array byte) var s/eax: (addr handle array byte) <- address h - stream-to-string curr-stream, s # leak + unquote-stream-to-string curr-stream, s # leak push-string-to-value-stack out, *s break $evaluate:process-word } diff --git a/apps/tile/value-stack.mu b/apps/tile/value-stack.mu index aae87c3d..7050442d 100644 --- a/apps/tile/value-stack.mu +++ b/apps/tile/value-stack.mu @@ -130,6 +130,8 @@ fn value-stack-max-width _self: (addr value-stack) -> result/eax: int { break-if-!= var s-ah/eax: (addr handle array byte) <- get g, text-data var s/eax: (addr array byte) <- lookup *s-ah + compare s, 0 + break-if-= var w/eax: int <- length s compare w, out break-if-<=