
CS 061 โ Computer Org. & Assembly Lang. Fall - 2003
Assignment 7 โ due Wednesday 11/26, 11 pm (secure server turnin)
Managing a list of words
This program will have three components:
1. An input subroutine, allowing the user to input a sequence of words, which will be stored in an array,
i.e. in a sequence of contiguous memory locations.
2. A "longest" subroutine that will locate the longest word - i.e. the one that has the most characters.
3. An output subroutine that will output the whole list of words, one per line, and then the longest word
in the list (e.g. "The longest word is: antidisestablishmentarianism")
You may assume that any input is valid - i.e. you may accept as input words such as @!!%&^#
You may also assume that the total list is not too big for the memory - i.e. you do not need to explicitly
test for size limits.
We will do this in steps:
Part 1:
1. Write a subroutine that takes a single "argument" R1 that contains an address, and asks the user to
input a single word. It stores the word to the address given, in the same form as the .STRINGZ
pseudo-op - e.g. the word "whatever" would be stored as the array:
{x0077, x0068, x0061, x0074, x0065, x0076, x0065, x0072, x0000}
starting at the address in R1.
This means that you will have to store each character as it is entered, testing each time for cr/lf (the
newline character x0A) to detect the end of the word, at which point you will store a NULL and then
return.
2. Write a subroutine that takes a single "argument" R1 that contains the location of the word, and
prints it out (at this point, that just means copying R1 to R0 and calling TRAP x22)
3. Write a main program that just calls these two subroutines. The address to which the word will be
stored can be provided by a .FILL pseudo-op.
Part 2:
Now we have to think about how we will terminate a list of words, i.e. an array of arrays that each
terminates with a NULL.
Remember that all our inputs are (necessarily!) ASCII characters, i.e. 8-bit data items which are stored