Recent

Author Topic: Old MoveJOH_PAS_3 move memory more fast , even copymemory or zeromemory?  (Read 325 times)

d2010

  • Full Member
  • ***
  • Posts: 159
Hello.
In few cases, I move memory (always move-memory fix 32characters fix exactly one point of project.lpr).
In that case, other user, say Must I replace copymemory with Move_i32, but
the program-developer must be 100% sure the size=32characters.
Code: Pascal  [Select][+][-]
  1. Procedure Move_i32(const ASource; var ADest; ACount: Integer);
  2. asm
  3.   mov ecx, [eax]
  4.   mov [edx], ecx             {4}
  5.   mov ecx, [eax + 4]
  6.   mov [edx + 4], ecx         {8}
  7.   mov ecx, [eax + 8]
  8.   mov [edx + 8], ecx         {12}
  9.   mov ecx, [eax + 12]
  10.   mov [edx + 12], ecx        {14}
  11.   mov ecx, [eax + 16]
  12.   mov [edx + 16], ecx        {16}
  13.   mov ecx, [eax + 20]
  14.   mov [edx + 20], ecx        {24}
  15.   mov ecx, [eax + 24]
  16.   mov [edx + 24], ecx        {24}
  17.   mov ecx, [eax + 28]
  18.   mov [edx + 28], ecx        {28}
  19. end;
  20.  
Example1: 

Code: [Select]
Procedure Good10Solutionl
Var cnt:integer;
Begin //more fast
   for  cnt:= 1 to (01 shl 20) do Move_i32(srce,dest,32);
End;

Procedure Slow10Solution;
Var cnt:integer;
Begin
   for  cnt:= 1 to (01 shl 20) do copymemory(dest,srce,32);
End;
C:Q1=Can I use this trick? in general it is very good for CrossPlatforms = Android, Linux, BeOs..?
C:Q2=It is good-solution for Move_i04,Move_i06? at means I replace
copymemory with
Procedure Move_i04(const ASource; var ADest; ACount: Integer);
Procedure Move_i08(const ASource; var ADest; ACount: Integer);
Procedure Move_f08(src:pchar;ADest:pchar; ACount: Integer);
Thank.

« Last Edit: April 24, 2025, 06:05:31 pm by d2010 »

BrunoK

  • Hero Member
  • *****
  • Posts: 697
  • Retired programmer
In a few cases, I move the memory (allal televisions the fixed memory 32 characters to fix a project point.lpr).
In this case, a wearer, pause Jeis repackaging the copy memory with Move-i32, but
the program-develling which is 100% secure in size of 32 characters.

Code: Pascal  [Select][+][-]
  1. Good10Solutionl
  2. Procedure
  3. Var knt: whole meter;
  4. Start  //more quick
  5.    for cnt:= 1 before (01cl 20) do Move_i32(srce, dest,32);
  6. The End;
  7.  
  8. Slow10Solution
  9. Procedure;
  10. Var knt: whole meter;
  11. Start
  12.    for n:= 1 before (01 wast 20) make a copy(dest,srce,32);
  13. The End;

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12189
  • FPC developer.
These are old D7 tricks, but the FPC move uses sse2 if available, and afaik so does D2006+

Did you test this is necessary at all? 
« Last Edit: April 25, 2025, 08:53:59 am by marcov »

Thaddy

  • Hero Member
  • *****
  • Posts: 16937
  • Ceterum censeo Trump esse delendam
Better not use that trick:
The compiler is often more efficient and your code is not portable.
It was OK about 20 years ago, though.
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

 

TinyPortal © 2005-2018