diff --git a/thun/compiler.markII.pl b/thun/compiler.markII.pl index 9821a66..3f118d2 100644 --- a/thun/compiler.markII.pl +++ b/thun/compiler.markII.pl @@ -114,12 +114,12 @@ Mark II label(Cons)], % Let's cons. - ⟐(unpack_pair(TOS, TEMP0, TOS)), + ⟐(unpack_pair(TOS, TEMP0, TOS, SP)), % TEMP0 = Address of the list to which to append. % TOS = Address of the second stack cell. [load_word(TEMP1, TOS, 0)], % TEMP1 contains the record of the second stack cell. - ⟐(unpack_pair(TEMP1, TEMP2, TEMP3)), + ⟐(unpack_pair(TEMP1, TEMP2, TEMP3, TOS)), % TEMP2 contains the address of the second item on the stack % TEMP3 = TOS + TEMP1[15:0] the address of the third stack cell @@ -168,20 +168,20 @@ language. and_imm(Reg, Reg, 0x7fff), % Mask off high bits. label(Label)]. -⟐(unpack_pair(From, HeadAddr, TailAddr)) --> +⟐(unpack_pair(From, HeadAddr, TailAddr, Base)) --> [ lsl_imm(HeadAddr, From, 2), % Trim off the type tag 00 bits. asr_imm(HeadAddr, HeadAddr, 17), % HeadAddr := From >> 15 eq_offset(Label0), % if the offset is zero don't add the address. it's empty list. - add(HeadAddr, HeadAddr, TOS), + add(HeadAddr, HeadAddr, Base), label(Label0), % HeadAddr contains the address of the second item on the stack lsl_imm(TailAddr, From, 17), % Get the offset of the third stack cell asr_imm(TailAddr, TailAddr, 17), % while preserving the sign. eq_offset(Label1), % if the offset is zero don't add the address. it's empty list. - add(TailAddr, TailAddr, TOS), + add(TailAddr, TailAddr, Base), label(Label1) - % TailAddr = TOS + From[15:0] the address of the third stack cell + % TailAddr = Base + From[15:0] the address of the third stack cell ].