changeset 66:02080e77386f

Make negative integers parse correctly
author William Astle <lost@l-w.ca>
date Sun, 23 Apr 2023 10:12:14 -0600
parents bb9fe2bd4894
children 9c2e66ef5fa1
files src/lwbasic.s
diffstat 1 files changed, 7 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/lwbasic.s	Sat Apr 22 20:06:05 2023 -0600
+++ b/src/lwbasic.s	Sun Apr 23 10:12:14 2023 -0600
@@ -1719,9 +1719,11 @@
                 bra eval_number1                ; go do the parsing
 eval_number0    jsr nextchar                    ; fetch next input
                 beq eval_numberr                ; brif end of expression - bail
-eval_number1    cmpa #'-                        ; negative?
+eval_number1    cmpa #'-                        ; negative (ascii sign)?
+		beq eval_number3		; brif so
+		cmpa #tok_minus			; negative (operator negative)?
                 bne eval_number2                ; brif not
-                com val0.sign                   ; invert sign
+eval_number3    com val0.sign                   ; invert sign
                 bra eval_number0                ; deal with next input
 eval_number2    cmpa #'+                        ; unary +?
                 beq eval_number0                ; brif so - skip it
@@ -1783,8 +1785,9 @@
                 subd val0.int+2
                 std val0.int+2
                 ldd zero
-                subd val0.int
-                std val0.int
+                sbcb val0.int+1
+                sbca val0.int
+		std val0.int
 eval_numberr0   rts
 eval_float      jmp SNERROR                     ; we don't handle floating point yet
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;