From 70187b1c01a0540bc677fbbfeaef129549d3075d Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Tue, 26 Nov 2019 22:11:23 -0800 Subject: 5765 A couple more primitives now working. In the process I ran into an issue with some buffer filling up when running ntranslate. Isolating it to survey.subx was straightforward, but --trace ran out of RAM, and --trace --dump ran out of (7GB of) disk. In the end what helped was just repeatedly inserting exits at different points, and I realized there was a magic number that hadn't been turned into a named constant. --- apps/assort | Bin 42893 -> 42897 bytes apps/braces | Bin 42908 -> 42912 bytes apps/calls | Bin 47619 -> 47623 bytes apps/dquotes | Bin 46543 -> 46547 bytes apps/hex | Bin 45139 -> 45143 bytes apps/mu | Bin 53140 -> 53751 bytes apps/mu.subx | 112 ++++++++++++++++++++++++++++++++++++++++++++++++++ apps/pack | Bin 55284 -> 55288 bytes apps/sigils | Bin 55294 -> 55298 bytes apps/subx-params.subx | 4 ++ apps/survey | Bin 52133 -> 52137 bytes apps/survey.subx | 6 +-- apps/tests | Bin 41690 -> 41694 bytes 13 files changed, 119 insertions(+), 3 deletions(-) diff --git a/apps/assort b/apps/assort index 0cd18ecf..1d59ee52 100755 Binary files a/apps/assort and b/apps/assort differ diff --git a/apps/braces b/apps/braces index e1fa64e5..14c0ccf3 100755 Binary files a/apps/braces and b/apps/braces differ diff --git a/apps/calls b/apps/calls index d429db9c..4a0e624e 100755 Binary files a/apps/calls and b/apps/calls differ diff --git a/apps/dquotes b/apps/dquotes index 43858006..e29314af 100755 Binary files a/apps/dquotes and b/apps/dquotes differ diff --git a/apps/hex b/apps/hex index 6c1d41f6..cc517a6e 100755 Binary files a/apps/hex and b/apps/hex differ diff --git a/apps/mu b/apps/mu index b8aad9cd..25d5ed3d 100755 Binary files a/apps/mu and b/apps/mu differ diff --git a/apps/mu.subx b/apps/mu.subx index 6385c020..c3a1020a 100644 --- a/apps/mu.subx +++ b/apps/mu.subx @@ -2176,6 +2176,118 @@ test-add-reg-to-reg: 5d/pop-to-ebp c3/return +test-add-reg-to-mem: + # add-to var1 var2/reg + # => + # 01 *(ebp+__) var2 + # + # . prologue + 55/push-ebp + 89/<- %ebp 4/r32/esp + # setup + (clear-stream _test-output-stream) + (clear-stream _test-output-buffered-file->buffer) + # var-var1/ecx : var + 68/push 0/imm32/no-register + 68/push 8/imm32/stack-offset + 68/push 1/imm32/block-depth + 68/push 1/imm32/type-int + 68/push "var1"/imm32 + 89/<- %ecx 4/r32/esp + # var-var2/edx : var in ecx + 68/push "ecx"/imm32/register + 68/push 0/imm32/no-stack-offset + 68/push 1/imm32/block-depth + 68/push 1/imm32/type-int + 68/push "var2"/imm32 + 89/<- %edx 4/r32/esp + # inouts/esi : (list var2) + 68/push 0/imm32/next + 52/push-edx/var-var2 + 89/<- %esi 4/r32/esp + # inouts = (list var1 var2) + 56/push-esi/next + 51/push-ecx/var-var1 + 89/<- %esi 4/r32/esp + # stmt/esi : statement + 68/push 0/imm32/next + 68/push 0/imm32/outputs + 56/push-esi/inouts + 68/push "add-to"/imm32/operation + 68/push 1/imm32 + 89/<- %esi 4/r32/esp + # convert + (emit-subx-statement _test-output-buffered-file %esi 0 Primitives 0) + (flush _test-output-buffered-file) +#? # dump _test-output-stream {{{ +#? (write 2 "^") +#? (write-stream 2 _test-output-stream) +#? (write 2 "$\n") +#? (rewind-stream _test-output-stream) +#? # }}} + # check output + (check-next-stream-line-equal _test-output-stream "01 *(ebp+0x00000008) 0x00000001/r32" "F - test-add-reg-to-mem") + # . epilogue + 89/<- %esp 5/r32/ebp + 5d/pop-to-ebp + c3/return + +test-add-mem-to-reg: + # var1/reg <- add var2 + # => + # 03 *(ebp+__) var1 + # + # . prologue + 55/push-ebp + 89/<- %ebp 4/r32/esp + # setup + (clear-stream _test-output-stream) + (clear-stream _test-output-buffered-file->buffer) + # var-var1/ecx : var in eax + 68/push "eax"/imm32/register + 68/push 0/imm32/no-stack-offset + 68/push 1/imm32/block-depth + 68/push 1/imm32/type-int + 68/push "var1"/imm32 + 89/<- %ecx 4/r32/esp + # var-var2/edx : var + 68/push 0/imm32/no-register + 68/push 8/imm32/stack-offset + 68/push 1/imm32/block-depth + 68/push 1/imm32/type-int + 68/push "var2"/imm32 + 89/<- %edx 4/r32/esp + # inouts/esi : (list var2) + 68/push 0/imm32/next + 52/push-edx/var-var2 + 89/<- %esi 4/r32/esp + # outputs/edi : (list var1) + 68/push 0/imm32/next + 51/push-ecx/var-var1 + 89/<- %edi 4/r32/esp + # stmt/esi : statement + 68/push 0/imm32/next + 57/push-edi/outputs + 56/push-esi/inouts + 68/push "add"/imm32/operation + 68/push 1/imm32 + 89/<- %esi 4/r32/esp + # convert + (emit-subx-statement _test-output-buffered-file %esi 0 Primitives 0) + (flush _test-output-buffered-file) +#? # dump _test-output-stream {{{ +#? (write 2 "^") +#? (write-stream 2 _test-output-stream) +#? (write 2 "$\n") +#? (rewind-stream _test-output-stream) +#? # }}} + # check output + (check-next-stream-line-equal _test-output-stream "03 *(ebp+0x00000008) 0x00000000/r32" "F - test-add-mem-to-reg") + # . epilogue + 89/<- %esp 5/r32/ebp + 5d/pop-to-ebp + c3/return + test-add-literal-to-reg: # var1/eax <- add 0x34 # => diff --git a/apps/pack b/apps/pack index 8835b079..2df718bb 100755 Binary files a/apps/pack and b/apps/pack differ diff --git a/apps/sigils b/apps/sigils index ea2d3db2..a0599e03 100755 Binary files a/apps/sigils and b/apps/sigils differ diff --git a/apps/subx-params.subx b/apps/subx-params.subx index 38a34314..bdf7783f 100644 --- a/apps/subx-params.subx +++ b/apps/subx-params.subx @@ -13,3 +13,7 @@ Input-size: # number of labels we can translate to addresses Max-labels: 0x10000/imm32/4K-labels/64KB + +# capacity of trace-stream +Trace-size: + 0x80000/imm32/512KB diff --git a/apps/survey b/apps/survey index 6a99c20c..59d457fa 100755 Binary files a/apps/survey and b/apps/survey differ diff --git a/apps/survey.subx b/apps/survey.subx index 87d519f3..70557261 100644 --- a/apps/survey.subx +++ b/apps/survey.subx @@ -23,7 +23,7 @@ # The output is the stream of bytes without segment headers or label definitions, # and with label references replaced with numeric values/displacements. # -# $ cat x |./subx run apps/assort +# $ cat x |./subx run apps/survey # ...ELF header bytes... # # ELF header above will specify that code segment begins at this offset # aa bb nn # some computed address @@ -53,9 +53,9 @@ Entry: # run tests if necessary, convert stdin if not e8/call new-segment/disp32 # . . discard args 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32 # add to esp - # initialize-trace-stream(256KB) + # initialize-trace-stream(Trace-size) # . . push args - 68/push 0x40000/imm32/256KB + 68/push Trace-size/imm32 # . . call e8/call initialize-trace-stream/disp32 # . . discard args diff --git a/apps/tests b/apps/tests index 31eab508..68009fe7 100755 Binary files a/apps/tests and b/apps/tests differ -- cgit 1.4.1-2-gfad0