load
This commit is contained in:
parent
8ee9a05780
commit
04b021846a
|
|
@ -1,97 +1,97 @@
|
||||||
[word(0),
|
[word(0),
|
||||||
do_offset(_5170),
|
do_offset(_6814),
|
||||||
allocate(_5180,20),
|
allocate(_6824,20),
|
||||||
label(_5170),
|
label(_6814),
|
||||||
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,_5242),
|
mov_imm(1,_6886),
|
||||||
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(_5290),
|
label(_6934),
|
||||||
sub_imm(1,1,0),
|
sub_imm(1,1,0),
|
||||||
eq_offset(_5296),
|
eq_offset(_6946),
|
||||||
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(_5372),
|
eq_offset(_7034),
|
||||||
add(5,5,1),
|
add(5,5,1),
|
||||||
label(_5372),
|
label(_7034),
|
||||||
load_word(3,5,0),
|
load_word(3,5,0),
|
||||||
lsl_imm(6,4,17),
|
lsl_imm(6,4,17),
|
||||||
asr_imm(6,6,17),
|
asr_imm(6,6,17),
|
||||||
eq_offset(_5448),
|
eq_offset(_7110),
|
||||||
add(6,6,1),
|
add(6,6,1),
|
||||||
label(_5448),
|
label(_7110),
|
||||||
mov(1,6),
|
mov(1,6),
|
||||||
asr_imm(6,3,30),
|
asr_imm(6,3,30),
|
||||||
and_imm(6,6,2),
|
and_imm(6,6,2),
|
||||||
sub_imm(6,6,2),
|
sub_imm(6,6,2),
|
||||||
ne_offset(_5536),
|
ne_offset(_7198),
|
||||||
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(_5536),
|
label(_7198),
|
||||||
sub_imm(0,0,4),
|
sub_imm(0,0,4),
|
||||||
sub(2,5,0),
|
sub(2,5,0),
|
||||||
hi_offset(_5634),
|
hi_offset(_7296),
|
||||||
and_imm(2,2,32767),
|
and_imm(2,2,32767),
|
||||||
label(_5634),
|
label(_7296),
|
||||||
lsl_imm(2,2,15),
|
lsl_imm(2,2,15),
|
||||||
ior_imm(2,2,4),
|
ior_imm(2,2,4),
|
||||||
label(_5696),
|
label(_7358),
|
||||||
store_word(2,0,0),
|
store_word(2,0,0),
|
||||||
do_offset(_5290),
|
do_offset(_6934),
|
||||||
label(_5296),
|
label(_6946),
|
||||||
do_offset(_5296),
|
do_offset(_6946),
|
||||||
label(_5750),
|
label(_7412),
|
||||||
lsl_imm(6,2,2),
|
lsl_imm(6,2,2),
|
||||||
asr_imm(6,6,17),
|
asr_imm(6,6,17),
|
||||||
eq_offset(_5798),
|
eq_offset(_7494),
|
||||||
add(6,6,0),
|
add(6,6,0),
|
||||||
label(_5798),
|
label(_7494),
|
||||||
lsl_imm(2,2,17),
|
lsl_imm(2,2,17),
|
||||||
asr_imm(2,2,17),
|
asr_imm(2,2,17),
|
||||||
eq_offset(_5860),
|
eq_offset(_7556),
|
||||||
add(2,2,0),
|
add(2,2,0),
|
||||||
label(_5860),
|
label(_7556),
|
||||||
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(_5946),
|
eq_offset(_7632),
|
||||||
add(8,8,2),
|
add(8,8,2),
|
||||||
label(_5946),
|
label(_7632),
|
||||||
lsl_imm(9,7,17),
|
lsl_imm(9,7,17),
|
||||||
asr_imm(9,9,17),
|
asr_imm(9,9,17),
|
||||||
eq_offset(_6008),
|
eq_offset(_7694),
|
||||||
add(9,9,2),
|
add(9,9,2),
|
||||||
label(_6008),
|
label(_7694),
|
||||||
sub_imm(0,0,4),
|
sub_imm(0,0,4),
|
||||||
sub_imm(8,8,0),
|
sub_imm(8,8,0),
|
||||||
eq_offset(_6076),
|
eq_offset(_7762),
|
||||||
sub(8,8,0),
|
sub(8,8,0),
|
||||||
and_imm(8,8,32767),
|
and_imm(8,8,32767),
|
||||||
label(_6076),
|
label(_7762),
|
||||||
sub_imm(6,6,0),
|
sub_imm(6,6,0),
|
||||||
eq_offset(_6144),
|
eq_offset(_7830),
|
||||||
sub(6,6,0),
|
sub(6,6,0),
|
||||||
and_imm(6,6,32767),
|
and_imm(6,6,32767),
|
||||||
label(_6144),
|
label(_7830),
|
||||||
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(_6274),
|
eq_offset(_7960),
|
||||||
sub(9,9,0),
|
sub(9,9,0),
|
||||||
and_imm(9,9,32767),
|
and_imm(9,9,32767),
|
||||||
label(_6274),
|
label(_7960),
|
||||||
mov_imm_with_shift(2,2),
|
mov_imm_with_shift(2,2),
|
||||||
ior(2,2,9),
|
ior(2,2,9),
|
||||||
do_offset(_5696),
|
do_offset(_7358),
|
||||||
label(_5242),
|
label(_6886),
|
||||||
expr_cell(_6392,0),
|
expr_cell(_8078,0),
|
||||||
label(_6392),
|
label(_8078),
|
||||||
symbol(_5750)]
|
symbol(_7412)]
|
||||||
|
|
@ -45,14 +45,11 @@ Mark II
|
||||||
store_word(TOS, SP, 0), % RAM[SP] := 0
|
store_word(TOS, SP, 0), % RAM[SP] := 0
|
||||||
|
|
||||||
label(Main)],
|
label(Main)],
|
||||||
|
⟐([
|
||||||
⟐(if_zero(EXPR_addr, HALT)),
|
if_zero(EXPR_addr, HALT),
|
||||||
|
load(EXPR, EXPR_addr)
|
||||||
% deref(EXPR_addr, EXPR),
|
]),[
|
||||||
[load_word(EXPR, EXPR_addr, 0), % Load expr pair record into EXPR
|
|
||||||
|
|
||||||
% At this point EXPR holds the record word of the expression.
|
% At this point EXPR holds the record word of the expression.
|
||||||
|
|
||||||
lsl_imm(TermAddr, EXPR, 2), % Trim off the type tag 00 bits.
|
lsl_imm(TermAddr, EXPR, 2), % Trim off the type tag 00 bits.
|
||||||
asr_imm(TermAddr, TermAddr, 17), % preserve sign of offset.
|
asr_imm(TermAddr, TermAddr, 17), % preserve sign of offset.
|
||||||
eq_offset(Foo), % if the offset is zero don't add the address. it's empty list.
|
eq_offset(Foo), % if the offset is zero don't add the address. it's empty list.
|
||||||
|
|
@ -112,19 +109,19 @@ Mark II
|
||||||
|
|
||||||
% ======================================
|
% ======================================
|
||||||
|
|
||||||
label(Cons)], % Let's cons.
|
label(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.
|
||||||
% TOS = Address of the second stack cell.
|
% TOS = Address of the second stack cell.
|
||||||
[load_word(TEMP1, TOS, 0)],
|
load(TEMP1, TOS),
|
||||||
% TEMP1 contains the record of the second stack cell.
|
% TEMP1 contains the record of the second stack cell.
|
||||||
⟐(unpack_pair(TEMP1, TEMP2, TEMP3, TOS)),
|
unpack_pair(TEMP1, TEMP2, TEMP3, TOS)
|
||||||
|
]),[
|
||||||
% TEMP2 contains the address of the second item on the stack
|
% TEMP2 contains the address of the second item on the stack
|
||||||
% TEMP3 = TOS + TEMP1[15:0] the address of the third stack cell
|
% TEMP3 = TOS + TEMP1[15:0] the address of the third stack cell
|
||||||
|
|
||||||
% Build and write the new list cell.
|
% Build and write the new list cell.
|
||||||
[
|
|
||||||
sub_imm(SP, SP, 4)
|
sub_imm(SP, SP, 4)
|
||||||
|
|
||||||
],⟐([
|
],⟐([
|
||||||
|
|
@ -169,21 +166,18 @@ language.
|
||||||
label(Label)].
|
label(Label)].
|
||||||
|
|
||||||
⟐(unpack_pair(From, HeadAddr, TailAddr, Base)) -->
|
⟐(unpack_pair(From, HeadAddr, TailAddr, Base)) -->
|
||||||
[
|
[lsl_imm(HeadAddr, From, 2), % Trim off the type tag 00 bits.
|
||||||
lsl_imm(HeadAddr, From, 2), % Trim off the type tag 00 bits.
|
asr_imm(HeadAddr, HeadAddr, 17), % HeadAddr := From >> 15
|
||||||
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.
|
||||||
eq_offset(Label0), % if the offset is zero don't add the address. it's empty list.
|
add(HeadAddr, HeadAddr, Base),
|
||||||
add(HeadAddr, HeadAddr, Base),
|
label(Label0),
|
||||||
label(Label0),
|
lsl_imm(TailAddr, From, 17), % Get the offset of the third stack cell
|
||||||
% HeadAddr contains the address of the second item on the stack
|
asr_imm(TailAddr, TailAddr, 17), % while preserving the sign.
|
||||||
lsl_imm(TailAddr, From, 17), % Get the offset of the third stack cell
|
eq_offset(Label1), % if the offset is zero don't add the address. it's empty list.
|
||||||
asr_imm(TailAddr, TailAddr, 17), % while preserving the sign.
|
add(TailAddr, TailAddr, Base),
|
||||||
eq_offset(Label1), % if the offset is zero don't add the address. it's empty list.
|
label(Label1)].
|
||||||
add(TailAddr, TailAddr, Base),
|
|
||||||
label(Label1)
|
|
||||||
% TailAddr = Base + From[15:0] the address of the third stack cell
|
|
||||||
].
|
|
||||||
|
|
||||||
|
⟐(load(From, To)) --> [load_word(From, To, 0)].
|
||||||
|
|
||||||
do :-
|
do :-
|
||||||
compile_program(Binary),
|
compile_program(Binary),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue