New function's UpperCase / LowerCase



Hi

I think these function's without the lookup table runs reasonable fast on my
AMD64. But that about all the INTEL cpu's ?

I dont think this is the fastest function but small :-)

Regards,
Lars G

(*
Author: Lars Bloch Gravengaard
Date: 25/11 2006
Instructionset(s): PAS
Function size 79 bytes
*)

function UpperCase_LBG_Pas_1_a(const S: string): string;
const a=1;
var
Max, CharNo : Cardinal;
pResult : PChar;
begin
Max := Length(S);
SetLength(Result, Max);
if Max <= 0 then exit;
pResult := PChar(Result);
CharNo := 0;
repeat
pResult[CharNo] := S[CharNo+a];
if (S[CharNo+a] >= 'a') and (S[CharNo+a] <= 'z') then
pResult[CharNo] := char(Ord(S[CharNo+a]) - 32);
Inc(CharNo);
until(CharNo >= Max);
end;


(*
Author: Lars Bloch Gravengaard
Date: 25/11 2006
Instructionset(s): PAS
Function size 79 bytes
*)

function LowerCase_LBG_Pas_1_a(const S: string): string;
const a=1;
var
Max, CharNo : Cardinal;
pResult : PChar;
begin
Max := Length(S);
SetLength(Result, Max);
if Max <= 0 then exit;
pResult := PChar(Result);
CharNo := 0;
repeat
pResult[CharNo] := S[CharNo+a];
if (S[CharNo+a] >= 'A') and (S[CharNo+a] <= 'Z') then
pResult[CharNo] := char(Ord(S[CharNo+a]) + 32);
Inc(CharNo);
until(CharNo >= Max);
end;


.



Relevant Pages

  • Re: Anyone working on multi-core optimizations?
    ... Typically you need arrays about 10000 elements long, ... threading individual functions becomes meaningfull. ... CharNo: Cardinal; ... pResult: PChar; ...
    (borland.public.delphi.language.basm)
  • Re: New functions UpperCase / LowerCase
    ... Max, CharNo: Cardinal; ... pResult: PChar; ...
    (borland.public.delphi.language.basm)
  • Re: Anyone working on multi-core optimizations?
    ... But seriously, isn't any function that can be logically split into multiple sections, that can be executed simultaneously, a candidate for multi-threading? ... CharNo: Cardinal; ... pResult: PChar; ...
    (borland.public.delphi.language.basm)
  • Re: New functions UpperCase / LowerCase
    ... pResult:= PChar; ... performs an unnecessary call of the @LStrToPChar function. ... uses 2 conditional jumps. ... Max, CharNo: Cardinal; ...
    (borland.public.delphi.language.basm)