Page 1 of 1

BGood Help! AAAHHH!!!

Posted: Tue Nov 22, 2005 3:02 pm
by AttentionKMartShoppers
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.

Re: BGood Help! AAAHHH!!!

Posted: Tue Nov 22, 2005 4:07 pm
by BGoodForGoodSake
AttentionKMartShoppers wrote:You are permitted to get help ONLY from the TAs and the instructor.
However I am permitted to give you tips

Think of the program as having two sub loops within a larger one.

data entry loop
string search loop

Design the first subloop first.

The first thing you need to do is print the prompt.
The next thing you need to develop is the capability to detect the number of characters being entered.

start
prompt user
input data
measure input length
if not valid goto start

Let me know when your done with these.

Then you can continue with the second half of the program which follows.

new memory = 0
read number of strings in memory
begin
ADD memory
if newmemory > number of strings in memory goto end
compare strings in first position
reach null x0000
check match
if no match goto begin
end
save position of match
if position is not null
output position
output no match found

I am sure this will be enough.
Any more and it would be cheating,
If you have help with the search and outputs let me know.

P.S. this is supposed to be a fun and simple program, perhaps you should stay away from lower level programming languages in the future if this is too difficult for you.

I.E. stick to VB or Mathematica or even Java. And focus more on Physics or Mathematics.

Posted: Tue Nov 22, 2005 7:17 pm
by Believer
Another reason computer programming might not be so fun (for me) :cry:.

Re: BGood Help! AAAHHH!!!

Posted: Tue Nov 22, 2005 7:57 pm
by Byblos
BGoodForGoodSake wrote:
AttentionKMartShoppers wrote:You are permitted to get help ONLY from the TAs and the instructor.
However I am permitted to give you tips

Think of the program as having two sub loops within a larger one.

data entry loop
string search loop

Design the first subloop first.

The first thing you need to do is print the prompt.
The next thing you need to develop is the capability to detect the number of characters being entered.

start
prompt user
input data
measure input length
if not valid goto start

Let me know when your done with these.

Then you can continue with the second half of the program which follows.

new memory = 0
read number of strings in memory
begin
ADD memory
if newmemory > number of strings in memory goto end
compare strings in first position
reach null x0000
check match
if no match goto begin
end
save position of match
if position is not null
output position
output no match found

I am sure this will be enough.
Any more and it would be cheating,
If you have help with the search and outputs let me know.

P.S. this is supposed to be a fun and simple program, perhaps you should stay away from lower level programming languages in the future if this is too difficult for you.

I.E. stick to VB or Mathematica or even Java. And focus more on Physics or Mathematics.
Believe it or not, I still have my assembly and micro code programs. It really was fun though. My very first program I wrote in PL/I on punch cards, submitted thru a card reader and compiled on an IBM mainframe 360/370. Dear Lord I'm ancient. That was in 1983, graduated in '86.

Posted: Tue Nov 22, 2005 8:33 pm
by AttentionKMartShoppers
Actually, we don't have to work alone on this project...haven't programmed yet, but thanks for the beginning push. I'll see what I can do. And it's not too difficult, I'm just not sure how to play with input and stuff like that yet. We just were taught the basics. And I was lazy, so sue me.
You must do the programming assignment in a group of not more than 3 people.

Posted: Tue Nov 22, 2005 9:07 pm
by BGoodForGoodSake
AttentionKMartShoppers wrote:Actually, we don't have to work alone on this project...haven't programmed yet, but thanks for the beginning push. I'll see what I can do. And it's not too difficult, I'm just not sure how to play with input and stuff like that yet. We just were taught the basics. And I was lazy, so sue me.
You must do the programming assignment in a group of not more than 3 people.
Oh ok, I understand laziness.
=)
Let me know if you need help.