diff options
author | tobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2009-05-08 15:00:25 +0000 |
---|---|---|
committer | tobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2009-05-08 15:00:25 +0000 |
commit | f44a93685ae651a08b51a2688a1c8d4c9ae2d28e (patch) | |
tree | 55a0e746490984861807e2a2ab349a1c29b028b9 /cmake/plugins/SDK/USDXStrUtils.pas | |
parent | 3dc85900d3b6f2bdd269229683452702c3d37cae (diff) | |
download | usdx-f44a93685ae651a08b51a2688a1c8d4c9ae2d28e.tar.gz usdx-f44a93685ae651a08b51a2688a1c8d4c9ae2d28e.tar.xz usdx-f44a93685ae651a08b51a2688a1c8d4c9ae2d28e.zip |
checkin of trunk-copy as base for cmake test
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/branches/experimental@1716 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to '')
-rw-r--r-- | cmake/plugins/SDK/USDXStrUtils.pas | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/cmake/plugins/SDK/USDXStrUtils.pas b/cmake/plugins/SDK/USDXStrUtils.pas new file mode 100644 index 00000000..94e5f65f --- /dev/null +++ b/cmake/plugins/SDK/USDXStrUtils.pas @@ -0,0 +1,79 @@ +unit USDXStrUtils; + +interface + +{$IFDEF FPC} + {$MODE Delphi} +{$ENDIF} + +uses ModiSDK; + +//function StrToAChar(Str: String): AChar; +function CreateStr(Str: PChar): PChar; +procedure FreeStr(Str: PChar); + +implementation + +{$IFDEF FPC} + {$ASMMODE Intel} +{$ENDIF} + +{function StrToAChar(Str: String): AChar; +var + L, I: Integer; +begin + L := Length(Str); + For I := 0 to L-1 do + AChar[I] := Str[I+1]; + + For I := L to 254 do + AChar[I] := #0; +end; } + +function StrCopy(Dest, Source: PChar): PChar; assembler; +asm + PUSH EDI + PUSH ESI + MOV ESI,EAX + MOV EDI,EDX + MOV ECX,0FFFFFFFFH + XOR AL,AL + REPNE SCASB + NOT ECX + MOV EDI,ESI + MOV ESI,EDX + MOV EDX,ECX + MOV EAX,EDI + SHR ECX,2 + REP MOVSD + MOV ECX,EDX + AND ECX,3 + REP MOVSB + POP ESI + POP EDI +end; + +function StrLen(Str: PChar): Cardinal; assembler; +asm + MOV EDX,EDI + MOV EDI,EAX + MOV ECX,0FFFFFFFFH + XOR AL,AL + REPNE SCASB + MOV EAX,0FFFFFFFEH + SUB EAX,ECX + MOV EDI,EDX +end; + +function CreateStr(Str: PChar): PChar; +begin + GetMem(Result, StrLen(Str) + 1); + StrCopy(Result, Str); +end; + +procedure FreeStr(Str: PChar); +begin + FreeMem(Str); +end; + +end. |