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