On 9 March 2012 16:12, Mattias Gaertner  wrote:
>
> Should these changes be applied to the lazarus aggpas?


Yes.  Attached is the patch for this thread's mentioned problem - no
x86_64 bit shifting implementation.


 I'm working further on AggPas and fixed some other things too. I'll
supply a few more patches as I go.


-- 
Regards,
  - Graeme -


_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://fpgui.sourceforge.net
From bbc8993846266309601f4a6a5aaaf3555955297f Mon Sep 17 00:00:00 2001
From: Graeme Geldenhuys <[email protected]>
Date: Fri, 9 Mar 2012 13:06:26 +0200
Subject: [PATCH 1/3] Removed ASM code from agg_basic.pas and replaced it with FPC build-in functions.

The problem was that x86_64 was not implemented, and ASM code
is definately not portable. Luckily, FPC's has built-in Sar*()
functions we could use.
---
 src/corelib/render/software/agg_basics.pas |   90 +++------------------------
 1 files changed, 10 insertions(+), 80 deletions(-)

diff --git a/src/corelib/render/software/agg_basics.pas b/src/corelib/render/software/agg_basics.pas
index 4240f41..bda237c 100644
--- a/src/corelib/render/software/agg_basics.pas
+++ b/src/corelib/render/software/agg_basics.pas
@@ -364,11 +364,9 @@  point_type = record
 // to be.
  procedure NoP;
 
-// SHR for signed integers is differently implemented in pascal compilers
-// than in c++ compilers. On the assembler level, c++ is using the SAR and
-// pascal is using SHR. That gives completely different result, when the
-// number is negative. We have to be compatible with c++ implementation,
-// thus instead of directly using SHR we emulate c++ solution.
+{ These implementations have changed to use FPC's Sar*() functions, so should
+  now support all platforms with ASM code. At a later date these functions
+  could be removed completely. }
  function  shr_int8 (i ,shift : int8 ) : int8;
  function  shr_int16(i ,shift : int16 ) : int16;
  function  shr_int32(i ,shift : int ) : int;
@@ -1590,90 +1588,22 @@ procedure NoP;
 end;
 
 { SHR_INT8 }
-function shr_int8;
+function shr_int8(i ,shift : int8 ) : int8;
 begin
-{$IFDEF AGG_CPU_386 }
- asm
-  mov al ,byte ptr [i ]
-  mov cl ,byte ptr [shift ]
-  sar al ,cl
-  mov byte ptr [result ] ,al
-
- end;
-
-{$ENDIF }
-
-{$IFDEF AGG_CPU_PPC }
- asm
-  lbz   r2,i
-  extsb r2,r2
-  lbz   r3,shift
-  extsb r3,r3
-  sraw  r2,r2,r3
-  extsb r2,r2
-  stb   r2,result
-	
- end;
-
-{$ENDIF }
-
+  Result := SarShortint(i, shift);
 end;
 
 { SHR_INT16 }
-function shr_int16;
+function shr_int16(i ,shift : int16 ) : int16;
 begin
-{$IFDEF AGG_CPU_386 }
- asm
-  mov ax ,word ptr [i ]
-  mov cx ,word ptr [shift ]
-  sar ax ,cl
-  mov word ptr [result ] ,ax
-
- end;
-
-{$ENDIF }
-
-{$IFDEF AGG_CPU_PPC }
- asm
-  lha   r2,i
-  lha   r3,shift
-  sraw  r2,r2,r3
-  extsh r2,r2
-  sth   r2,result
-
- end;
-
-{$ENDIF }
-
+  Result := SarSmallint(i, shift);
 end;
 
 { SHR_INT32 }
-function shr_int32;
+function shr_int32(i, shift: int): int;
 begin
-{$IFDEF AGG_CPU_386 }
- asm
-  mov eax ,dword ptr [i ]
-  mov ecx ,dword ptr [shift ]
-  sar eax ,cl
-  mov dword ptr [result ] ,eax
-
- end;
-
-{$ENDIF }
-
-{$IFDEF AGG_CPU_PPC }
- asm
-  lwz  r3,i
-  lwz  r2,shift
-  sraw r3,r3,r2
-  stw  r3,result
-
- end;
-
-{$ENDIF }
-
+  Result := SarLongint(i, shift);
 end;
 
-END.
-
+end.
 
-- 
1.7.0.4

--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to