EASy68K  
It is currently Tue May 30, 2017 7:24 am

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Wed Feb 11, 2015 8:51 pm 
Offline

Joined: Wed Feb 11, 2015 8:33 pm
Posts: 1
Hello there,

I am pretty beginner at assembly language and 68000. My program is suppose to intake up to 10 words or as many up to just a carriage return. The # of words, length of words and the word are stored in a list. In the format [# of words], [length of word], [word] etc etc. That is also how it is suppose to print. My program prints the correct # of words and length of words. Then prints the first letter of each word and the ending letters of the last word. So the last word is the only correct one. I've tried a lot of things, not sure what else to try. Sorry for the most likely sloppy code

If I were to input Hello and Test the output would be:
2, 5, Hest, 4, Test

Thanks

Code:
*-----------------------------------------------------------
* Title      : Assignment 5 - Question 2
* Written by : Kieran O'Driscoll
* Date       : February 10th, 2015
* Description: Question 2
*-----------------------------------------------------------

START       ORG     $1000

            LEA     PROMPT,A1   Prompts the user for a string and loads
            JSR     P_STR       LIST to A2
            LEA     LIST,A2
            MOVE.B  #0,(A2)+    Creates an empty space for the # of words
            MOVE.B  COUNT,D3
           
LOOP        JSR     INPUT       Calls the input function
AFTER       ADD.B   #1,D6       Adds to the number of words added
            SUB.B   #1,D3       
            BNE     LOOP       Checks to see if the 10 words have been entered                       
NEXT        LEA     LIST,A2   
            MOVE.B  D6,(A2)+    Moves the number of words to the front of the list
            LEA     LIST,A2
            JSR     PLOOP       
           
END         STOP    #$2700
           
           
            INCLUDE 'io_util.x68'


INPUT       LEA     STRING,A1   Asks user for the a word
            JSR     P_Length    Uses task 3, length in D1 and string to (A1)
            MOVE.B  D1,(A2)+    moves length of string to list
            MOVE.B  STRING,D2   
            MOVE.B  STRING,(A2)+ Moves string to list
            CMP.B   #$0,D2       Compares to see if it is a <CR>                       
            BNE     AFTER
            JSR     NEXT

PLOOP       MOVE.B  (A2)+,D1    Moves # of words to list
            LEA     NULL,A1
            JSR     P_NUM       Prints number using task 17
ILOOP       LEA     SEP,A1      Prints ', ' to make it comma seperated
            JSR     P_STRNOCR
            LEA     NULL,A1
            MOVE.B  (A2)+,D1    Moves length of string to D1
            JSR     P_NUM       Prints number using task 17
            LEA     SEP,A1
            JSR     P_STRNOCR
            MOVE.B  (A2)+,STRING Moves the string to STRING
            LEA     STRING,A1   Loads address of String to A1
            JSR     P_STRNOCR   
            SUB.B   #1,D6       Loops the number of times there are words
            BNE     ILOOP             
            JSR     END

PROMPT      DC.B    'Enter a series of words and <CR> to end:',0
COUNT       DC.B    10
SEP         DC.B    ', ',0
STRING      DS.B    40
LIST        DS.B    200
                       
            END     START


Top
 Profile  
 
PostPosted: Thu Feb 12, 2015 11:44 pm 
Offline
User avatar

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1036
odriski wrote:
Code:
INPUT       LEA     STRING,A1   Asks user for the a word
            JSR     P_Length    Uses task 3, length in D1 and string to (A1)
            MOVE.B  D1,(A2)+    moves length of string to list
            MOVE.B  STRING,D2   
            MOVE.B  STRING,(A2)+ Moves string to list

The last line above moves one character from STRING to (A2). A loop would be required if you want to move the entire string.

_________________
Prof. Kelly


Top
 Profile  
 
PostPosted: Sat Sep 26, 2015 12:05 pm 
Offline

Joined: Fri Sep 25, 2015 7:57 am
Posts: 7
hello who is the io_util.x68.

greeting


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 1 guest


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:  
cron
Powered by phpBB® Forum Software © phpBB Group