A minimal-overhead (32-bit integer) compare procedure for the CRT qsort function:
OPTION PROLOGUE:NONE
OPTION EPILOGUE:NONE
align 4
compare proc C p1:DWORD, p2:DWORD
mov eax, [esp+4]
mov edx, [esp+8]
mov eax, [eax]
mov edx, [edx]
sub eax, edx
ret
compare endp
OPTION PROLOGUE:PrologueDef
OPTION EPILOGUE:EpilogueDef
But at least for the Microsoft compilers there is no need to code the procedure in MASM, because you can create a naked function in C that has the same minimal overhead, and that can use exactly the same assembly code. I can’t recall ever trying a naked function with GCC.