Mercurial > hg > index.cgi
changeset 57:6a4c342ac12b
Add BREAK check to main interpretation loop.
author | William Astle <lost@l-w.ca> |
---|---|
date | Sun, 19 Feb 2023 15:33:10 -0700 |
parents | f741bb544a04 |
children | 24b123b3e69b |
files | src/lwbasic.s |
diffstat | 1 files changed, 22 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lwbasic.s Thu Dec 22 23:44:25 2022 -0700 +++ b/src/lwbasic.s Sun Feb 19 15:33:10 2023 -0700 @@ -1221,6 +1221,22 @@ clr contstmt+1 jmp ,x ; return to caller ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; Check for BREAK; this needs to check the keyboard buffer directly instead of just using the usual key fetching +; routine so we don't interfere with keyboard buffering if BREAK isn't pressed. However, if BREAK is pressed, we +; need to react immediately in which case we clear everything up to and including the BREAK from the buffer. +breakcheck ldx keyb_buffr ; get keyboard ring buffer pointer +breakcheck0 cmpx keyb_buffw ; is the buffer empty? + beq breakcheck2 ; brif so (C clear here) + lda ,x+ ; is there a BREAK in the buffer? + cmpx #keyb_buff+keyb_bufflen ; do we need to wrap to start of buffer? + bne breakcheck1 ; brif not + ldx #keyb_buff ; reset to start of buffer +breakcheck1 cmpa #3 + bne breakcheck0 ; brif not BREAK + stx keyb_buffr ; clear buffer up to and including the BREAK + coma ; set C for BREAK pressed +breakcheck2 rts +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Main interpretation loop ; ; Enter at interpret with inputptr pointing to the code stream to interpret. @@ -1228,7 +1244,9 @@ ; command stream has completed. STOP or BREAK will return with carry set while END or falling off the end of the ; code will return with carry clear. In the event of an error, the usual error processing will be done and control ; will return to immediate mode with the stack reset. -interpret ldx inputptr ; get interpration address +interpret bsr breakcheck ; check for BREAK + bcs cmd_stop0 ; brif BREAK detected - go stop the program + ldx inputptr ; get interpration address stx curstmt ; save address of the current statement (needed for some stuff) lda ,x+ ; are we at the end of the line? beq interpret0 ; brif so @@ -1272,11 +1290,11 @@ ; The END command. cmd_end bne SNERROR ; error out if there is an argument ;jsr closeall ; close all files for END - clra ; flag END + clra ; flag END (clear carry) bra cmd_stop0 ; go do the stop/end cmd_stop bne SNERROR ; raise error if there was an argument - lda #0xff ; flag STOP -cmd_stop0 sta endflag ; set stop/end flag + coma ; flag STOP - set carry +cmd_stop0 ror endflag ; set stop/end flag cmd_stop1 clr filenum ; reset I/O to console ldx curline ; in immediate mode? beq cmd_stop2 ; brif so - don't save the continue pointers