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 1cdbbe6..3dbcebc 100644 Binary files a/thun/joy_asmii.bin and b/thun/joy_asmii.bin differ diff --git a/thun/markII.rst b/thun/markII.rst index c1e2c54..f6d5a02 100644 --- a/thun/markII.rst +++ b/thun/markII.rst @@ -377,6 +377,25 @@ the library code. ], ヮ(i), + +------------------------------------------ + + [ヶ,ペ],ワ(new), + + ヶ, low_half(TOS, SP) + ペ, write_cell(TOS, SP) + + + + + + + + + + + + PC == 0 PC == 0x25