Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,127 @@
|
|||
*=$0801
|
||||
db $0E,$08,$0A,$00,$9E,$20,$28,$32,$30,$36,$34,$29,$00,$00,$00 ;required init code on commodore 64 floppy disks
|
||||
*=$0810
|
||||
|
||||
lda #$0e
|
||||
jsr chrout ;required for my printing routine to work.
|
||||
|
||||
z_HL equ $02
|
||||
z_L equ $02
|
||||
z_H equ $03
|
||||
z_B equ $04
|
||||
|
||||
|
||||
|
||||
loadpair z_HL,TestString0
|
||||
jsr isStringNumeric
|
||||
|
||||
loadpair z_HL,TestString1
|
||||
jsr isStringNumeric
|
||||
|
||||
loadpair z_HL,TestString2
|
||||
jsr isStringNumeric
|
||||
|
||||
loadpair z_HL,TestString3
|
||||
jsr isStringNumeric
|
||||
|
||||
loadpair z_HL,TestString4
|
||||
jsr isStringNumeric
|
||||
|
||||
loadpair z_HL,TestString5
|
||||
jsr isStringNumeric
|
||||
|
||||
loadpair z_HL,TestString6
|
||||
jsr isStringNumeric
|
||||
|
||||
loadpair z_HL,TestString7
|
||||
jsr isStringNumeric
|
||||
|
||||
loadpair z_HL,TestString8
|
||||
jsr isStringNumeric
|
||||
rts ;return to basic
|
||||
|
||||
isStringNumeric:
|
||||
; input: z_HL = source address
|
||||
pushY
|
||||
ldy #0
|
||||
sty z_B ;our tally for decimal points
|
||||
|
||||
checkFirstChar:
|
||||
lda (z_HL),y
|
||||
beq notNumeric ;a null string is not a valid number!
|
||||
cmp #'-'
|
||||
beq isNegative_OK
|
||||
cmp #'.'
|
||||
beq isFloat_OK
|
||||
and #$30
|
||||
cmp #$30
|
||||
beq isNumeral_OK
|
||||
;else, is not numeric
|
||||
notNumeric:
|
||||
popY
|
||||
jsr PrintString_TextScreen ;prints what's already in z_HL
|
||||
jsr NewLine
|
||||
loadpair z_HL,isStringNumeric_Fail
|
||||
jsr PrintString_TextScreen
|
||||
jsr NewLine
|
||||
jmp NewLine
|
||||
;rts
|
||||
isNegative_OK:
|
||||
isNumeral_OK:
|
||||
iny
|
||||
jmp loop_isStringNumeric
|
||||
isFloat_OK:
|
||||
iny
|
||||
inc z_B
|
||||
loop_isStringNumeric:
|
||||
lda (z_HL),y
|
||||
beq Terminated_isStringNumeric
|
||||
cmp #'.'
|
||||
beq CheckIfDecimalAlreadyOccurred
|
||||
and #$30
|
||||
cmp #$30
|
||||
bne notNumeric
|
||||
loop_overhead_isStringNumeric:
|
||||
iny
|
||||
jmp loop_isStringNumeric
|
||||
|
||||
CheckIfDecimalAlreadyOccurred:
|
||||
lda z_B
|
||||
bne notNumeric
|
||||
inc z_B
|
||||
jmp loop_overhead_isStringNumeric
|
||||
|
||||
Terminated_isStringNumeric:
|
||||
;if we got this far the string is numeric.
|
||||
popY
|
||||
jsr PrintString_TextScreen ;prints what's already in z_HL
|
||||
jsr NewLine
|
||||
loadpair z_HL,isStringNumeric_Pass
|
||||
jsr PrintString_TextScreen
|
||||
jsr NewLine
|
||||
jmp NewLine
|
||||
;rts
|
||||
|
||||
isStringNumeric_Pass:
|
||||
db "IS NUMERIC",0
|
||||
isStringNumeric_Fail:
|
||||
db "IS NOT NUMERIC",0
|
||||
|
||||
TestString0:
|
||||
db 0
|
||||
TestString1:
|
||||
db "123",0
|
||||
TestString2:
|
||||
db "-30",0
|
||||
TestString3:
|
||||
db "123.45",0
|
||||
TestString4:
|
||||
db "-123.45",0
|
||||
TestString5:
|
||||
db "ABCDE",0
|
||||
TestString6:
|
||||
db "-34-5",0
|
||||
TestString7:
|
||||
db "1.000.000",0
|
||||
TestString8:
|
||||
db ".23456",0
|
||||
Loading…
Add table
Add a link
Reference in a new issue