# HG changeset patch # User William Astle # Date 1716014506 21600 # Node ID 95f174bf459b5e5ec5a1e6bec2ea01a4e88f8a5a # Parent 9f23ddc5165f104f8ad4f4b0e155a081e1d4c38a Add error handling for immediate mode loop diff -r 9f23ddc5165f -r 95f174bf459b src/error.s --- a/src/error.s Wed May 15 20:16:56 2024 -0600 +++ b/src/error.s Sat May 18 00:41:46 2024 -0600 @@ -11,13 +11,7 @@ ; issues if there happen to be error codes above 128. ERROR clr filenum ; reset display device to console jsr writecondnl ; do a newline if needed (will preserve B) - ldx #errormsg ; point to error message list - incb ; account for decb below - bra ERROR1 ; go search for correct message -ERROR0 lda ,x+ ; end of message? - bne ERROR0 ; brif not end of message -ERROR1 decb ; at the correct one? - bne ERROR0 ; brif not - skip to next one + bsr ERRORstr ; get the error message string ERROR2 jsr writestrconduc ; output error message ldu curline ; are we in immediate mode? beq ERROR3 ; brif so @@ -29,6 +23,14 @@ clr ,-s ; reset the call stack sts cstackptr jmp immediate ; go back to immediate mode +ERRORstr ldx #errormsg ; point to error messages + incb ; compensate for decb below + bra ERRORstr1 ; go find the right string +ERRORstr0 lda ,x+ ; end of string? + bne ERRORstr0 ; brif not +ERRORstr1 decb ; at the correct message? + bne ERRORstr0 ; brif not - skip a message + rts ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Error messages ; diff -r 9f23ddc5165f -r 95f174bf459b src/interp.s --- a/src/interp.s Wed May 15 20:16:56 2024 -0600 +++ b/src/interp.s Sat May 18 00:41:46 2024 -0600 @@ -63,6 +63,12 @@ setcifdigit0 rts ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Immediate mode handler +immediatee jsr ERRORstr ; get error string + jsr writestrconduc ; display it + ldx #atmsg ; output " at " + jsr writestrconduc + leax ,u ; point to error location + jsr console_outstr ; display remaining line part (but preserve case this time) immediate jsr writecondnl ; do newline if required ldx #prompt ; point to prompt string jsr console_outstrn @@ -79,6 +85,7 @@ bcs immediate1 ; brif so - go handle program editing clrb ; flag to do actual parsing jsr parse ; go parse the line + bcs immediatee ; brif there was a parse error bra * jsr interpretline ; go interpret the tokenized line bra immediate ; go handle another line diff -r 9f23ddc5165f -r 95f174bf459b src/miscdata.s --- a/src/miscdata.s Wed May 15 20:16:56 2024 -0600 +++ b/src/miscdata.s Sat May 18 00:41:46 2024 -0600 @@ -5,4 +5,5 @@ prompt fcn 'OK' ; general prompt breakmsg fcn 'BREAK' ; "BREAK" message inmsg fcn ' in ' ; " in " message +atmsg fcn ' at ' ; " at " message *pragmapop list diff -r 9f23ddc5165f -r 95f174bf459b src/parse.s --- a/src/parse.s Wed May 15 20:16:56 2024 -0600 +++ b/src/parse.s Sat May 18 00:41:46 2024 -0600 @@ -42,6 +42,7 @@ leax 3,x ; move to next entry cmpx #parsetab_cmde ; end of table? blo parse1 ; brif not + bra parse_errorsn ; fell off the end parse3 jsr [1,x] ; call the handler bcs parse_error ; brif the handler indicated error bsr parse_curtoken ; fetch the token we left off on