Is there a better way to compare files other than
read x bytes
compare y bytes

Posted on 2001-11-23 19:48:14 by lackluster
i do not know what you mean:
a better or a faster way?

for example in HE we can not send the whole world file via the network from one machine client to the other, instead we do a CRC (or you can do a MD5) on each file and send only the result (ie a dword for CRC) to compare... if files are diffrent its pretty sure that the CRC32 will be diffrent (but not 100% sure...)
Posted on 2001-11-23 20:48:01 by BogdanOntanu

The choice is really between doing the comparison directly from the disk files which is really slow, or loading equal parts into memory and comparing them sections at a time. On smaller files you could load both of them directly in memory but as they get larger, doing a section at a time is the only reliable way to handle it.

The comparison code is not hard to write, address of both sections of memory in say ESI and EDI, set ECX as a loop counter and make an exit condition for mismatch.

Posted on 2001-11-24 00:03:11 by hutch--
Just the other day I wrote code that compared two strings one char at a time like Hutch had mentioned:

; Loop through the login strings to see if they match...
mov eax, offset buffer ; Load offset (user input) into eax...
mov edi, eax ; and put into edi
mov eax, offset LoginString ; Load offset into eax...
mov esi, eax ; and put into esi
mov ecx, sizeof LoginString ; How many bytes we need to loop through
repe cmpsb ; Repeat comparasin of each byte
cld ; Clear direction flag
jnz ErrorDisplay ; Show error if login not right...

Just thought I'd post it incase anyone might find it useful. I used it as part of a login program... I was just trying to further my skills...

Just an after thought - the code above might be too slow for your application so you'll want to edit the compare instruction and do the loop yourself.
Posted on 2001-11-24 11:24:40 by JamesE