Base address in unpack_pair.

This commit is contained in:
Simon Forman 2019-11-09 15:12:44 -08:00
parent bcadc95aa3
commit e4c17f8c24
1 changed files with 6 additions and 6 deletions

View File

@ -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
].