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.
This commit is contained in:
Virgil Dupras 2020-04-24 14:10:40 -04:00
parent af39b37dd1
commit 816563e2e3
7 changed files with 22 additions and 13 deletions

View File

@ -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<?* +59 z80a's variables
+08 FUTURE USES +5b FUTURE USES
+08 C<* override +5b FUTURE USES
+0a PARSEPTR +70 DRIVERS
+0c C<* +80 RAMEND
+0e WORDBUF

View File

@ -9,8 +9,8 @@ IP is the Interpreter Pointer
PARSEPTR holds routine address called on (parse)
C<* holds routine address called on C<
C<* holds routine address called on C<. If the C<* override
at 0x08 is nonzero, this routine is called instead.
(cont.)

View File

@ -7,5 +7,9 @@
( w -- a f )
: (find) CURRENT @ SWAP _find ;
: QUIT (resRS) LIT< INTERPRET (find) DROP EXECUTE ;
: QUIT
(resRS)
0 0x08 RAM+ ! ( 08 == C<* override )
LIT< INTERPRET (find) DROP EXECUTE
;
394 407 LOADR

View File

@ -3,7 +3,11 @@
: (parse) (parsed) NOT IF ABORT THEN ;
: C<? 0x06 RAM+ @ DUP 2 > IF EXECUTE THEN ( 06 == C<?* ) ;
: C< 0x0c RAM+ @ EXECUTE ( 0c == C<* ) ;
: C<
0x08 RAM+ @ ( 08 == C<* override )
DUP NOT IF DROP 0x0c RAM+ @ THEN ( 0c == C<* )
EXECUTE
;
: , HERE @ ! HERE @ 2+ HERE ! ;

View File

@ -3,6 +3,7 @@
LIT< (parse) (find) DROP (parse*) !
( 2e == SYSTEM SCRATCHPAD )
CURRENT @ 0x2e RAM+ !
0 0x08 RAM+ ! ( 08 == C<* override )
( 0c == C<* )
LIT< (boot<) (find) DROP 0x0c RAM+ !
( boot< always has a char waiting. 06 == C<?* )

Binary file not shown.

View File

@ -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
;