comparison src/lwbasic.s @ 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 8ac1aafb9ecb
comparison
equal deleted inserted replaced
65:bb9fe2bd4894 66:02080e77386f
1717 stx val0+2 1717 stx val0+2
1718 stx val0+4 1718 stx val0+4
1719 bra eval_number1 ; go do the parsing 1719 bra eval_number1 ; go do the parsing
1720 eval_number0 jsr nextchar ; fetch next input 1720 eval_number0 jsr nextchar ; fetch next input
1721 beq eval_numberr ; brif end of expression - bail 1721 beq eval_numberr ; brif end of expression - bail
1722 eval_number1 cmpa #'- ; negative? 1722 eval_number1 cmpa #'- ; negative (ascii sign)?
1723 beq eval_number3 ; brif so
1724 cmpa #tok_minus ; negative (operator negative)?
1723 bne eval_number2 ; brif not 1725 bne eval_number2 ; brif not
1724 com val0.sign ; invert sign 1726 eval_number3 com val0.sign ; invert sign
1725 bra eval_number0 ; deal with next input 1727 bra eval_number0 ; deal with next input
1726 eval_number2 cmpa #'+ ; unary +? 1728 eval_number2 cmpa #'+ ; unary +?
1727 beq eval_number0 ; brif so - skip it 1729 beq eval_number0 ; brif so - skip it
1728 eval_number5 cmpa #'. ; decimal point? 1730 eval_number5 cmpa #'. ; decimal point?
1729 beq eval_float ; brif decimal - force float 1731 beq eval_float ; brif decimal - force float
1781 beq eval_numberr0 ; brif not 1783 beq eval_numberr0 ; brif not
1782 ldd zero ; negate the value 1784 ldd zero ; negate the value
1783 subd val0.int+2 1785 subd val0.int+2
1784 std val0.int+2 1786 std val0.int+2
1785 ldd zero 1787 ldd zero
1786 subd val0.int 1788 sbcb val0.int+1
1787 std val0.int 1789 sbca val0.int
1790 std val0.int
1788 eval_numberr0 rts 1791 eval_numberr0 rts
1789 eval_float jmp SNERROR ; we don't handle floating point yet 1792 eval_float jmp SNERROR ; we don't handle floating point yet
1790 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 1793 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1791 ; Operator table 1794 ; Operator table
1792 ; 1795 ;