The MASM Forum Archive 2004 to 2012

Specialised Projects => Pelle's Macro Assembler Development => Topic started by: Vortex on March 20, 2011, 10:15:13 AM

Title: Sorting with msvcrt function qsort
Post by: Vortex on March 20, 2011, 10:15:13 AM
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.
Title: Re: Sorting with msvcrt function qsort
Post by: Vortex on January 08, 2012, 10:32:07 AM
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