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
Posted on 2009-12-23 11:22:54 by Yuri Grille
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?
Posted on 2009-12-23 14:16:34 by baldr

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
----------------

Posted on 2009-12-24 10:35:58 by Yuri Grille
Not fixed, you just added a (superfluous) data size specifier.

``movzx eax, byte ptr ds:``
Posted on 2009-12-24 10:47:12 by f0dder

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
Posted on 2009-12-24 11:24:40 by Yuri Grille
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.
Posted on 2009-12-24 11:28:43 by f0dder

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
Posted on 2009-12-24 11:33:03 by Yuri Grille
MOVZX expresses your intentions a bit more clearly, and iirc some CPUs have false dependency issues with partial register updates.
Posted on 2009-12-24 11:39:05 by f0dder
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?
Posted on 2009-12-24 12:30:51 by baldr