Hack Forums
[Assembly] Basic code a sort algorithm in assembly - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Coders Lounge (https://hackforums.net/forumdisplay.php?fid=5)
+---- Thread: [Assembly] Basic code a sort algorithm in assembly (/showthread.php?tid=5903564)



Basic code a sort algorithm in assembly - tim - Nov 4, 2018

Can someone do this for me? Can pay.

It must be hand coded in gnu assembler type instructions.

Thanks.


RE: Basic code a sort algorithm in assembly - SIM-3364521 - Feb 9, 2019

I know this is late but have you found sb to do it for you?
Also what kind of sort should it be? would bouble sort be enough or should it be more efficient?
and what kind of data should be sortet? Just a simple byte array?

If you can provide these information i might be able to help you :)


RE: Basic code a sort algorithm in assembly - PELock - Feb 22, 2019

Bubble sort:

Code
_bsort proc uses esi edi ebx, _lpArray:dword, _uCount:dword

mov esi, _lpArray
mov ecx, _uCount
_bsort_loop:
lea ebx, [esi+ecx*4]
mov eax, dword ptr[esi]
_bsort_compare:
sub ebx, 4
cmp eax, dword ptr[ebx]
jle @F
xchg eax, dword ptr[ebx]
@@:
cmp ebx, esi
jnz _bsort_compare
mov dword ptr [esi], eax
add esi, 4
dec   ecx
       jne    _bsort_loop
ret
_bsort endp