diff options
author | Kartik Agaram <vc@akkartik.com> | 2019-11-26 22:11:23 -0800 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2019-11-26 22:11:23 -0800 |
commit | 70187b1c01a0540bc677fbbfeaef129549d3075d (patch) | |
tree | ac869a1cabf2d0bf839cfbe93e22d304662e4693 /apps | |
parent | 55628fb6932c0468ca7f20db6ed3ec454be8c91f (diff) | |
download | mu-70187b1c01a0540bc677fbbfeaef129549d3075d.tar.gz |
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.
Diffstat (limited to 'apps')
-rwxr-xr-x | apps/assort | bin | 42893 -> 42897 bytes | |||
-rwxr-xr-x | apps/braces | bin | 42908 -> 42912 bytes | |||
-rwxr-xr-x | apps/calls | bin | 47619 -> 47623 bytes | |||
-rwxr-xr-x | apps/dquotes | bin | 46543 -> 46547 bytes | |||
-rwxr-xr-x | apps/hex | bin | 45139 -> 45143 bytes | |||
-rwxr-xr-x | apps/mu | bin | 53140 -> 53751 bytes | |||
-rw-r--r-- | apps/mu.subx | 112 | ||||
-rwxr-xr-x | apps/pack | bin | 55284 -> 55288 bytes | |||
-rwxr-xr-x | apps/sigils | bin | 55294 -> 55298 bytes | |||
-rw-r--r-- | apps/subx-params.subx | 4 | ||||
-rwxr-xr-x | apps/survey | bin | 52133 -> 52137 bytes | |||
-rw-r--r-- | apps/survey.subx | 6 | ||||
-rwxr-xr-x | 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 --- a/apps/assort +++ b/apps/assort Binary files differdiff --git a/apps/braces b/apps/braces index e1fa64e5..14c0ccf3 100755 --- a/apps/braces +++ b/apps/braces Binary files differdiff --git a/apps/calls b/apps/calls index d429db9c..4a0e624e 100755 --- a/apps/calls +++ b/apps/calls Binary files differdiff --git a/apps/dquotes b/apps/dquotes index 43858006..e29314af 100755 --- a/apps/dquotes +++ b/apps/dquotes Binary files differdiff --git a/apps/hex b/apps/hex index 6c1d41f6..cc517a6e 100755 --- a/apps/hex +++ b/apps/hex Binary files differdiff --git a/apps/mu b/apps/mu index b8aad9cd..25d5ed3d 100755 --- a/apps/mu +++ b/apps/mu Binary files differdiff --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 --- a/apps/pack +++ b/apps/pack Binary files differdiff --git a/apps/sigils b/apps/sigils index ea2d3db2..a0599e03 100755 --- a/apps/sigils +++ b/apps/sigils Binary files differdiff --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 --- a/apps/survey +++ b/apps/survey Binary files differdiff --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 --- a/apps/tests +++ b/apps/tests Binary files differ |