CSE 378 Fall 2010 Homework 2: Simple Programming in x86-64

Due: Monday October 11th, 5:00pm

This assignment is intended to get you started programming in the x86-64 assembly language.
For this assignment you will be implementing the standard C string function, strstr.
strstr has the function signature:

char* strstr(char* haystack, char* needle)
and finds the first occurrence of the substring needle in the string haystack, returning a pointer to the beginning of the substring, or NULL if the substring is not found.

What you should do:

  1. Download the provided template file for GNU/Linux, Mac OSX or if you're using Windows, compile the C template with all optimzations turned off.

  2. Implement the body of the strstr function.

  3. Compile your assembly program with the following command:
    gcc -o hw2 hw2-template.s
  4. Test your solution by executing the generated 'hw2' exectuable. You may want to modify the existing haystack and needle strings in the data section of your assembly file for this step. To execute your compiled exectuable you can use the command:
    ./hw2
  5. Turn-in your completed assembly code file to the course's Catalyst CollectIt dropbox. Be sure you have commented your code as necessary to help your TAs give you as much partial credit as possible. Also ensure you've placed your name in the block of comments at the top of the file.