CS33 -- Laboratory 7

Due: Thursday, Oct 21 by 11:59 pm

This lab is really a take-home part of the midterm. Please work on your own. You may use the text book, and any material that I have provided to you without reference. Please do NOT use any other sources. After the in-class midterm on Weds, 20 Oct, I will make available, on this webpage, an exercise to be solved and tested. I expect that the work can be completed in about an hour.

I have provided you with a file called takeprob.asm. Your task is to edit it so that it does the level of string matching asked for, test and debug your solution using the lc3 simulator. Once you have a working assembly language program, email it to me as an ATTACHMENT to an email message whose subject says CS33 takehome. I should receive the email by Thursday, Oct 21 11:59 pm .

In my pub directory: /home/cfk/pub/cs33/week7/, there is a file called: takeprob.asm. Copy it to your week7 subdirectory and add code to it so that it does a version of 'string matching'.

That file contains part of an LC3 assembly language program to do 'string matching'. String matching is important in text-editing programs and DNA sequence analysis. Because of its importance, there are many clever string-matching algorithms. I am not asking you to be clever. Just do the string matching any way that you can.

The program is to search for a pattern of characters in a text string. If the pattern occurs in the text, then your program should output the position in the text of the beginning of the first match. If the pattern does not occur, your program should output No match. I have given you the part that reads in the pattern and text from the user into buffers called patbuf and txtbuf respectively. I have also given you output code assuming you can get the correct position into R0 just before the
jsr BinarytoASCII. If there is no match you should branch to nomtch. Assume that the pattern will be <=10 characters and that the text will be <= 80 characters.

Here are some sample runs of my solution:

--- halting the LC-3 --- Enter pattern and Enter text Monkeys like a banana and berries. The first occurance of the pattern starts at pos: +023 Enter pattern an Enter text Monkeys like a banana and berries. The first occurance of the pattern starts at pos: +017 Enter pattern rotten Enter text CS33 is great. No match. Enter pattern CS Enter text CS33 is great The first occurance of the pattern starts at pos: +001 Enter pattern eat Enter text CS33 is great The first occurance of the pattern starts at pos: +011 Enter pattern eats Enter text CS33 is great No match.

Note: As of 1 Oct, the final exam for CS33 has been scheduled by the registrar for Friday 12/17/2010, 9:00am-12:00pm in SC240. Plan to attend.