summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGraeme Geldenhuys <graeme@mastermaths.co.za>2012-03-09 13:06:26 +0200
committerGraeme Geldenhuys <graeme@mastermaths.co.za>2012-03-09 16:28:49 +0200
commitbbc8993846266309601f4a6a5aaaf3555955297f (patch)
treeb32c0872cbdd0f1f667db67f53eefde96730ea60 /src
parent36f3b56c2ec69f607dee2a6e96c343a0e42791d2 (diff)
downloadfpGUI-bbc8993846266309601f4a6a5aaaf3555955297f.tar.xz
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.
Diffstat (limited to 'src')
-rw-r--r--src/corelib/render/software/agg_basics.pas90
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 4240f417..bda237cb 100644
--- a/src/corelib/render/software/agg_basics.pas
+++ b/src/corelib/render/software/agg_basics.pas
@@ -364,11 +364,9 @@ type
// 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 @@ begin
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.