word works with negative numbers now.
symbols moved to head of machine code.
This commit is contained in:
parent
4a39d82c75
commit
2e301fa6c3
|
|
@ -1,97 +1,111 @@
|
||||||
[word(0),
|
[word(0),
|
||||||
do_offset(_7910),
|
do_offset(_2170),
|
||||||
allocate(_7920,20),
|
allocate(_2180,20),
|
||||||
label(_7910),
|
label(_2170),
|
||||||
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,_7982),
|
mov_imm(1,_2242),
|
||||||
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),
|
||||||
label(_8030),
|
labelv_imm(3,0),
|
||||||
|
store_word(2,0,0),
|
||||||
|
label(_2290),
|
||||||
sub_imm(1,1,0),
|
sub_imm(1,1,0),
|
||||||
eq_offset(_8042),
|
eq_offset(_2302),
|
||||||
load_word(4,1,0),
|
load_word(4,1,0),
|
||||||
lsl_imm(5,4,2),
|
lsl_imm(5,4,2),
|
||||||
asr_imm(5,5,17),
|
asr_imm(5,5,17),
|
||||||
eq_offset(_8158),
|
eq_offset(_24346,4,17),
|
||||||
|
asr_imm(6,6,17),
|
||||||
|
eq_offset(),
|
||||||
add(5,5,1),
|
add(5,5,1),
|
||||||
label(_8158),
|
label(_2434),
|
||||||
lsl_imm(6,4,17),
|
lsl_imm(6,4,17),
|
||||||
asr_imm(6,6,17),
|
asr_imm(6,6,17),
|
||||||
eq_offset(_8220),
|
eq_offset(_2502),
|
||||||
add(6,6,1),
|
add(6,6,1),
|
||||||
label(_8220),
|
label(_2502),
|
||||||
load_word(3,5,0),
|
load_word(3,5,0),
|
||||||
mov(1,6),
|
mov(1,6),
|
||||||
asr_imm(6,3,30),
|
asr_imm(6,3,t(6,16383),
|
||||||
|
ior_imm(6,6,65535),
|
||||||
|
and(30),
|
||||||
and_imm(6,6,2),
|
and_imm(6,6,2),
|
||||||
sub_imm(6,6,2),
|
sub_imm(6,6,2),
|
||||||
ne_offset(_8322),
|
ne_offset(_2564),
|
||||||
mov_imm_with_shift(6,16383),
|
mov_imm_with_shift(6,16383),
|
||||||
ior_imm(6,6,65535),
|
ior_imm(6,6,65535),
|
||||||
and(6,6,3),
|
and(6,6,3),
|
||||||
do(6),
|
do(6),
|
||||||
label(_8322),
|
label(_2564),
|
||||||
sub_imm(0,0,4),
|
sub_imm(0(_2810),
|
||||||
|
store_word(2,0,0),
|
||||||
|
do_offse,0,4),
|
||||||
sub(2,5,0),
|
sub(2,5,0),
|
||||||
hi_offset(_8424),
|
hi_offset(_2748),
|
||||||
and_imm(2,2,32767),
|
and_imm(2,2,32767),
|
||||||
label(_8424),
|
label(_2748),
|
||||||
lsl_imm(2,2,15),
|
lsl_imm(2,2,15),
|
||||||
ior_imm(2,2,4),
|
ior_imm(2,2,4),
|
||||||
label(_8486),
|
label(_2810),
|
||||||
store_word(2,0,0),
|
store_word(2,0,0),
|
||||||
do_offset(_8030),
|
do_offset,lsl_imm(2,2,17),
|
||||||
label(_8042),
|
asr_imm(2,2,17),
|
||||||
do_offset(_8042),
|
e(_2290),
|
||||||
label(_8540),
|
label(_2302),
|
||||||
|
do_offset(_2302),
|
||||||
|
label(_2864),
|
||||||
|
symbol(_2864),
|
||||||
lsl_imm(6,2,2),
|
lsl_imm(6,2,2),
|
||||||
asr_imm(6,6,17),
|
asr_imm(6,6,17),
|
||||||
eq_offset(_8656),
|
eq_offset(_3064),
|
||||||
add(6,6,0),
|
add(6,6,0),
|
||||||
label(_8656),
|
label(_3064),
|
||||||
lsl_imm(2,2,17),
|
9,7,17),
|
||||||
|
asr_imm(9,9,17),
|
||||||
|
eq_offset(lsl_imm(2,2,17),
|
||||||
asr_imm(2,2,17),
|
asr_imm(2,2,17),
|
||||||
eq_offset(_8718),
|
eq_offset(_3132),
|
||||||
add(2,2,0),
|
add(2,2,0),
|
||||||
label(_8718),
|
label(_3132),
|
||||||
load_word(7,2,0),
|
load_word(7,2,0),
|
||||||
lsl_imm(8,7,2),
|
lsl_imm(8,7,2),
|
||||||
asr_imm(8,8,17),
|
asr_imm(8,8,17),
|
||||||
eq_offset(_8794),
|
eq_offset(_3214)q_offset(_3394),
|
||||||
add(8,8,2),
|
sub(6,6,0),
|
||||||
label(_8794),
|
and_imm,add(8,8,2),
|
||||||
|
label(_3214),
|
||||||
lsl_imm(9,7,17),
|
lsl_imm(9,7,17),
|
||||||
asr_imm(9,9,17),
|
asr_imm(9,9,17),
|
||||||
eq_offset(_8856),
|
eq_offset(_3282),
|
||||||
add(9,9,2),
|
add(9,9,2),
|
||||||
label(_8856),
|
label(_3282),
|
||||||
sub_imm(0,0,4),
|
sub_imm(0,0,4),
|
||||||
sub_imm(8,8,0),
|
sub_imm(8,8,0),
|
||||||
eq_offset(_8900),
|
eq_offset,9,32767),
|
||||||
|
label(_3518),
|
||||||
|
mov_imm_wit(_3326),
|
||||||
sub(8,8,0),
|
sub(8,8,0),
|
||||||
and_imm(8,8,32767),
|
and_imm(8,8,32767),
|
||||||
label(_8900),
|
label(_3326),
|
||||||
sub_imm(6,6,0),
|
sub_imm(6,6,0),
|
||||||
eq_offset(_8968),
|
eq_offset(_3394),
|
||||||
sub(6,6,0),
|
sub(6,6,0),
|
||||||
and_imm(6,6,32767),
|
and_imm(6,6,32767),
|
||||||
label(_8968),
|
label(_3394),
|
||||||
lsl_imm(8,8,15),
|
lsl_imm(8,8,15),
|
||||||
ior(8,8,6),
|
ior(8,8,6),
|
||||||
store_word(8,0,0),
|
store_word(8,0,0),
|
||||||
sub_imm(0,0,4),
|
sub_imm(0,0,4),
|
||||||
sub_imm(9,9,0),
|
sub_imm(9,9,0),
|
||||||
eq_offset(_9114),
|
eq_offset(_3518),
|
||||||
sub(9,9,0),
|
sub(9,9,0),
|
||||||
and_imm(9,9,32767),
|
and_imm(9,9,32767),
|
||||||
label(_9114),
|
label(_3518),
|
||||||
mov_imm_with_shift(2,2),
|
mov_imm_with_shift(2,2),
|
||||||
ior(2,2,9),
|
ior(2,2,9),
|
||||||
do_offset(_8486),
|
do_offset(_2810),
|
||||||
label(_7982),
|
label(_2242),
|
||||||
expr_cell(_9232,0),
|
expr_cell(_2864,0)]
|
||||||
label(_9232),
|
|
||||||
symbol(_8540)]
|
|
||||||
|
|
@ -85,7 +85,7 @@ Mark II
|
||||||
% ======================================
|
% ======================================
|
||||||
],⟐([
|
],⟐([
|
||||||
|
|
||||||
label(Cons), % Let's cons.
|
definition(Cons), % Let's cons.
|
||||||
|
|
||||||
unpack_pair(TOS, TEMP0, TOS, SP),
|
unpack_pair(TOS, TEMP0, TOS, SP),
|
||||||
% TEMP0 = Address of the list to which to append.
|
% TEMP0 = Address of the list to which to append.
|
||||||
|
|
@ -107,8 +107,7 @@ Mark II
|
||||||
jump(Done) % Rely on mainloop::Done to write TOS to RAM.
|
jump(Done) % Rely on mainloop::Done to write TOS to RAM.
|
||||||
]),[
|
]),[
|
||||||
label(Expression),
|
label(Expression),
|
||||||
expr_cell(ConsSym, 0),
|
expr_cell(Cons, 0)
|
||||||
label(ConsSym), symbol(Cons)
|
|
||||||
].
|
].
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -172,6 +171,8 @@ language.
|
||||||
[mov_imm_with_shift(In, 2), % In := 4 << 15
|
[mov_imm_with_shift(In, 2), % In := 4 << 15
|
||||||
ior(In, In, Term)].
|
ior(In, In, Term)].
|
||||||
|
|
||||||
|
⟐(definition(Name)) --> [label(Name), symbol(Name)].
|
||||||
|
|
||||||
|
|
||||||
do :-
|
do :-
|
||||||
compile_program(Binary),
|
compile_program(Binary),
|
||||||
|
|
@ -218,9 +219,13 @@ asm([(N, Instruction)|Rest]) --> !, asm(N, Instruction), asm(Rest).
|
||||||
asm(Here, expr_cell(Func, NextCell)) --> !,
|
asm(Here, expr_cell(Func, NextCell)) --> !,
|
||||||
{Data is ((Func - Here) << 15) \/ NextCell}, asm(Here, word(Data)).
|
{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_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).
|
asm(_, load_byte(A, B, Offset)) --> !, instruction_format_F2(0, 1, A, B, Offset).
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -295,6 +295,23 @@ useful for appending lists to other lists.
|
||||||
|
|
||||||
Yeah, I think that's the way to go...
|
Yeah, I think that's the way to go...
|
||||||
|
|
||||||
|
---------------------------------------------
|
||||||
|
|
||||||
|
There's soething fishey with the symbols now that they are in the header
|
||||||
|
of the machine code. Each symbol's pointer field points to the next cell,
|
||||||
|
which seems really redundant. We need some symbol record to
|
||||||
|
differentiate from lists and ints. Maybe if more information was in the
|
||||||
|
header? Like the name of the function? It would make more sense?
|
||||||
|
|
||||||
|
Right now I'm assuming that the eventual parser would be looking up
|
||||||
|
symbols at parse-time and reusing the header symbols rather than
|
||||||
|
allocating cells for new ones. If the symbols were kept apart from the
|
||||||
|
machine code then it makes sense for them to have pointers?
|
||||||
|
|
||||||
|
Maybe I can dispense with symbol records by modifying the
|
||||||
|
is-this-a-symbol code to just check if the address is below the end of
|
||||||
|
the library code.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PC == 0
|
PC == 0
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue