changeset 36:c786c1dd4632

Fix ERROR routine to actually work The ERROR routine needs to look up the error message without an off by one bug. Also, it needs to reset the stack before moving into immediate mode since it can be called anywhere with the stack in any state.
author William Astle <lost@l-w.ca>
date Mon, 21 Nov 2022 22:38:01 -0700
parents 336be9cef342
children ac52753bacfc
files src/lwbasic.s
diffstat 1 files changed, 2 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/lwbasic.s	Mon Nov 21 22:35:29 2022 -0700
+++ b/src/lwbasic.s	Mon Nov 21 22:38:01 2022 -0700
@@ -1012,7 +1012,7 @@
                 jsr writecondnl                 ; do a newline if needed (will preserve B)
                 ldx #errormsg                   ; point to error message list
                 incb                            ; account for decb below
-                bra ERROR0                      ; go search for correct message
+                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?
@@ -1021,8 +1021,7 @@
                 beq ERROR3                      ; brif end of message
                 jsr writechrconduc              ; output the character, converted to upper case situationally
                 bra ERROR2                      ; handle another character
-ERROR3          
-                
+ERROR3          lds freetop                     ; reset the stack pointer (error routine could be called anywhere)
                 ; fall through to immediate mode intentional
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ; Immediate mode handler