changeset 131:95f174bf459b

Add error handling for immediate mode loop
author William Astle <lost@l-w.ca>
date Sat, 18 May 2024 00:41:46 -0600
parents 9f23ddc5165f
children 917b4893bb3d
files src/error.s src/interp.s src/miscdata.s src/parse.s
diffstat 4 files changed, 18 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- 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
 ;
--- 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
--- 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
--- 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