Hello,
I'm writing a little program and I have a problem : Using the CHARI instruction , I 'm supposed to get 4 digits representing a year ( I can not use DECI ) . I am able to read characters one by one and convert them to decimal , but the problem is I have to then do calculations with the year and i't's not possible with only one digit. I wondered if it was possible to put the numbers one after the other without overwriting what was there before. Here is what I have so far:
relire2: CHARI entrée,d
ldx compteur,d
addx 1,i
stx compteur,d
LDA test2,d
CPA 10,i
breq continue
stbytea entree2,d
ldbytea entree2,d
cpa 48,i
brlt inv
cpa 57,i
brgt inv
suba 48,i
sta annee,d
deco annee,d
continue: nop1
BRNE relire2 ; relire jusqu'au ENTREE
cpx 5,i
brne inv
br stop1
inv: stro inv1,d
stop1: STOP
test2:.BYTE 0
entrée: .BLOCK 1
test: .BYTE 0
entree2: .BLOCK 2
compteur: .BLOCK 1
test2: .BLOCK 2
annee: .WORD 0
inv1: .ASCII "Année invalide\x00"
.end
Thanks