IUP Computer Science
CO 300 Assembly Language
Spring 1994

Program #5 (Due 13 April 1994)

Write an assembly language program that examines a series of text lines entered at the terminal and produces a frequency count of the occurrences of every three-letter word in the text.

To help you write this program two separately-compiled routines have been written. One routine, called CLEAN, is written in Pascal. It accepts two arguments: the address of a string and the address on a four-byte integer (the number of characters in the string). CLEAN replaces any punctuation marks in the string with blanks (space characters). It also converts uppercase characters to lowercase with the help of a procedure called MAKELOWER that you must write. Finally, CLEAN replaces the terminator character with a space. The other routine, called ORDER, is written in FORTRAN. It accepts three arguments: the address of a fixed-length string descriptor for an array of strings, the address of an array of two-byte frequency counts, and the address of the two-byte integer (number of entries in these arrays). ORDER sorts the two parallel arrays so that the strings are in alphabetical order. It does this with the help of a procedure called INTEXCH that you must write.

Your program should proceed as follows:

1.Display a line or two of explanation telling the user what to do. Then, repeatedly prompt the user with just "? " and read in lines of text. Each line must be no more than 78 characters long.

2.For each line that is read in,

a. Use CLEAN to remove the punctuation and make all characters lowercase.

b.Examine the characters of the line (after CLEANing) and locate each three-letter word on the line. For each such word found, search a array of three-letter words that your program maintains. If the word from the text can be located in the array, add one to the frequency count for the word. If the word from the text cannot be located in the array, add the word to the array and set its frequency count to 1. Notes: the array of three-letter words has NOTHING in it initially; you may assume that there are no more than 200 distinct three-letter words in the input.

3.Keep prompting and processing the text until the user enters a line with only a period(.) at the beginning.

4.When the period is entered, use the ORDER procedure to sort the parallel arrays of three-letter words and frequency counts. Then, display the sorted arrays (only the used portion) beneath a title line explaining what they are.

To make CLEAN work properly, you must write an assembly language procedure called MAKELOWER that has one argument: the address of a character. All that MAKELOWER has to do is change a character that is known to be in uppercase to lowercase. To make ORDER work properly, you must write an assembly language procedure called INTEXCH that has two arguments: addresses of two 2-byte integers. All that INTEXCH must do is exchange the values in the two integer. The MAKELOWER and INTEXCH procedures must be written in a separate file from the main program and assembled separate from the main program.

In the PROJECT directory, referenceable as P:, you will find the source and object files for CLEAN and ORDER. I recommend that you copy the two object files to your own directory for this project. After you have written and assembled your project #5 program and MAKELOWER and INTEXCH, you must link all four object files to make the executable file for this project.

Hand in a .LIS printout for the program and for MAKELOWER and INTEXCH. Also, hand in an image of the execution of the program (captured with CARBON) in which you enter 5 to 8 lines of text, in which there are at least 5 or 6 three-letter words, several of which occur more than once.

* * * * *

EXTRA CREDIT SECTION

For extra credit use the object file ORDERALT.OBJ instead of ORDER.OBJ. This alternate file contains an ORDER subroutine that relies upon two subroutines to exchange entries in the arrays of three-letter words and frequency counts. One of these subroutines is INTEXCH which is described above; the other is named CHAREXCH and is used to exchange entries in the array of three-letter words; this subroutine takes two arguments both of which are addresses of fixed-length string descriptors. All that CHAREXCH should do is exchange the contents of the two strings that are pointed to by the descriptors whose addresses are the arguments.

You must write the CHAREXCH subroutine in assembly language to get the extra credit. Put this subroutine in the same file as MAKELOWER and INTEXCH.