V22.0201 -- Fall 1997
Nathan Hull

Assignment #2

Due: The Day of the Midterm


The second programming assignment is to implement a merge program in assembly language as follows. It should take as input 2 arrays of characters, sorted in decreasing order. It should merge them together (in order) into a larger array, leaving the original arrays intact. The arrays can be read in one array per line (terminated with a CR). They should be arrays of printable characters. Each character should only occupy one byte in memory. Your program should print an error to the screen if the arrays exceed the space allocated for them.

For example, with input arrays PJFEDCB and ZQNMGB, your program should produce as output something like:

Array 1: PJFEDCB

Array 2: ZQNMGB

Merged array: ZQPNMJGFEDCBB

Make sure your program can handle any size arrays up to 128 characters, including the case where the two arrays are different sizes, or one or both of them are of length 0.

Your program should print out the 2 arrays before merging, as well as the final merged array, using the DOS functions (i.e. using INT 21h) described in class. Remember that you will have to take care of the carriage return and line feed screen operations yourself.


To be handed in:

A printed copy of the program.

A printed copy of the output it produced on the test data of your choice.

A floppy disk containing the source file(s).

We will also be running your program on our own test data, so make sure your program is well tested!


EXTRA CREDIT: Have your program merge two arrays of integers instead of characters. The difficulty here will be in doing the output: an integer will need to be converted to ASCII before printing. For moderate extra credit, you can print the hex representation of each number. For full extra credit, your program should print the ASCII characters corresponding to the decimal value of each number.