RDP1974 40 Posted November 25, 2024 question do you remember the good old https://fastcode.sourceforge.net/ ? (2007 project) I asked chatgpt to convert asm32 to asm64 delphi, look at this example:  procedure MoveJOH_SSE2_10(const Source; var Dest; Count : Integer); asm  cmp   ecx, TINYSIZE  ja    @@Large {Count > TINYSIZE or Count < 0}  cmp   eax, edx  jbe   @@SmallCheck  add   eax, ecx  add   edx, ecx  jmp   SmallForwardMove_10 @@SmallCheck:  jne   SmallBackwardMove_10  ret {For Compatibility with Delphi's move for Source = Dest} @@Large:  jng   @@Done {For Compatibility with Delphi's move for Count < 0}  cmp   eax, edx  ja    Forwards_SSE2_10  je    @@Done {For Compatibility with Delphi's move for Source = Dest}  sub   edx, ecx  cmp   eax, edx  lea   edx, [edx+ecx]  jna   Forwards_SSE2_10  jmp   Backwards_SSE2_10 {Source/Dest Overlap} @@Done: end; {MoveJOH_SSE2}  chat gpt rewrite this in 64bit: procedure MoveJOH_SSE2_10(const Source; var Dest; Count: Integer); asm  cmp   r8d, TINYSIZE     // Compare Count (R8D) with TINYSIZE  ja    @@Large        // If Count > TINYSIZE or Count < 0, jump to @@Large  cmp   rcx, rdx       // Compare Source (RCX) with Dest (RDX)  jbe   @@SmallCheck  add   rcx, r8        // Adjust Source address: Source + Count  add   rdx, r8        // Adjust Dest address: Dest + Count  jmp   SmallForwardMove_10  // Jump to small forward move @@SmallCheck:  jne   SmallBackwardMove_10 // If Source ≠Dest, use backward move  ret              // If Source = Dest, exit (compatible with Delphi’s Move) @@Large:  jng   @@Done         // If Count < 0, exit (compatible with Delphi’s Move)  cmp   rcx, rdx  ja    Forwards_SSE2_10    // If Source > Dest, use forward move  je    @@Done         // If Source = Dest, exit  sub   rdx, r8        // Adjust Dest address: Dest - Count  cmp   rcx, rdx  lea   rdx, [rdx + r8]    // Restore original Dest address  jna   Forwards_SSE2_10    // If no overlap, use forward move  jmp   Backwards_SSE2_10   // If overlap, use backward move @@Done: end;  opinions? does this make sense to you? can we take the winners of fastcode 32bit and convert them in 64bit so easily? chatgpt then owns the copyright? Share this post Link to post
DelphiUdIT 218 Posted November 25, 2024 For something to be patentable it must have a creative and innovative character. I don't think that a few lines of assembler can be considered as such. Share this post Link to post
Brian Evans 112 Posted November 25, 2024 (edited) Note it is a 64-bit version of a 32-bit move function not a 64-bit move function.  A 64-bit move function would have Count as: NativeInt and other changes to allow moves over the limits of a 32-bit integer. Edited November 25, 2024 by Brian Evans Share this post Link to post
Stefan Glienke 2083 Posted November 25, 2024 (edited) Converting source code that won any challenge over 15 years ago is questionable regardless of correctness. Â Anyway, for this particular example, implementing a faster System.Move for Windows (other platforms use their libc memory) has been solved since Delphi 11.3. Â I sincerely challenge everyone to come up with a faster/better implementation. Edited November 25, 2024 by Stefan Glienke 2 Share this post Link to post
RDP1974 40 Posted November 25, 2024 indeed the quality of the system rtl of D12 is outstanding Share this post Link to post