I have this code that converts year input (into chari) and output it as decimal. My problem is, if by mistake, a letter or blank space is entered, the program keeps output the error message but and wont reask for a new input. Example, if ABCD is entered, it will give you the error message 4 times and exit.
Input year has to be between 1900 and 2049 (inclusive).
To reproduce the error, try with 19a0 or abcd per example.
Where am I wrong here ?
STRO welcome,d
entyear:STRO inptyear,d
readnomb:NOP1
initread:LDA -1,i
STA pos,d
LDA 0,i
STA integer,d
readchar:LDA 0,i
CHARI ascii,d
LDBYTEA ascii,d
CPA 0x000A,i
BREQ exitentr
CPA 0x002F,i
BRLE errlect
CPA 0x003A,i
BRGE errlect
SUBA 48,i
STA valint,d
LDX pos,d
ADDX 1,i
STX pos,d
BR convint
errlect: STRO msgerr,d
LDX 0,i
STX ascii,d
BR readnomb
multdix: LDA integer,d
ASLA
STA inttemp,d
ASLA
ASLA
ADDA inttemp,d
STA integer,d
LDX pos,d
SUBX 1,i
STX pos,d
convint: LDX pos,d
CPX 0,i
BRGT multdix
LDA integer,d
ADDA valint,d
STA integer,d
BR readchar
exitentr:LDX pos,d
CPX 0,i
BRLT end
dispint:LDA integer,d
CPA datemin,i
BRLT errlect
CPA datemax,i
BRGT errlect
DECO integer,d
STRO msgspace,d
BR entyear
end: STOP
welcome: .ASCII "Enter a year to convert to decimal\n"
.BYTE 0
inptyear: .ASCII "Year ?: "
.BYTE 0
msgerr: .ASCII "\nWrong caracter detected, please enter a new year: "
.BYTE 0
msgspace:.WORD 0x0A0A
.BYTE 0
inttemp: .WORD 0
valint: .WORD 0
pos: .WORD 0
datemin: .EQUATE 1900
datemax: .EQUATE 2049
integer: .WORD 0
ascii: .BYTE 0
.END