Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
I guess it is. You could even after check [esi] and [edi] after a mismatch to see which string is the smallest / biggest.
B.t.w. You have to load the offset of string1 and string2. You are now loading it with their first four characters as an address. I don't think that'll work.
But I don't think this is a real os-dev question. More for general programming and such.
I'd start by finding the size of both strings and working from there.
For instance, if both are aligned to an 8-byte boundary to perform the copy I can use an "unsigned long long" - effectively speeding up the operation 8 times.
The same can apply to such things as string comparison as well. The only function that I can think of off the top of my head that you can't do this in is strlen .
No, 32-bit processors support unsigned long long. 64-bit processors just use 64-bit variables to address stuff (so your pointers would be 8 bytes instead of 4).
Edit: There are other massive differences between 32-bit and 64-bit, I just only mentioned the relevant one.
; ASM CODE
; NASM SINTAX
;
cld
mov ecx,11 ; from 0 to 11
mov edi,string1 ; first string
mov esi,string2 ; second string
repe cmpsb
jne error ; error
;some code here
string1 db "One string!!" ; 12 bytes
string2 db "Another str" ; 12 bytes
Note the ECX and REPE.
The using cx in pmode for loops or rep etc, is a common misstake, that can give a nasty outcome, if ecx was holding say 0x800000 before this code
mov eax,[esi]
mov ebx,[esi+4]
mov ecx,[esi+8]
xor eax,[edi]
xor ebx,[edi+4]
xor ecx,[edi+8]
or eax,ebx
or eax,ecx
jne .different
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.