diff --git a/thun/asm-dump.txt b/thun/asm-dump.txt index 794d706..3aaa519 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, S1), +mov_imm(1, B2), mov_imm(2, 0), mov_imm(3, 0), store_word(2, 0, 0), @@ -243,8 +243,47 @@ ior(9, 9, 6), store_word(9, 0, 0), do_offset(H), label(S1), +symbol(S1), +mov_imm(2, T1), +do_offset(V1), +label(T1), +expr_cell(I1, 4), +expr_cell(J, 0), +label(U1), +symbol(U1), +mov_imm(2, W1), +do_offset(V1), +label(W1), +expr_cell(R, 4), +expr_cell(S, 0), +label(X1), +symbol(X1), +mov_imm(2, Y1), +do_offset(V1), +label(Y1), +expr_cell(J1, 4), +expr_cell(J, 0), +label(V1), +mov_imm(7, 4), +sub_imm(0, 0, 4), +sub_imm(2, 2, 0), +eq_offset(Z1), +sub(2, 2, 0), +and_imm(2, 2, 32767), +label(Z1), +sub_imm(7, 7, 0), +eq_offset(A2), +sub(7, 7, 0), +and_imm(7, 7, 32767), +label(A2), +lsl_imm(2, 2, 15), +ior(2, 2, 7), +store_word(2, 0, 0), +mov_imm(7, S), +add_imm(7, 7, 4), +do(7), +label(B2), expr_cell(I1, 4), expr_cell(R, 4), -expr_cell(J1, 4), -expr_cell(J, 4), +expr_cell(X1, 4), expr_cell(S, 0)]. \ No newline at end of file diff --git a/thun/compiler.markII.pl b/thun/compiler.markII.pl index 39e3bf9..1dd61ab 100644 --- a/thun/compiler.markII.pl +++ b/thun/compiler.markII.pl @@ -168,9 +168,21 @@ Mark II sub_base_merge_and_store(TEMP3, TEMP0, SP), % Push first item onto stack. jump(Main), + definition(Unit, [New, Cons], DoDef, TOS), + definition(X, [Dup, I], DoDef, TOS), + definition(Swons, [Swap, Cons], DoDef, TOS), + + label(DoDef), % TOS points to body expr, set by definition. + asm(mov_imm(TEMP1, 4)), % Used for linking to previous cell. + incr(SP), + sub_base_merge_and_store(TOS, TEMP1, SP), % Push body expr onto stack. + asm(mov_imm(TEMP1, I)), % Get address of I's machine code. + asm(add_imm(TEMP1, TEMP1, 4)), + asm(do(TEMP1)), + % ====================================== label(Expression), - dexpr([New, Dup, Swap, Cons, I]) + dexpr([New, Dup, Swons, I]) ]). @@ -244,6 +256,12 @@ language. ⟐(definition(Name)) --> [label(Name), symbol(Name)]. +⟐(definition(Name, Body, DoDef, TEMP)) --> ⟐(definition(Name)), + [mov_imm(TEMP, BodyList), + do_offset(DoDef), + label(BodyList)], + dexpr(Body). + ⟐(head_addr(Pair, HeadAddr)) --> [lsl_imm(HeadAddr, Pair, 2), asr_imm(HeadAddr, HeadAddr, 17)]. ⟐(repeat_until(Condition, Body)) --> diff --git a/thun/joy_asmii.bin b/thun/joy_asmii.bin index 5e85ec7..9e6a2a1 100644 Binary files a/thun/joy_asmii.bin and b/thun/joy_asmii.bin differ