IUP Computer Science
COSC 300 Spring 2002

Project  #2
(Due in class on 22 February 2002)

Write an assembly language program that compresses text by removing the white space that is in it, and keeping track of how many non-white space characters there are.  The program should declare one or more variables that hold character information (the text). This text should include all types of white space - blanks, 0dh (returns), 0ah (linefeeds), and 09h (tabs); there should be more than 300 characters in the text;  it should occupy at least four lines if it were displayed; and the text should end with a $  The total number of characters may NOT be stored in any variable in the program; also, the total number of characters may NOT be used as a constant (numeric or symbolic) in the program.

The program should use program offset information to determine how many total characters are in the text and then use that number in loop control to examine the text, count the non-white space characters and move them to a compressed text area (do not change the original text). After all original characters have been examined, the program should display the compressed text.  The count of non-white space characters should be stored in a word (2-byte) area named CCOUNT    Below is an example of the something you might use as the text, although it is a bit on the short side. Do not use this sample in your program; use something you make up yourself.

lines   db    09h,"This is a message containing several lines.",0dh,0ah
        db    "Among the things it does not have are "
        db    "any complex words, or even hard to pronounce ones.",0dh,0ah
        db    "These lines in the middle are nothing but padding.  They "
        db    "could easily be ",0dh,0ah,"omitted, except for the need to "
        db    "have at least 300 characters overall.  "
        db    0dh,0ah,"One more decent sentence should do it; 300 really "
        db    "isn't that many.  This should be enough.  "
        db    0dh,0ah,09h
        db    "The last line is nothing special, just #@%*&!~#(&)#@ garbage."
        db    0dh,0ah,"The end.     ",0dh,0ah,"$"
The only restrictions on the characters in the text are that they must be displayable and that there must be only one $ (and it must be last). If the example above is used in a program, the program should display the following as compressed text.  There are 361 (0169h) non-white space characters in this text.
Thisisamessagecontainingseverallines.Amongthethingsitdoesnothaveareanycomplexwor
ds,orevenhardtopronounceones.Theselinesinthemiddlearenothingbutpadding.Theycould
easilybeomitted,exceptfortheneedtohaveatleast300charactersoverall.Onemoredecents
entenceshoulddoit;300reallyisn'tthatmany.Thisshouldbeenough.Thelastlineisnothing
special,just#@%*&!~#(&)#@garbage.Theend.
Hand in an assembly-generated listing of your well-commented program.  Also, name the source file (.asm file) after yourself, as in  yourlastname.asm and copy it to the hand-in folder for this course on the P: drive, i.e., to  P:\courses\spring2002\cosc\cosc300\xxx\hand-in   where xxx is your section number.

Notes: Do NOT attempt to input the text to be examined; it must be declared in the program itself.  The $ is not displayed in the compressed text because of the DOS function I used to make this display.