Hello to all people in this forum , firts, I´m not a English speaker , (I speak Spanish ) :
This is a Algorith made by me some months ago , I need your opinion about this and his speed and compare with others in time etc ..:
-------------------
tabla db 1024 dup (?)
datos db “hola que tal my name is Yuri Grille”,0 ; The data
mov ecx,34 ; << Length of data in decimal
mov edx,ecx ; << Backup
ordenamiento:
mov al,
inc dword ptr ds:
loop ordenamiento
xor eax,eax
ciclo:
mov ecx , dword ptr ds:
cmp ecx,0 ; If zero jump, because the character does not exist
jz salto
aun:
mov byte ptr ds:,al
dec edx
loop aun
salto:
dec al
jnz ciclo
----------------
Bye
Yuri Grille,
mov al, initializes only al, and you're using eax to index tabla. movzx (or xor eax, eax before first loop) will fix it.
What is the intended purpose of sorting some string bytewise?
mov al, initializes only al, and you're using eax to index tabla. movzx (or xor eax, eax before first loop) will fix it.
What is the intended purpose of sorting some string bytewise?
Sorry , I fix the problem :
-------------------
tabla db 1024 dup (?)
datos db “hola que tal my name is Yuri Grille”,0 ; The data
mov ecx,34 ; << Length of data in decimal
mov edx,ecx ; << Backup
ordenamiento:
mov al, byte ptr ds:
inc dword ptr ds:
loop ordenamiento
xor eax,eax
ciclo:
mov ecx , dword ptr ds:
cmp ecx,0 ; If zero jump, because the character does not exist
jz salto
aun:
mov byte ptr ds:,al
dec edx
loop aun
salto:
dec al
jnz ciclo
----------------
Not fixed, you just added a (superfluous) data size specifier.
movzx eax, byte ptr ds:
Hello , f0dder , the result is the same , look it in olly :
But , mov al, byte ptr ds: is in only 6 bytes .
00401007 > /0FB681FF1F4000 movzx eax, byte ptr ds:
0040100E . |8A81FF1F4000 mov al, byte ptr ds:
Thanks
No, the result isn't the same - MOVZX clears the top three bytes of EAX (and possibly rids you of false dependencies), where as MOV AL only loads the lower byte of EAX.
While it might not matter in your snippet, it matters if it's used elsewhere within other code, where the other bytes of EAX aren't clear on entry.
While it might not matter in your snippet, it matters if it's used elsewhere within other code, where the other bytes of EAX aren't clear on entry.
mmmmm , thanks f0dder , gracias muchas gracias.
Sorry is a error . Is better add : ?
xor eax,eax ?
And work after with :
al, byte ptr ds:
Is more faster ??
thanks
MOVZX expresses your intentions a bit more clearly, and iirc some CPUs have false dependency issues with partial register updates.
Yuri Grille,
Well, it appears that you're trying to implement in-place counting sort. Two questions arise:
1. String at datos is 35 characters in length, why your code insists on 34?
2. tabla is definitely array of dwords, why you declare it as bytes?
Well, it appears that you're trying to implement in-place counting sort. Two questions arise:
1. String at datos is 35 characters in length, why your code insists on 34?
2. tabla is definitely array of dwords, why you declare it as bytes?