From 0b0ed3f0f2c235dcd082940a059628495ea4a5db Mon Sep 17 00:00:00 2001 From: florian Date: Mon, 17 Apr 2006 17:17:29 +0000 Subject: [PATCH] * fixed some calling conventions in assembler routines for win64 git-svn-id: trunk@3250 - --- rtl/x86_64/strings.inc | 28 ++++++++++++++++++++++++++++ rtl/x86_64/strlen.inc | 5 +++++ 2 files changed, 33 insertions(+) diff --git a/rtl/x86_64/strings.inc b/rtl/x86_64/strings.inc index 3452f46156..a90ea221ec 100644 --- a/rtl/x86_64/strings.inc +++ b/rtl/x86_64/strings.inc @@ -18,7 +18,17 @@ {$define FPC_UNIT_HAS_STRCOPY} { Created from glibc: libc/sysdeps/x86_64/strcpy.S Version 1.2 } function strcopy(dest,source : pchar) : pchar;assembler; +{$ifdef win64} +var + rdi,rsi : int64; +{$endif win64} asm +{$ifdef win64} + movq %rsi,rsi + movq %rdi,rdi + movq %rdx, %rsi + movq %rcx, %rdi +{$endif win64} movq %rsi, %rcx { Source register. } andl $7, %ecx { mask alignment bits } movq %rdi, %rdx { Duplicate destination pointer. } @@ -139,13 +149,27 @@ asm .LFPC_STRCOPY_4: movq %rdi, %rax { Source is return value. } +{$ifdef win64} + movq rsi,%rsi + movq rdi,%rdi +{$endif win64} end; {$define FPC_UNIT_HAS_STRCOMP} { Created from glibc: libc/sysdeps/x86_64/strcmp.S Version 1.2 } function StrComp(Str1, Str2: PChar): SizeInt;assembler; +{$ifdef win64} +var + rdi,rsi : int64; +{$endif win64} asm +{$ifdef win64} + movq %rsi,rsi + movq %rdi,rdi + movq %rdx, %rsi + movq %rcx, %rdi +{$endif win64} .LFPC_STRCMP_LOOP: movb (%rdi), %al cmpb (%rsi), %al @@ -163,5 +187,9 @@ asm movq $-1, %rcx cmovbq %rcx, %rax .Lexit: +{$ifdef win64} + movq rsi,%rsi + movq rdi,%rdi +{$endif win64} end; diff --git a/rtl/x86_64/strlen.inc b/rtl/x86_64/strlen.inc index 6009b5cf16..dc9d1db919 100644 --- a/rtl/x86_64/strlen.inc +++ b/rtl/x86_64/strlen.inc @@ -16,7 +16,12 @@ Implemented using the code from glibc: libc/sysdeps/x86_64/strlen.S Version 1.2 } asm + { win64 has different calling conventions } +{$ifdef win64} + movq %rcx, %rdi { Duplicate source pointer. } +{$else win64} movq %rdi, %rcx { Duplicate source pointer. } +{$endif win64} andl $7, %ecx { mask alignment bits } movq %rdi, %rax { duplicate destination. } jz .LFPC_STRLEN_1 { aligned => start loop }