
 1000  *SAVE S.DOS NUMIN (RBSC)
 1010  *--------------------------------
 1020  NUML   .EQ $44
 1030  NUMH   .EQ $45
 1040  *--------------------------------
 1050  GNNB   .EQ $A1A4
 1060  *--------------------------------
 1070         .OR $A1B9
 1080         .TA $09B9
 1090  *--------------------------------
 1100  *      RETURN .CC. WITH NUMBER IN A,X
 1110  *          OR .CS. IF BAD SYNTAX
 1120  *--------------------------------
 1130  CONVERT.NUMBER.IN.WBUF
 1140         LDY #0       INIT NUMBER = 0
 1150         STY NUML     (AND LEAVE Y=0 TOO)
 1160         STY NUMH  
 1170         JSR GNNB     GET NEXT NON-BLANK CHAR
 1180         BEQ .2       ...NO NUMBER, RETURN 0
 1190         CMP #"$"     HEX OR DECIMAL?
 1200         BEQ .7       ...HEX
 1210  *---CONVERT DECIMAL NUMBER-------
 1220  .3     EOR #$B0     CONVERT CHAR TO DIGIT
 1230         CMP #10
 1240         BCS .4       ...NOT DIGIT
 1250         ASL NUML     SHIFT VALUE 1 LEFT
 1260         ROL NUMH
 1270         ADC NUML     2*VALUE + DIGIT
 1280         TAX
 1290         TYA          A = Y = 0
 1300         ADC NUMH  
 1310         PHA
 1320         ASL NUML     SHIFT VALUE 1 LEFT
 1330         ROL NUMH
 1340         ASL NUML     SHIFT VALUE 1 LEFT
 1350         ROL NUMH
 1360         TXA          ...+ 8*VALUE
 1370         ADC NUML  
 1380         STA NUML  
 1390         PLA
 1400         ADC NUMH  
 1410         STA NUMH  
 1420         BCS .4       ...OVERFLOW
 1430  .1     JSR GNNB     GET NEXT NON-BLANK CHAR
 1440         BNE .3       ...NOT COMMA OR CR
 1450  *---NUMBER IS FINISHED-----------
 1460  .2     LDX NUML     END OF NUMBER
 1470         LDA NUMH     VALUE IN A,X
 1480         CLC          SIGNAL VALID NUMBER
 1490         RTS          RETURN
 1500  *---MERGE NEXT HEX DIGIT---------
 1510  .8     ASL          POSITION DIGIT
 1520         ASL
 1530         ASL
 1540         ASL
 1550         LDX #4       SHIFT VALUE 4 BITS LEFT
 1560  .9     ASL          SHIFT DIGIT INTO VALUE
 1570         ROL NUML
 1580         ROL NUMH
 1590         DEX
 1600         BNE .9
 1610  *---CONVERT HEX NUMBER-----------
 1620  .7     JSR GNNB     GET NEXT NON-BLANK CHAR
 1630         BEQ .2       ...END OF NUMBER
 1640         EOR #$B0     CONVERT ASCII TO DIGIT
 1650         CMP #10      0...9?
 1660         BCC .8       ...YES, 0-9
 1670         ADC #$88     SHIFT RANGE FOR A-F TEST
 1680         CMP #$FA     A...F?
 1690         BCS .8       ...A-F
 1700  *---SYNTAX ERROR-----------------
 1710  .4     SEC          SIGNAL BAD CHAR OR OVERFLOW
 1720         RTS
 1730  *--------------------------------
 1740         .OR $800
 1750  TEST   JSR $FD67
 1760         TXA
 1770         BEQ .1
 1780         LDX #0
 1790         STX $AA5D
 1800         JSR CONVERT.NUMBER.IN.WBUF
 1810         JSR $F941
 1820         JMP TEST
 1830  .1     RTS

