"new" word.
This commit is contained in:
parent
4cba943355
commit
4faebb4551
|
|
@ -5,7 +5,7 @@ label(A),
|
||||||
mov_imm(0, 0),
|
mov_imm(0, 0),
|
||||||
store_word(0, 0, 0),
|
store_word(0, 0, 0),
|
||||||
mov_imm(0, 4096),
|
mov_imm(0, 4096),
|
||||||
mov_imm(1, I1),
|
mov_imm(1, J1),
|
||||||
mov_imm(2, 0),
|
mov_imm(2, 0),
|
||||||
mov_imm(3, 0),
|
mov_imm(3, 0),
|
||||||
store_word(2, 0, 0),
|
store_word(2, 0, 0),
|
||||||
|
|
@ -186,6 +186,11 @@ ior(6, 6, 7),
|
||||||
store_word(6, 0, 0),
|
store_word(6, 0, 0),
|
||||||
do_offset(H),
|
do_offset(H),
|
||||||
label(I1),
|
label(I1),
|
||||||
|
symbol(I1),
|
||||||
|
mov_imm(5, 0),
|
||||||
|
do_offset(D),
|
||||||
|
label(J1),
|
||||||
|
expr_cell(I1, 4),
|
||||||
expr_cell(R, 4),
|
expr_cell(R, 4),
|
||||||
expr_cell(J, 4),
|
expr_cell(J, 4),
|
||||||
expr_cell(S, 0)].
|
expr_cell(S, 0)].
|
||||||
|
|
@ -109,9 +109,7 @@ Mark II
|
||||||
head_addr(TOS, TermAddr),
|
head_addr(TOS, TermAddr),
|
||||||
jump(PUSH),
|
jump(PUSH),
|
||||||
|
|
||||||
|
|
||||||
definition(I), % ======================================
|
definition(I), % ======================================
|
||||||
|
|
||||||
unpack_pair(TOS, TEMP0, TOS, SP),
|
unpack_pair(TOS, TEMP0, TOS, SP),
|
||||||
% TEMP0 = Address of the quoted program.
|
% TEMP0 = Address of the quoted program.
|
||||||
% TOS = Address of the stack tail.
|
% 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.
|
asm(mov(TEMP0, TEMP2)), % update temp0 to point to rest of quoted program.
|
||||||
incr(SP), % We are about to write a cell.
|
incr(SP), % We are about to write a cell.
|
||||||
br(if_zero(TEMP2),
|
br(if_zero(TEMP2),
|
||||||
[ % TERM is the last item in the quoted program.
|
[sub_base_merge_and_store(TEMP1, EXPR_addr, SP)],
|
||||||
% The expr should point to a cell that has TEMP1 head and tail
|
% TERM is the last item in the quoted program.
|
||||||
% of the rest of the expression.
|
% The expr should point to a cell that has TEMP1 head and tail
|
||||||
sub_base_merge_and_store(TEMP1, EXPR_addr, SP)
|
% of the rest of the expression.
|
||||||
], [ % TERM has at least one more item after it.
|
[merge_and_store(TEMP1, TEMP3, SP)]
|
||||||
% We know that we will be writing that item in a
|
% TERM has at least one more item after it.
|
||||||
% cell immediately after this one, so it has TEMP1
|
% We know that we will be writing that item in a
|
||||||
% head and 4 for the tail.
|
% cell immediately after this one, so it has TEMP1
|
||||||
merge_and_store(TEMP1, TEMP3, SP)
|
% head and 4 for the tail.
|
||||||
]
|
|
||||||
)
|
)
|
||||||
]),
|
]),
|
||||||
asm(mov(EXPR_addr, TEMP4))
|
asm(mov(EXPR_addr, TEMP4))
|
||||||
|
|
@ -147,17 +144,18 @@ Mark II
|
||||||
load(TEMP1, TOS), % TEMP1 contains the record of the second stack cell.
|
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
|
% 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.
|
% 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),
|
incr(SP),
|
||||||
sub_base_merge_and_store(TEMP0, TEMP1, SP),
|
sub_base_merge_and_store(TEMP0, TEMP1, SP),
|
||||||
jump(Main), % We already wrote the stack cell so 'Main' not 'Done'.
|
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),
|
label(Expression),
|
||||||
dexpr([Dup, Cons, I])
|
dexpr([New, Dup, Cons, I])
|
||||||
]).
|
]).
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -377,6 +377,25 @@ the library code.
|
||||||
],
|
],
|
||||||
ヮ(i),
|
ヮ(i),
|
||||||
|
|
||||||
|
|
||||||
|
------------------------------------------
|
||||||
|
|
||||||
|
[ヶ,ペ],ワ(new),
|
||||||
|
|
||||||
|
ヶ, low_half(TOS, SP)
|
||||||
|
ペ, write_cell(TOS, SP)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PC == 0
|
PC == 0
|
||||||
PC == 0x25
|
PC == 0x25
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue