flat assembler
Message board for the users of flat assembler.

Index > Main > bytesort [sort byte array]

Author
Thread Post new topic Reply to topic
UCM



Joined: 25 Feb 2005
Posts: 285
Location: Canada
UCM
Does anybody have any code to sort an array of bytes? I've looked around, and it's mostly to sort dwords, and I cant seem to convert it

_________________
This calls for... Ultra CRUNCHY Man!
Ta da!! *crunch*
Post 27 Jun 2005, 00:48
View user's profile Send private message Reply with quote
Matrix



Joined: 04 Sep 2004
Posts: 1171
Location: Overflow
Matrix
Hy, it was easy to convert 4byte bubblesort to 1 byte, here you are:
Code:
; 
; bubble sort 
; input: edi = pointer to byte array, ecx = number of indexes 
; output: edi = pointer to sorted array 
; destroys:  al, edx, eflags 
; 
bubblesort0b: 
       lea     ebx,[edi+ecx] 
     mov     al,[edi] 
.cmploop:dec   ebx
       cmp     al,[ebx] 
   jle     .again 
      xchg    al,[ebx] 
.again:  cmp   ebx,edi 
     jnz     .cmploop 
stosb
loop bubblesort0b 
ret 
    


Last edited by Matrix on 29 Jun 2005, 08:47; edited 1 time in total
Post 27 Jun 2005, 08:41
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
Matrix wrote:

Matrix
Joined: 04 Sep 2004
Posts: 666
Location: Everywhere

What an evil matrix.
So now you've reached your goal and you won't post anymore? (Don't dare answer me, you'd ruin it all)
Twisted Evil Twisted Evil Twisted Evil
Post 27 Jun 2005, 09:28
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Vasilev Vjacheslav



Joined: 11 Aug 2004
Posts: 392
Vasilev Vjacheslav
Quote:
vid -> Posts: 777


hm, very strange Smile
Post 27 Jun 2005, 14:04
View user's profile Send private message Reply with quote
UCM



Joined: 25 Feb 2005
Posts: 285
Location: Canada
UCM
Thanks matrix, I'll try it.
Post 27 Jun 2005, 21:33
View user's profile Send private message Reply with quote
Matrix



Joined: 04 Sep 2004
Posts: 1171
Location: Overflow
Matrix
vid wrote:
Matrix wrote:

Matrix
Joined: 04 Sep 2004
Posts: 666
Location: Everywhere

What an evil matrix.
So now you've reached your goal and you won't post anymore? (Don't dare answer me, you'd ruin it all)
Twisted Evil Twisted Evil Twisted Evil


wehhehe ;>
Post 28 Jun 2005, 10:07
View user's profile Send private message Visit poster's website Reply with quote
UCM



Joined: 25 Feb 2005
Posts: 285
Location: Canada
UCM
wait, dont you mean 'loop bubblesort0b' on the second last line?
Post 28 Jun 2005, 22:29
View user's profile Send private message Reply with quote
Matrix



Joined: 04 Sep 2004
Posts: 1171
Location: Overflow
Matrix
yeah sorry, fast conversion Smile
Post 29 Jun 2005, 08:46
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.