[word(0),\r
-do_offset(_7910),\r
-allocate(_7920,20),\r
-label(_7910),\r
+do_offset(_2170),\r
+allocate(_2180,20),\r
+label(_2170),\r
mov_imm(0,0),\r
store_word(0,0,0),\r
mov_imm(0,4096),\r
-mov_imm(1,_7982),\r
+mov_imm(1,_2242),\r
mov_imm(2,0),\r
mov_imm(3,0),\r
store_word(2,0,0),\r
-label(_8030),\r
+labelv_imm(3,0),\r
+store_word(2,0,0),\r
+label(_2290),\r
sub_imm(1,1,0),\r
-eq_offset(_8042),\r
+eq_offset(_2302),\r
load_word(4,1,0),\r
lsl_imm(5,4,2),\r
asr_imm(5,5,17),\r
-eq_offset(_8158),\r
+eq_offset(_24346,4,17),\r
+asr_imm(6,6,17),\r
+eq_offset(),\r
add(5,5,1),\r
-label(_8158),\r
+label(_2434),\r
lsl_imm(6,4,17),\r
asr_imm(6,6,17),\r
-eq_offset(_8220),\r
+eq_offset(_2502),\r
add(6,6,1),\r
-label(_8220),\r
+label(_2502),\r
load_word(3,5,0),\r
mov(1,6),\r
-asr_imm(6,3,30),\r
+asr_imm(6,3,t(6,16383),\r
+ior_imm(6,6,65535),\r
+and(30),\r
and_imm(6,6,2),\r
sub_imm(6,6,2),\r
-ne_offset(_8322),\r
+ne_offset(_2564),\r
mov_imm_with_shift(6,16383),\r
ior_imm(6,6,65535),\r
and(6,6,3),\r
do(6),\r
-label(_8322),\r
-sub_imm(0,0,4),\r
+label(_2564),\r
+sub_imm(0(_2810),\r
+store_word(2,0,0),\r
+do_offse,0,4),\r
sub(2,5,0),\r
-hi_offset(_8424),\r
+hi_offset(_2748),\r
and_imm(2,2,32767),\r
-label(_8424),\r
+label(_2748),\r
lsl_imm(2,2,15),\r
ior_imm(2,2,4),\r
-label(_8486),\r
+label(_2810),\r
store_word(2,0,0),\r
-do_offset(_8030),\r
-label(_8042),\r
-do_offset(_8042),\r
-label(_8540),\r
+do_offset,lsl_imm(2,2,17),\r
+asr_imm(2,2,17),\r
+e(_2290),\r
+label(_2302),\r
+do_offset(_2302),\r
+label(_2864),\r
+symbol(_2864),\r
lsl_imm(6,2,2),\r
asr_imm(6,6,17),\r
-eq_offset(_8656),\r
+eq_offset(_3064),\r
add(6,6,0),\r
-label(_8656),\r
-lsl_imm(2,2,17),\r
+label(_3064),\r
+9,7,17),\r
+asr_imm(9,9,17),\r
+eq_offset(lsl_imm(2,2,17),\r
asr_imm(2,2,17),\r
-eq_offset(_8718),\r
+eq_offset(_3132),\r
add(2,2,0),\r
-label(_8718),\r
+label(_3132),\r
load_word(7,2,0),\r
lsl_imm(8,7,2),\r
asr_imm(8,8,17),\r
-eq_offset(_8794),\r
-add(8,8,2),\r
-label(_8794),\r
+eq_offset(_3214)q_offset(_3394),\r
+sub(6,6,0),\r
+and_imm,add(8,8,2),\r
+label(_3214),\r
lsl_imm(9,7,17),\r
asr_imm(9,9,17),\r
-eq_offset(_8856),\r
+eq_offset(_3282),\r
add(9,9,2),\r
-label(_8856),\r
+label(_3282),\r
sub_imm(0,0,4),\r
sub_imm(8,8,0),\r
-eq_offset(_8900),\r
+eq_offset,9,32767),\r
+label(_3518),\r
+mov_imm_wit(_3326),\r
sub(8,8,0),\r
and_imm(8,8,32767),\r
-label(_8900),\r
+label(_3326),\r
sub_imm(6,6,0),\r
-eq_offset(_8968),\r
+eq_offset(_3394),\r
sub(6,6,0),\r
and_imm(6,6,32767),\r
-label(_8968),\r
+label(_3394),\r
lsl_imm(8,8,15),\r
ior(8,8,6),\r
store_word(8,0,0),\r
sub_imm(0,0,4),\r
sub_imm(9,9,0),\r
-eq_offset(_9114),\r
+eq_offset(_3518),\r
sub(9,9,0),\r
and_imm(9,9,32767),\r
-label(_9114),\r
+label(_3518),\r
mov_imm_with_shift(2,2),\r
ior(2,2,9),\r
-do_offset(_8486),\r
-label(_7982),\r
-expr_cell(_9232,0),\r
-label(_9232),\r
-symbol(_8540)]
\ No newline at end of file
+do_offset(_2810),\r
+label(_2242),\r
+expr_cell(_2864,0)]
\ No newline at end of file
% ======================================
],⟐([
- label(Cons), % Let's cons.
+ definition(Cons), % Let's cons.
unpack_pair(TOS, TEMP0, TOS, SP),
% TEMP0 = Address of the list to which to append.
jump(Done) % Rely on mainloop::Done to write TOS to RAM.
]),[
label(Expression),
- expr_cell(ConsSym, 0),
- label(ConsSym), symbol(Cons)
+ expr_cell(Cons, 0)
].
[mov_imm_with_shift(In, 2), % In := 4 << 15
ior(In, In, Term)].
+⟐(definition(Name)) --> [label(Name), symbol(Name)].
+
do :-
compile_program(Binary),
asm(Here, expr_cell(Func, NextCell)) --> !,
{Data is ((Func - Here) << 15) \/ NextCell}, asm(Here, word(Data)).
-asm(_, symbol(Sym)) --> !, {Data is Sym \/ 0x80000000}, asm(_, word(Data)).
+asm(_, symbol(Sym)) --> !, {Data is (Sym + 4) \/ 0x80000000}, asm(_, word(Data)).
+% The symbol is at the beginning of the function machine code, so the pointer it
+% holds to that code has to be one word beyond the pointer/label Sym that points
+% to the symbol itself (one word before the machine code.) The symbol's address
+% is used in expressions.
-asm(_, word(Word)) --> !, {binary_number(Bits, Word)}, collect(32, Bits).
+asm(_, word(Word)) --> !, encode_int(32, Word).
asm(_, load_word(A, B, Offset)) --> !, instruction_format_F2(0, 0, A, B, Offset).
asm(_, load_byte(A, B, Offset)) --> !, instruction_format_F2(0, 1, A, B, Offset).
\r
Yeah, I think that's the way to go...\r
\r
+---------------------------------------------\r
+\r
+There's soething fishey with the symbols now that they are in the header\r
+of the machine code. Each symbol's pointer field points to the next cell,\r
+which seems really redundant. We need some symbol record to\r
+differentiate from lists and ints. Maybe if more information was in the\r
+header? Like the name of the function? It would make more sense?\r
+\r
+Right now I'm assuming that the eventual parser would be looking up\r
+symbols at parse-time and reusing the header symbols rather than\r
+allocating cells for new ones. If the symbols were kept apart from the\r
+machine code then it makes sense for them to have pointers?\r
+\r
+Maybe I can dispense with symbol records by modifying the\r
+is-this-a-symbol code to just check if the address is below the end of\r
+the library code.\r
+\r
\r
\r
PC == 0\r