Question: Assembly Language #include #include char str1[] = text; char str2[] = test; int hamdist(char *a, char *b) { int c; int unmatched; unmatched = 0;

Assembly Language

Assembly Language #include #include char str1[] = "text"; char str2[] = "test";

#include

#include char str1[] = "text";

char str2[] = "test";

int hamdist(char *a, char *b) { int c;

int unmatched;

unmatched = 0;

for(c = 0;

a[c] != '\0';

c++) { if(a[c] != b[c]) unmatched++;

} return unmatched;

}

int main()

{ printf("Hamming distance = %d ", hamdist(str1, str2));

}

The "hamming distance" between two strings of equal length is defined as the number of positions at which the corresponding characters are different. In other words, how many characters would need to be changed in order to make the strings equal For instance.. Hamming Distance( text, test ) = 1 Hamming Distance( text, tell ) = 2 HammingDistance ( text, told ) 3 Hamming Distance( text, bold ) = 4 - I have attached a file called hamdist.c which is a complete implementation of the hamming distance function. Feel free to compile and test it if you like. Note that strings of any length can be passed in, since it will continue checking until it encounters a null terminator Your assignment is to implement this function in assembly. I have included a second file, hamdist.asm, as a skeleton to get you started if needed. Please utilize the concepts we have been working on: functions, parameters, local variables, and frame pointers. Specifically, I will be looking for... 1. A separate, standalone function, accessed with call/ret. 2. Two parameters passed from main) to hamdist) in the proper way 3. An EBP based stack frame complete with prologue and epilogue 4. Two local variables: the loop counter and the distance counter 5. Parameters and local variables accessed properly using the frame pointer The "hamming distance" between two strings of equal length is defined as the number of positions at which the corresponding characters are different. In other words, how many characters would need to be changed in order to make the strings equal For instance.. Hamming Distance( text, test ) = 1 Hamming Distance( text, tell ) = 2 HammingDistance ( text, told ) 3 Hamming Distance( text, bold ) = 4 - I have attached a file called hamdist.c which is a complete implementation of the hamming distance function. Feel free to compile and test it if you like. Note that strings of any length can be passed in, since it will continue checking until it encounters a null terminator Your assignment is to implement this function in assembly. I have included a second file, hamdist.asm, as a skeleton to get you started if needed. Please utilize the concepts we have been working on: functions, parameters, local variables, and frame pointers. Specifically, I will be looking for... 1. A separate, standalone function, accessed with call/ret. 2. Two parameters passed from main) to hamdist) in the proper way 3. An EBP based stack frame complete with prologue and epilogue 4. Two local variables: the loop counter and the distance counter 5. Parameters and local variables accessed properly using the frame pointer

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!