CSc 3210
Computer Organization and Programming
Fall 1999
Programming Assignment #5 (29 November 1999, Monday)
Assignment Objectives: To learn how to manipulate disk files using DOS services, process command line parameters, read lines of text from ascii files, search for substrings, and to become more proficient at writing assembly programs.
Problem Description: Write an assembler program that will perform a search of individual lines of text within text files for a given pattern. The pattern (a fixed string) to be searched will be the first of two command line parameters to your program. The second command line parameter will be a file specification (may include wild card characters * and ?). There could be any number of spaces between the command line parameters. If the search command is executed with fewer than two command line parameters, your program should respond with the message:
Usage: search pattern file-specafter displaying this message the program should terminate.
Submission Instructions: Submit search.asm and search.exe by the deadline and submit program listing of search.asm.
Hints:
INT 21H, Function 4EH ; Find first matching file INT 21H, Function 4FH ; Find next matching file INT 21H, Function 3DH ; Open file INT 21H, Function 3EH ; Close file INT 21H, Function 3FH ; Read record from file INT 21H, Function 1AH ; Set the Disk Transfer Area (DTA)
The following is a sample output assuming that there are only two files which match the file specification *.tex (f1.tex and f2.tex),
A:>type f1.tex This is line 1 of f1.tex This is line 2 of f1.tex This is Line 3 of f1.tex This is line 4 of f1.tex This is Line 5 of f1.tex This is Line 6 of f1.tex This is line 7 of f1.tex This is Line 8 of f1.tex This is line 9 of f1.tex This is Line 10 of f1.tex This is line 11 of f1.tex This is the last line (12) of f1.tex A:>type f2.tex This is line 1 of f2.tex This is 2 of f2.tex This is the last line of f2.tex A:>search line *.tex 1:F1.TEX:This is line 1 of f1.tex 2:F1.TEX:This is line 2 of f1.tex 4:F1.TEX:This is line 4 of f1.tex 7:F1.TEX:This is line 7 of f1.tex 9:F1.TEX:This is line 9 of f1.tex 11:F1.TEX:This is line 11 of f1.tex 12:F1.TEX:This is the last line (12) of f1.tex 1:F2.TEX:This is line 1 of f2.tex 3:F2.TEX:This is the last line of f2.tex