summaryrefslogtreecommitdiff
path: root/rtl/m68k
diff options
context:
space:
mode:
authorkaroly <karoly@3ad0048d-3df7-0310-abae-a5850022a9f2>2017-12-26 18:05:34 +0000
committerkaroly <karoly@3ad0048d-3df7-0310-abae-a5850022a9f2>2017-12-26 18:05:34 +0000
commite3bbf08162ca4964e23ea6534f764036ce33f8ac (patch)
tree4a97bc9e70f721c2e925f1c7dd73e50c9676d25f /rtl/m68k
parent3c52a9f99a2bb6c27c5f08ab068ded7073cb444d (diff)
downloadfpc-e3bbf08162ca4964e23ea6534f764036ce33f8ac.tar.gz
m68k: apparently, the right place for the sar qword helper is still in the CPU include, not the 64bit helper include. this fixes linux m68k build.
git-svn-id: https://svn.freepascal.org/svn/fpc/trunk@37820 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'rtl/m68k')
-rw-r--r--rtl/m68k/m68k.inc85
1 files changed, 85 insertions, 0 deletions
diff --git a/rtl/m68k/m68k.inc b/rtl/m68k/m68k.inc
index 27f4d5757e..c4676b0a4a 100644
--- a/rtl/m68k/m68k.inc
+++ b/rtl/m68k/m68k.inc
@@ -575,6 +575,91 @@ begin
end;
{$endif}
+{$ifndef FPC_SYSTEM_HAS_SAR_QWORD}
+{$define FPC_SYSTEM_HAS_SAR_QWORD}
+function fpc_SarInt64(Const AValue : Int64;const Shift : Byte): Int64; [Public,Alias:'FPC_SARINT64']; compilerproc; assembler; nostackframe;
+asm
+ // d0 = shift
+ lea.l 4(sp),a0
+ move.l d2,-(sp)
+ move.l d0,d2
+{$ifndef CPUCOLDFIRE}
+ and.w #63,d2
+ cmp.w #32,d2
+{$else}
+ and.l #63,d2
+ cmp.l #32,d2
+{$endif}
+ bge.s @longshift
+
+ move.l (a0)+,d0
+ move.l (a0),d1
+
+{$ifdef CPUM68K_HAS_ROLROR}
+ cmp.w #1,d2
+ beq.s @oneshift
+{$endif}
+{$ifdef CPU68000}
+ cmp.w #16,d2
+ beq.s @sixteenshift
+{$endif}
+
+ move.l d3,a0
+ move.l d4,a1
+
+ move.l d0,d3
+ moveq.l #32,d4
+{$ifndef CPUCOLDFIRE}
+ sub.w d2,d4
+{$else}
+ sub.l d2,d4
+{$endif}
+ asr.l d2,d0
+ lsl.l d4,d3
+ lsr.l d2,d1
+ or.l d3,d1
+
+ move.l a0,d3
+ move.l a1,d4
+
+ bra.s @quit
+
+{$ifdef CPU68000}
+@sixteenshift:
+ move.w d0,d1
+ swap d1
+ swap d0
+ ext.l d0
+
+ bra.s @quit
+{$endif}
+
+{$ifdef CPUM68K_HAS_ROLROR}
+@oneshift:
+ asr.l #1,d0
+ roxr.l #1,d1
+
+ bra.s @quit
+{$endif}
+
+@longshift:
+ move.l (a0),d0
+ move.l d0,d1
+ smi d0
+{$if defined(CPU68020) or defined(CPUCOLDFIRE)}
+ extb.l d0
+{$else}
+ ext.w d0
+ ext.l d0
+{$endif}
+ sub.w #32,d2
+ asr.l d2,d1
+
+@quit:
+ move.l (sp)+,d2
+end;
+{$endif}
+
{$if defined(CPUM68K_HAS_BYTEREV) or defined(CPUM68K_HAS_ROLROR)}
{ Disabled for now, because not all cases below were tested. (KB) }
{.$define FPC_SYSTEM_HAS_SWAPENDIAN}