EASy68K  
It is currently Thu Nov 15, 2018 1:12 pm

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Tue Oct 02, 2018 6:38 am 
Offline

Joined: Tue Oct 02, 2018 5:03 am
Posts: 3
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



Top
 Profile  
 
PostPosted: Wed Oct 03, 2018 10:39 am 
Offline

Joined: Tue Oct 02, 2018 5:03 am
Posts: 3
I somehow managed to edit and make it work for the part I am asking, however I’m stuck at the second part.


Top
 Profile  
 
PostPosted: Wed Oct 03, 2018 10:42 am 
Offline

Joined: Tue Oct 02, 2018 5:03 am
Posts: 3
I have managed to read the data from user input and compared it with ASCII Code and only accept a certain value which is between 48 - 57 which represents characters 0-9.

Now, I'm having a hard time figuring out how do I print a certain string based on the input of the user. The requirements is to enter a maximum of 8 digits(eg: 12345678) or when the RETURN character is captured(13 in ASCII) and the program will print a specific string based on the number typed in. Another example would be if a user inputs
Code:
asdasdasd;';1234asdas5678
, this will still be treated as 8 digits as 1,2,3,4,5,6,7,8 is valid.

A specific string is being given to me as follows - this is part of the info that is given to me it continues to 9
Code:
INFO DC.B   '/////////'
    DC.B    '* ZERO  *'
    DC.B    '*////////'
    DC.B    '*  ONE  *'
    DC.B    '**///////'


The hard part is figuring how to retrieve the character I stored in the array and have it compare with a certain value so that if for example, the input is
Code:
01
then the program knows it has to print
Code:
'/////////'
'*////////'
'* ZERO *'
'* ONE *'


Quote:
Current Code

Code:
    ORG    $1000
START:                  ; first instruction of program

* Put program code here
    LEA ARR, A0
    CLR.L D5
   
LOOP
    JSR INPUT
   
    CMP.B #13, D1 *COMPARING #13(ENTER) TO USER INPUT*
    BEQ COMPILE
       
    CMP.B #48, D1 *COMPARING #48 WHICH IS NOT '0' TO USER INPUT*
    BLT LOOP
   
    CMP.B #57, D1 *COMPARING #57 WHICH IS NOT '9' TO USER INPUT*
    BGT LOOP
   
    ADD.B #1, D5 *ADD 1 TO COUNTER(D5) WHEN INPUT IS VALID*
    MOVE.B D1, (A0)+ *STORE THE NUMBERS INPUT INTO AN ARRAY
    CMP.B #8, D5 *COMPARE #8 WITH COUNTER(D5) FOR 8 INPUTS*
    BEQ COMPILE
   
    BRA LOOP
COMPILE
    LEA ARR, A0
    CLR.L D5

    SIMHALT

INPUT
    MOVE.B #5, D0
    TRAP #15
    RTS
OUTPUT
    MOVE.B #14, D0
    TRAP #15
    RTS
   
    SIMHALT             ; halt simulator

* Put variables and constants here
STR1 DC.B 'TEST',13,10,0
ARR DS.W 8 *8 LONG WORD ARRAY*
INFO DC.B   '/////////'
    DC.B    '* ZERO  *'
    DC.B    '*////////'
    DC.B    '*  ONE  *'
    DC.B    '**///////'

    END    START        ; last line of source





Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group