From 816563e2e352d904e7d199e43db1fd4d2382fac1 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Fri, 24 Apr 2020 14:10:40 -0400 Subject: [PATCH] Stop LOADing on ABORT This is done by adding a "C<* override" layer that is reset to 0 on ABORT. The problem was that when ABORT happened during a LOAD, we had a resetted RSP and started from a clean INTERPRET, but LOAD didn't have the opportunity to restore C<*, which caused it to continue interpreting from the faulty BLK. With a C<* override, we don't need to *restore* C<*, we just need to clear the override. --- blk/081 | 2 +- blk/082 | 4 ++-- blk/393 | 6 +++++- blk/398 | 6 +++++- blk/405 | 1 + emul/forth/z80c.bin | Bin 2212 -> 2250 bytes forth/blk.fs | 16 ++++++++-------- 7 files changed, 22 insertions(+), 13 deletions(-) diff --git a/blk/081 b/blk/081 index 8d000fa..83b8219 100644 --- a/blk/081 +++ b/blk/081 @@ -3,7 +3,7 @@ RAMSTART INITIAL_SP +53 readln's variables +02 CURRENT +55 adev's variables +04 HERE +57 blk's variables +06 C IF EXECUTE THEN ( 06 == C36B5Dp;- zk88GjrGzx$z%G@Yjn|%){sqD{XDjlYjW)~9H}lPW-%KO%Cvl}k+~XQzaK$5LwD^Lf zCM5=oYa$DCaX|OQDRLW3rMrQ-8ltlbMce-FPN~!b(hX6=5NwJv^=M&{XF>^IJ@wtr6ZwwLX6k9`h?N^j4|I%J%QkJ9 zA844S*CMuPT$`%&L`8;pZLa0FkALMYM$G4L$fF#@hEZym4Jb3AzRm`+A@7L$OiLtT zd)33*adL)){g*#f78X|u^XseY^MzjMBB;BgR>DnZ+LAd}2eb$}f_YM@Prrz;yjWQA zfs+XhfecJ0_B|KKOUK$yxpb9NrNM=Uw9U%!nfALMvzt4?JoyY{9^&uqw_RbOE2wBu!s6Lc=9T;{bm(<7?|(9`QCfqH@_!OCQk#I%wcn@x?bKX zuUC$G`<@a|d@8-%|Z&G6lWlku{d3vo2?Rp2ErzQTa43bssTg;x2S-fm0(P!qSjaMt zWvoS(d~>WyGFCnI-TYM#pAOY8mU1mJL?yURAMgM^HAJWsclH(_XryJ5?wZH${9dXq z$fzZH>_VgzyU%TXL#NNR>SpW>F%-G}>2u@D;!BGBN6ov@|GiIOgrHnDhr&)Bm5S%qfT Ss)Esb;TK*7mnr?wGq8WEqjSCh diff --git a/forth/blk.fs b/forth/blk.fs index fa2fb19..6ad8bae 100644 --- a/forth/blk.fs +++ b/forth/blk.fs @@ -61,28 +61,28 @@ ; : LOAD - ( save BLK>, CINPTR and boot< ptr to RSP ) + ( save BLK>, C<* override and boot< ptr to RSP ) BLK> @ >R - 0x0c RAM+ @ >R + 0x08 RAM+ @ >R 0x2e RAM+ @ >R BLK@ ( Point to beginning of BLK ) BLK( 0x2e RAM+ ! - ( 0c == CINPTR ) - ['] _ 0x0c RAM+ ! + ( 08 == C<* override ) + ['] _ 0x08 RAM+ ! INTERPRET R> 0x2e RAM+ ! - ( Before we restore CINPTR, are we restoring it to "_"? + ( Before we restore C<* are we restoring it to "_"? if yes, it means we're in a nested LOAD which means we should also load back the saved BLK>. Otherwise, we can ignore the BLK> from RSP. ) - I 0x0c RAM+ @ = IF + I 0x08 RAM+ @ = IF ( nested load ) - R> DROP ( CINPTR ) + R> DROP ( C<* ) R> BLK@ ELSE ( not nested ) - R> 0x0c RAM+ ! + R> 0x08 RAM+ ! R> DROP ( BLK> ) THEN ;