Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Hamming_Distance( 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.

%include "/usr/share/csc314/asm_io.inc"

segment .data

format db "Hamming distance = %d",10,0

; the hamming distance between these is 1 str1 db "text",0 str2 db "test",0

segment .bss

segment .text global asm_main extern printf

asm_main: enter 0,0 pusha ;***************CODE STARTS HERE***************************

; call your ham dist function here ; pass str1 and str2 as arguments ; result gets returned in EAX

push eax ; the returned integer from hamdist() push format ; "Hamming distance = %d " call printf add esp, 8

;***************CODE ENDS HERE***************************** popa mov eax, 0 leave ret

hamdist:

ret

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2014 Nancy France September 15 19 2014 Proceedings Part 2 Lnai 8725

Authors: Toon Calders ,Floriana Esposito ,Eyke Hullermeier ,Rosa Meo

2014th Edition

3662448505, 978-3662448502

More Books

Students also viewed these Databases questions

Question

=+5 Does this case provide an example of the future for IHRM?

Answered: 1 week ago