News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Sorting with msvcrt function qsort

Started by Vortex, March 20, 2011, 10:15:13 AM

Previous topic - Next topic

Vortex

Here is a quick sort demo using the msvcrt function qsort. This example was originally coded with Masm. I translated it to Poasm. qsort2 is the UNICODE version.

Vortex

CompareProc eliminating the dependency _stricmp :

CompareProc PROC C USES esi edi arg1:DWORD,arg2:DWORD

    mov     eax,arg1
    mov     ecx,arg2
    mov     esi,DWORD PTR [eax]
    mov     edi,DWORD PTR [ecx]
    mov     edx,-1
@@:
    add     edx,1
    movzx   eax,BYTE PTR [esi+edx]
    test    eax,eax
    jz      l2
    cmp     al,BYTE PTR [edi+edx]
    je      @b
l1:
    sub     al,BYTE PTR [edi+edx]
    jc      l3
    mov     eax,1
l2:         
    ret
l3:
    xor     eax,eax
    mov     eax,-1

    ret

CompareProc ENDP