
 1000  *SAVE S.DOS NUMIN
 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         LDA #0       INIT NUMBER = 0
 1150         STA NUML  
 1160         STA NUMH  
 1170         JSR GNNB     GET NEXT NON-BLANK CHAR
 1180         PHP
 1190         CMP #"$"     HEX OR DECIMAL?
 1200         BEQ .6       ...HEX
 1210         PLP
 1220         JMP .2       ...DECIMAL (OR NONE)
 1230  *---NEXT CHAR OF DECIMAL #-------
 1240  .1     JSR GNNB     GET NEXT NON-BLANK CHAR
 1250  .2     BNE .3       ...NOT COMMA OR CR
 1260         LDX NUML     END OF NUMBER
 1270         LDA NUMH     VALUE IN A,X
 1280         CLC          SIGNAL VALID NUMBER
 1290         RTS          RETURN
 1300  *---CONVERT DECIMAL NUMBER-------
 1310  .3     SEC          CONVERT CHAR TO DIGIT
 1320         SBC #$B0
 1330         BMI .4       ...NOT DIGIT
 1340         CMP #$0A
 1350         BCS .4       ...NOT DIGIT
 1360         JSR .5       SHIFT VALUE 1 LEFT
 1370         ADC NUML     2*VALUE + DIGIT
 1380         TAX
 1390         LDA #$00
 1400         ADC NUMH  
 1410         TAY
 1420         JSR .5       SHIFT VALUE 1 LEFT
 1430         JSR .5       SHIFT VALUE 1 LEFT
 1440         TXA          ...+ 8*VALUE
 1450         ADC NUML  
 1460         STA NUML  
 1470         TYA
 1480         ADC NUMH  
 1490         STA NUMH  
 1500         BCC .1       ...NO OVERFLOW
 1510  .4     SEC          SIGNAL BAD CHAR OR OVERFLOW
 1520         RTS
 1530  *---SHIFT VALUE 1 BIT LEFT-------
 1540  .5     ASL NUML  
 1550         ROL NUMH  
 1560         RTS
 1570  *---CONVERT HEX NUMBER-----------
 1580  .6     PLP          POP USELESS STATUS
 1590  .7     JSR GNNB     GET NEXT NON-BLANK CHAR
 1600         BEQ .2       ...END OF NUMBER
 1610         SEC          CONVERT ASCII TO DIGIT
 1620         SBC #$B0
 1630         BMI .4       ...NOT A DIGIT
 1640         CMP #$0A
 1650         BCC .8       ...0-9
 1660         SBC #$07     TRY LETTERS
 1670         BMI .4       ...NOT A DIGIT
 1680         CMP #$10
 1690         BCS .4       ...NOT A DIGIT
 1700  .8     LDX #4       SHIFT VALUE 4 BITS LEFT
 1710  .9     JSR .5       SHIFT VALUE 1 LEFT
 1720         DEX
 1730         BNE .9
 1740         ORA NUML     MERGE VALUE WITH NEW DIGIT
 1750         STA NUML  
 1760         JMP .7       ...NEXT DIGIT
 1770  *--------------------------------

