Project 3 Description --------------------- In this project you'll do I/O as well as acquaint yourself with C-style strings and dynamic memory management. Getting rolecks --------------- Rolecks is available off of the course website (www.cs.umass.edu/~trekp/cs201). It is an executable Jar file, so any system running a reasonably recent version of Java should be able to run it. Make sure you get the latest version! Rolecks is regularly being extended and improved (read: bug fixes). Make sure you grab a recent copy before starting. Loading and running your code ----------------------------- You can write your code in your text editor of choice. To assemble it, click on the 'assemble file' button in rolecks. This will generate a simple binary version of the file (if the file was named foo.s the binary form will be named foo.bin). To load up the binary, click on the 'Open Executable' button in rolecks. The Problem ----------- The problem here is to read two strings from the user, then decide whether the second string is a substring of the first string and then to print out the index of the first occurance of the substring. So, for instance, if the first string was "I am a relatively short string", and the second string was "am" the program should output "2". Remember, these strings are going to be NULL-terminated and zero-indexed. Also remember that these strings are case-sensitive, so "foo" doesn't match "Foo", so simply comparing the raw ASCII values is fine. Getting the Input Strings -------------------------- The process of getting the strings will be similar to that for project 2, with some modifications. Actually fetching the characters from standard input is accomplished with SWI #h00F00001, the new part is that you have no idea how long these input strings are going to be. They could be 4 characters long, but they could just as easily be 4000 characters long. Here's where you're going to need dynamic memory. You should read in the characters, one at a time, and then store them in the heap. Growing the heap as you need in order to accommodate the string. So you're going to have to allocate as you go. Remember SWI #h00F0000F will grab a page of free memory from the OS and stick it on the end of your heap, placing the address of the 0-th byte in that page in R0. You're going to have to maintain storage for two strings as well as pointers to them. Inputting the Strings ---------------------- Every string you type into Standard Input (and commit with an enter) is appended to the buffer read by SWI #h00F00001. So, you can simply type in the two strings in succession before you launch your program. The strings will still be NULL-terminated. Outputting the index -------------------- The index should be outputted in decimal and ended with a newline ('\n', ASCII char 0x0a). If there is no occurance of the second string in the first, your program should output "No.\n". Again, '\n' is the newline character (ASCII 0x0a). The Extended Problem For Honors Students ---------------------------------------- Those of you in the honors section have a larger problem. You must print out the index of every occurance of the substring in the first input string. For instance if the first string was "Goo Goo GaJoob" and the second string was "Goo", then your program should output "0\n4\n". Similarly, if the first string is "amam amulet" and the second string was "am" then your output should be "0\n2\n5\n". Submitting your code -------------------- Submit your code by e-mailing to trekp@cs.umass.edu a message with: "CS201 Project 3 Submission, " in the subject line, where "" is replaced with your actual name. Attach the source code, which should be in a file named "proj3.s" to the message.