So my situation right now is, I need to read in(input from the user) up to 8 digits as characters (not numerical instead as a character input).
But only characters 0,1,2,3,4,5,6,7,8,9 is labelled as valid inputs. This means that the ASCII equivalent for these characters is between decimal 48-57
Anything below decimal 48 and above decimal 57 will deem the input as invalid.
The next step is to check how many inputs are there. Example if I were to enter "--------kaskldjklasd12345678" this will still only take as 8 inputs because it has 1,2,3,4,5,6,7,8 while the alphabets and symbols are being ignored. Basically, I want the program to identify if the user input is 8 characters(only between 0-9) or when the RETURN key is pressed, then I would want to store the characters into an array.
Right now, I'm figuring on how to store the input characters into an array. The program below is doing the comparing and addition for the counter to determine the counter=8. I'm stuck on how to store the values/character in an array.
The array storing should be only after the counter(d5) hits 8. So do I put
Code:
lea arr1, a0
move.w d1,d0
?
The code I have right now is:
Code:
*-----------------------------------------------------------
* Title :
* Written by :
* Date :
* Description:
*-----------------------------------------------------------
ORG $1000
START: ; first instruction of program
* Put program code here
CLR.L D5
LOOP
JSR INPUT
CMP.B #13, D1 *COMPARING #13(ENTER) TO USER INPUT*
BEQ ENTER
CMP.B #48, D1 *COMPARING #48 WHICH IS NOT '0' TO USER INPUT*
BLT LESS
CMP.B #57, D1 *COMPARING #57 WHICH IS NOT '9' TO USER INPUT*
BGT MORE
ADD.B #1, D5 *ADD 1 TO COUNTER(D5) WHICH INPUT IS VALID*
CMP.B #8, D5 *COMPARE #8 WITH COUNTER(D5) FOR 8 INPUTS*
BEQ ENTER
BRA LOOP
LESS
JSR INPUT
BRA LOOP
MORE
JSR INPUT
BRA LOOP
ENTER
LEA STR1, A1
MOVE.B #14, D0
TRAP #15
INPUT
MOVE.B #5, D0
TRAP #15
RTS
SIMHALT ; halt simulator
* Put variables and constants here
STR1 DC.B 'TEST',13,10,0
ARR DS.L 8 *8 LONG WORD ARRAY*
END START ; last line of source