BGood Help! AAAHHH!!!
Posted: Tue Nov 22, 2005 3:02 pm
Department of Electrical and Computer Engineering
University of Texas at Austin
EE 306
Fall 2005
Instructor: Dr. Tony Ambler
TAs: Nikhil Patil, Geethapriya Raghavan, Madhavi Kandamani, Jeremy Carrillo, Prahlad Enuganti, Lavanya Chockalingam, Pankaj Adhikari, Xiao Pu, Sowmya Ramachandran
Programming Assignment 4
Due: Wednesday, November 30, 2005 11:59 pm
You must do the programming assignment in a group of not more than 3 people. You are permitted to get help ONLY from the TAs and the instructor. Submission will follow the procedures posted under the course documents section of the website. If this program is done in a group, please submit only 1 program with a comment containing the group members' names at the top.
In this assignment, you are asked to write a program in LC-3 assembly language. Please note that your submitted program should be named string.asm.
In this assignment, you are asked to write a program that takes a string as input and searches through a set of strings already stored in memory to tell whether the input string already exists in memory. Your program should first print the prompt:
Please input a string and press enter.
Note that your prompt should be identical to the one shown. In addition, you should output a line feed (ASCII character LF = x0A) to move the cursor to the next line. Then, you should capture the input until the user hits the enter key. The input string will be restricted to 5 letters; however, this does not mean that the user will stop at 5 letters. If the string the user has input is longer than 5 letters or less than 1 letter, you should output the following prompt:
Invalid string. Please input a string and press enter.
Note that this prompt should only show up after the user has pressed enter, and you should once again have a line feed at the end of the prompt. Your prompt should once again be identical to the one shown.
After the user has input the string, your program should check to see if the input string matches any of the strings already stored in memory. Memory location x3200 will hold the number of strings in memory. Each string will consist of a sequence of characters followed by the null character (i.e. x0000) to signal the end of the string. The strings will be stored in consecutive memory locations starting at location x3201. For example, if there are two strings (“one” and “two”) stored in memory, the following is what will be seen in memory:
x3200 x0002
x3201 ASCII value of “o”
x3202 ASCII value of “n”
x3203 ASCII value of “e”
x3204 x0000
x3205 ASCII value of “t”
x3206 ASCII value of “w”
x3207 ASCII value of “o”
x3208 x0000
Your program should compare the input string to those found in memory and stop when it finds the first occurrence of the input string. If the string is found you should output the address (in hexadecimal) of the first character in memory where the string was found. If it is not found, you should output:
The string was not found.
Once again, your output should be identical to the line shown with a line feed. There is no limit to the number of strings in memory, nor is there a limit on the length of the strings (such that they still fit in memory).
The following is an example based upon the above example of strings already stored in memory:
Please input a string and press enter.
abcdef
Invalid string. Please input a string and press enter.
two
String found at location x3205
At this point your program should halt. Here is another example based on the same strings already stored in memory.
Please input a string and press enter.
on
The string was not found.
At this point your program should halt. Please note that the string in memory must be exactly identical to the input string, including length (i.e. “on” is not found even though memory contains “one”). In both example cases, your output should be identical to the output shown.
Your program should not be case sensitive. That is, if the input string is 'ONE' in the above example, then the string should be found. You may not assume that the strings stored in memory are in lower case or upper case. For example, suppose we have:
x3200 x0002
x3201 ASCII value of “o”
x3202 ASCII value of “N”
x3203 ASCII value of “E”
x3204 x0000
x3205 ASCII value of “t”
x3206 ASCII value of “w”
x3207 ASCII value of “o”
x3208 x0000
If the user inputs the string 'One', then your program should find the string at location x3201.
Your program MUST start at x3000. Our test program will store the number of strings in memory location x3200 and the strings following that. To test your program, you should use the simulator to store these values yourselves. However, your program should not have anything in those locations when you turn in it in. If the address contains a letter (A-F), make sure that you output the capital letter (i.e. x320F).
NOTE: In order to make things easier for you, it can be assumed that the strings contain only alphabetic characters.
THIS IS HILARIOUS.
University of Texas at Austin
EE 306
Fall 2005
Instructor: Dr. Tony Ambler
TAs: Nikhil Patil, Geethapriya Raghavan, Madhavi Kandamani, Jeremy Carrillo, Prahlad Enuganti, Lavanya Chockalingam, Pankaj Adhikari, Xiao Pu, Sowmya Ramachandran
Programming Assignment 4
Due: Wednesday, November 30, 2005 11:59 pm
You must do the programming assignment in a group of not more than 3 people. You are permitted to get help ONLY from the TAs and the instructor. Submission will follow the procedures posted under the course documents section of the website. If this program is done in a group, please submit only 1 program with a comment containing the group members' names at the top.
In this assignment, you are asked to write a program in LC-3 assembly language. Please note that your submitted program should be named string.asm.
In this assignment, you are asked to write a program that takes a string as input and searches through a set of strings already stored in memory to tell whether the input string already exists in memory. Your program should first print the prompt:
Please input a string and press enter.
Note that your prompt should be identical to the one shown. In addition, you should output a line feed (ASCII character LF = x0A) to move the cursor to the next line. Then, you should capture the input until the user hits the enter key. The input string will be restricted to 5 letters; however, this does not mean that the user will stop at 5 letters. If the string the user has input is longer than 5 letters or less than 1 letter, you should output the following prompt:
Invalid string. Please input a string and press enter.
Note that this prompt should only show up after the user has pressed enter, and you should once again have a line feed at the end of the prompt. Your prompt should once again be identical to the one shown.
After the user has input the string, your program should check to see if the input string matches any of the strings already stored in memory. Memory location x3200 will hold the number of strings in memory. Each string will consist of a sequence of characters followed by the null character (i.e. x0000) to signal the end of the string. The strings will be stored in consecutive memory locations starting at location x3201. For example, if there are two strings (“one” and “two”) stored in memory, the following is what will be seen in memory:
x3200 x0002
x3201 ASCII value of “o”
x3202 ASCII value of “n”
x3203 ASCII value of “e”
x3204 x0000
x3205 ASCII value of “t”
x3206 ASCII value of “w”
x3207 ASCII value of “o”
x3208 x0000
Your program should compare the input string to those found in memory and stop when it finds the first occurrence of the input string. If the string is found you should output the address (in hexadecimal) of the first character in memory where the string was found. If it is not found, you should output:
The string was not found.
Once again, your output should be identical to the line shown with a line feed. There is no limit to the number of strings in memory, nor is there a limit on the length of the strings (such that they still fit in memory).
The following is an example based upon the above example of strings already stored in memory:
Please input a string and press enter.
abcdef
Invalid string. Please input a string and press enter.
two
String found at location x3205
At this point your program should halt. Here is another example based on the same strings already stored in memory.
Please input a string and press enter.
on
The string was not found.
At this point your program should halt. Please note that the string in memory must be exactly identical to the input string, including length (i.e. “on” is not found even though memory contains “one”). In both example cases, your output should be identical to the output shown.
Your program should not be case sensitive. That is, if the input string is 'ONE' in the above example, then the string should be found. You may not assume that the strings stored in memory are in lower case or upper case. For example, suppose we have:
x3200 x0002
x3201 ASCII value of “o”
x3202 ASCII value of “N”
x3203 ASCII value of “E”
x3204 x0000
x3205 ASCII value of “t”
x3206 ASCII value of “w”
x3207 ASCII value of “o”
x3208 x0000
If the user inputs the string 'One', then your program should find the string at location x3201.
Your program MUST start at x3000. Our test program will store the number of strings in memory location x3200 and the strings following that. To test your program, you should use the simulator to store these values yourselves. However, your program should not have anything in those locations when you turn in it in. If the address contains a letter (A-F), make sure that you output the capital letter (i.e. x320F).
NOTE: In order to make things easier for you, it can be assumed that the strings contain only alphabetic characters.
THIS IS HILARIOUS.