This commit is contained in:
Simon Forman 2019-11-07 16:28:28 -08:00
parent 7bab15c64a
commit 65d55cf7b4
2 changed files with 12 additions and 9 deletions

View File

@ -133,7 +133,8 @@ CPUs.)
split_pair(TERM, TEMP1, EXPR, TEMP0),
% Now Term has the term's record data and temp1 has the address of the term.
if_literal(TERM, PUSH),
lookup(DICT_PTR, DICT_TOP, TERM, HALT), % Jump to command or if not found halt.
% if it is a symbol the rest of it is the pointer to the machine code.
lookup(TERM), % Jump to command.
label(PUSH), push(TOS, TERM, SP), % stack = TERM, stack
label(DONE), write_ram(SP, TOS), % RAM[SP] := TOS
jump(MAIN)
@ -316,14 +317,11 @@ language.
ior(TOS, TOS, SP)],
(write_cell(TOS, SP)).
(lookup(PTR, TOP, TERM, Exit)) -->
[mov(PTR, TOP), % point to the top of the dictionary.
label(Lookup),
sub(0, TERM, PTR), eq(PTR), % if the term is found jump to it,
sub_imm(PTR, PTR, 4), % else load the next pointer.
load_word(PTR, PTR, 0),
sub_imm(PTR, PTR, 0), eq_offset(Exit), % exit if it's zero.
do_offset(Lookup)]. % loop to the top.
(lookup(TERM)) -->
[mov_imm_with_shift(0, 0x3fff),
ior_imm(0, 0, 0xffff),
and(0, 0, TERM),
eq(0)]. % Jump to term's machine code.
(repeat_until(Condition, Body)) -->
{add_label(Condition, End, ConditionL)},

View File

@ -107,3 +107,8 @@ Next, we must check if the term is a literal (not a symbol)
That involves rolling the value to get the top two bits and then checking
whether they are 10 or not.
lookup(DICT_PTR, DICT_TOP, TERM, HALT)
It turns out that you don;t need anything but the record since it's
already been looked up. The symbol contains the jump address.