From 4faebb45511d90297df123340deedbf28df39c39 Mon Sep 17 00:00:00 2001 From: Simon Forman Date: Tue, 12 Nov 2019 15:47:33 -0800 Subject: [PATCH] "new" word. --- thun/asm-dump.txt | 7 ++++++- thun/compiler.markII.pl | 30 ++++++++++++++---------------- thun/joy_asmii.bin | Bin 652 -> 668 bytes thun/markII.rst | 19 +++++++++++++++++++ 4 files changed, 39 insertions(+), 17 deletions(-) diff --git a/thun/asm-dump.txt b/thun/asm-dump.txt index 2db71c5..cd7d796 100644 --- a/thun/asm-dump.txt +++ b/thun/asm-dump.txt @@ -5,7 +5,7 @@ label(A), mov_imm(0, 0), store_word(0, 0, 0), mov_imm(0, 4096), -mov_imm(1, I1), +mov_imm(1, J1), mov_imm(2, 0), mov_imm(3, 0), store_word(2, 0, 0), @@ -186,6 +186,11 @@ ior(6, 6, 7), store_word(6, 0, 0), do_offset(H), label(I1), +symbol(I1), +mov_imm(5, 0), +do_offset(D), +label(J1), +expr_cell(I1, 4), expr_cell(R, 4), expr_cell(J, 4), expr_cell(S, 0)]. \ No newline at end of file diff --git a/thun/compiler.markII.pl b/thun/compiler.markII.pl index 5ea634f..e7e7221 100644 --- a/thun/compiler.markII.pl +++ b/thun/compiler.markII.pl @@ -109,9 +109,7 @@ Mark II head_addr(TOS, TermAddr), jump(PUSH), - definition(I), % ====================================== - unpack_pair(TOS, TEMP0, TOS, SP), % TEMP0 = Address of the quoted program. % TOS = Address of the stack tail. @@ -127,16 +125,15 @@ Mark II asm(mov(TEMP0, TEMP2)), % update temp0 to point to rest of quoted program. incr(SP), % We are about to write a cell. br(if_zero(TEMP2), - [ % TERM is the last item in the quoted program. - % The expr should point to a cell that has TEMP1 head and tail - % of the rest of the expression. - sub_base_merge_and_store(TEMP1, EXPR_addr, SP) - ], [ % TERM has at least one more item after it. - % We know that we will be writing that item in a - % cell immediately after this one, so it has TEMP1 - % head and 4 for the tail. - merge_and_store(TEMP1, TEMP3, SP) - ] + [sub_base_merge_and_store(TEMP1, EXPR_addr, SP)], + % TERM is the last item in the quoted program. + % The expr should point to a cell that has TEMP1 head and tail + % of the rest of the expression. + [merge_and_store(TEMP1, TEMP3, SP)] + % TERM has at least one more item after it. + % We know that we will be writing that item in a + % cell immediately after this one, so it has TEMP1 + % head and 4 for the tail. ) ]), asm(mov(EXPR_addr, TEMP4)) @@ -147,17 +144,18 @@ Mark II load(TEMP1, TOS), % TEMP1 contains the record of the second stack cell. % write a new cell, the head is head of TEMP1, the tail is tail of TEMP1 % but adjusted to offset from SP+4 where we are about to write this record. - % Load tos with ram[tos] - unpack_pair(TEMP1, TEMP0, TEMP1, TOS), - % TEMP0 = HeadAddr, TEMP1 = TailAddr + unpack_pair(TEMP1, TEMP0, TEMP1, TOS), % TEMP0 = HeadAddr, TEMP1 = TailAddr incr(SP), sub_base_merge_and_store(TEMP0, TEMP1, SP), jump(Main), % We already wrote the stack cell so 'Main' not 'Done'. + definition(New), % ====================================== + asm(mov_imm(TermAddr, 0)), % Rely on push machinery. + jump(PUSH), % ====================================== label(Expression), - dexpr([Dup, Cons, I]) + dexpr([New, Dup, Cons, I]) ]). diff --git a/thun/joy_asmii.bin b/thun/joy_asmii.bin index 1cdbbe6cf1f7aafe51c726ab22171ea311743eeb..3dbcebc44717b9eb2fe5af839ae7ede7d57d5db8 100644 GIT binary patch delta 48 zcmeBSox{pFVIreGW5Y&6ZzhEbCWZzE1_syW|Noz}F#P(@!jJ{TGXEJE@_?9u0RU=f B4)Op1 delta 32 mcmbQk+QZ7&Fp*K8v1Fs6H