unit FastcodeStrCompUnit; //Version : 0.1 Preliminary version //Only direct calling supported interface function StrCompFastcodeP3(const Str1, Str2: PChar): Integer; function StrCompFastcodeP4(const Str1, Str2: PChar): Integer; //function StrCompFastcodePrescott(const Str1, Str2: PChar): Integer; function StrCompFastcodeOpteron(const Str1, Str2: PChar): Integer; function StrCompFastcodeXP(const Str1, Str2: PChar): Integer; function StrCompFastcodeRTL(const Str1, Str2: PChar): Integer; function StrCompFastcodeBlended(const Str1, Str2: PChar): Integer; function StrCompFastcodePascal(const Str1, Str2: PChar): Integer; implementation //Author: Aleksandr Sharahov //Date: N/A //Optimized for: P3 //Instructionset(s): N/A //Original Name: StrCompSha3 function StrCompFastcodeP3(const Str1, Str2: PChar): Integer; assembler; asm sub edx, eax //pointers MUST be not NULL @next: movzx ecx, [eax+edx] add eax, 1 test cl, cl jz @last cmp cl, [eax-1] je @next @last: movzx eax, [eax-1] sub eax, ecx end; //Author: Aleksandr Sharahov //Date: N/A //Optimized for: P4 //Instructionset(s): N/A //Original Name: StrCompSha3 function StrCompFastcodeP4(const Str1, Str2: PChar): Integer; assembler; asm sub edx, eax //pointers MUST be not NULL @next: movzx ecx, [eax+edx] add eax, 1 test cl, cl jz @last cmp cl, [eax-1] je @next @last: movzx eax, [eax-1] sub eax, ecx end; //Author: Aleksandr Sharahov //Date: N/A //Optimized for: XP //Instructionset(s): N/A //Original Name: StrCompSha3 function StrCompFastcodeXP(const Str1, Str2: PChar): Integer; assembler; asm sub edx, eax //pointers MUST be not NULL @next: movzx ecx, [eax+edx] add eax, 1 test cl, cl jz @last cmp cl, [eax-1] je @next @last: movzx eax, [eax-1] sub eax, ecx end; //Author: Aleksandr Sharahov //Date: N/A //Optimized for: Opteron //Instructionset(s): N/A //Original Name: StrCompSha3 function StrCompFastcodeOpteron(const Str1, Str2: PChar): Integer; assembler; asm sub edx, eax //pointers MUST be not NULL @next: movzx ecx, [eax+edx] add eax, 1 test cl, cl jz @last cmp cl, [eax-1] je @next @last: movzx eax, [eax-1] sub eax, ecx end; //Author: Aleksandr Sharahov //Date: N/A //Optimized for: RTL //Instructionset(s): N/A //Original Name: StrCompSha3 function StrCompFastcodeRTL(const Str1, Str2: PChar): Integer; assembler; asm sub edx, eax //pointers MUST be not NULL @next: movzx ecx, [eax+edx] add eax, 1 test cl, cl jz @last cmp cl, [eax-1] je @next @last: movzx eax, [eax-1] sub eax, ecx end; //Author: Aleksandr Sharahov //Date: N/A //Optimized for: Blended //Instructionset(s): N/A //Original Name: StrCompSha3 function StrCompFastcodeBlended(const Str1, Str2: PChar): Integer; assembler; asm sub edx, eax //pointers MUST be not NULL @next: movzx ecx, [eax+edx] add eax, 1 test cl, cl jz @last cmp cl, [eax-1] je @next @last: movzx eax, [eax-1] sub eax, ecx end; //Author: Aleksandr Sharahov //Date: N/A //Optimized for: Pascal //Instructionset(s): N/A //Original Name: StrCompShaPas3 function StrCompFastcodePascal(const Str1, Str2: PChar): Integer; var ch, dist: integer; p: pchar; begin; p:=str1; dist:=str2-p; repeat; ch:=shortint(p[dist]); inc(p); until (ch=0) or (byte(ch)<>byte(p[-1])); Result:=ord(p[-1])-byte(ch); end; end.