incr stack

Really decr, but I'm abstracting.
This commit is contained in:
Simon Forman 2019-11-09 18:28:01 -08:00
parent 67583716f2
commit 7a821a4eaf
2 changed files with 50 additions and 50 deletions

View File

@ -1,97 +1,97 @@
[word(0),
do_offset(_7362),
allocate(_7372,20),
label(_7362),
do_offset(_7910),
allocate(_7920,20),
label(_7910),
mov_imm(0,0),
store_word(0,0,0),
mov_imm(0,4096),
mov_imm(1,_7434),
mov_imm(1,_7982),
mov_imm(2,0),
mov_imm(3,0),
store_word(2,0,0),
label(_7482),
label(_8030),
sub_imm(1,1,0),
eq_offset(_7494),
eq_offset(_8042),
load_word(4,1,0),
lsl_imm(5,4,2),
asr_imm(5,5,17),
eq_offset(_7610),
eq_offset(_8158),
add(5,5,1),
label(_7610),
label(_8158),
lsl_imm(6,4,17),
asr_imm(6,6,17),
eq_offset(_7672),
eq_offset(_8220),
add(6,6,1),
label(_7672),
label(_8220),
load_word(3,5,0),
mov(1,6),
asr_imm(6,3,30),
and_imm(6,6,2),
sub_imm(6,6,2),
ne_offset(_7774),
ne_offset(_8322),
mov_imm_with_shift(6,16383),
ior_imm(6,6,65535),
and(6,6,3),
do(6),
label(_7774),
label(_8322),
sub_imm(0,0,4),
sub(2,5,0),
hi_offset(_7872),
hi_offset(_8424),
and_imm(2,2,32767),
label(_7872),
label(_8424),
lsl_imm(2,2,15),
ior_imm(2,2,4),
label(_7934),
label(_8486),
store_word(2,0,0),
do_offset(_7482),
label(_7494),
do_offset(_7494),
label(_7988),
do_offset(_8030),
label(_8042),
do_offset(_8042),
label(_8540),
lsl_imm(6,2,2),
asr_imm(6,6,17),
eq_offset(_8070),
eq_offset(_8656),
add(6,6,0),
label(_8070),
label(_8656),
lsl_imm(2,2,17),
asr_imm(2,2,17),
eq_offset(_8132),
eq_offset(_8718),
add(2,2,0),
label(_8132),
label(_8718),
load_word(7,2,0),
lsl_imm(8,7,2),
asr_imm(8,8,17),
eq_offset(_8208),
eq_offset(_8794),
add(8,8,2),
label(_8208),
label(_8794),
lsl_imm(9,7,17),
asr_imm(9,9,17),
eq_offset(_8270),
eq_offset(_8856),
add(9,9,2),
label(_8270),
label(_8856),
sub_imm(0,0,4),
sub_imm(8,8,0),
eq_offset(_8338),
eq_offset(_8900),
sub(8,8,0),
and_imm(8,8,32767),
label(_8338),
label(_8900),
sub_imm(6,6,0),
eq_offset(_8406),
eq_offset(_8968),
sub(6,6,0),
and_imm(6,6,32767),
label(_8406),
label(_8968),
lsl_imm(8,8,15),
ior(8,8,6),
store_word(8,0,0),
sub_imm(0,0,4),
sub_imm(9,9,0),
eq_offset(_8536),
eq_offset(_9114),
sub(9,9,0),
and_imm(9,9,32767),
label(_8536),
label(_9114),
mov_imm_with_shift(2,2),
ior(2,2,9),
do_offset(_7934),
label(_7434),
expr_cell(_8654,0),
label(_8654),
symbol(_7988)]
do_offset(_8486),
label(_7982),
expr_cell(_9232,0),
label(_9232),
symbol(_8540)]

View File

@ -71,12 +71,12 @@ Mark II
do(TEMP0),
% going into push we have the term
label(PUSH),
label(PUSH)],
% push2(TOS, TEMP1, SP), % stack = TERM, stack
sub_imm(SP, SP, 4), % SP -= 1 (word, not byte)
(incr(SP)),
% SP points to the future home of the new stack cell.
sub(TOS, TermAddr, SP), % TOS := &temp - sp
[sub(TOS, TermAddr, SP), % TOS := &temp - sp
% Er, what if it's negative?
hi_offset(Bar0),
and_imm(TOS, TOS, 0x7fff), % Mask off high bits so
@ -102,25 +102,22 @@ Mark II
% TOS = Address of the second stack cell.
load(TEMP1, TOS),
% 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
% TEMP3 = TOS + TEMP1[15:0] the address of the third stack cell
% Build and write the new list cell.
sub_imm(SP, SP, 4)
],([
incr(SP),
sub_base_from_offset(TEMP2, SP),
sub_base_from_offset(TEMP0, SP)
]),[
lsl_imm(TEMP2, TEMP2, 15), % TEMP2 := TEMP2 << 15
ior(TEMP2, TEMP2, TEMP0),
store_word(TEMP2, SP, 0),
sub_imm(SP, SP, 4)
],(
store_word(TEMP2, SP, 0)
],([
incr(SP),
sub_base_from_offset(TEMP3, SP)
),[
]),[
mov_imm_with_shift(TOS, 2), % TOS := 4 << 15
ior(TOS, TOS, TEMP3),
do_offset(Done), % Rely on mainloop::Done to write TOS to RAM.
@ -163,6 +160,9 @@ language.
(load(From, To)) --> [load_word(From, To, 0)].
(incr(SP)) --> [sub_imm(SP, SP, 4)]. % SP -= 1 (word, not byte).
do :-
compile_program(Binary),
write_binary('joy_asmii.bin', Binary).