[Lazarus] AGG missing 3 asm conversions to work on 64-bit CPU's

Graeme Geldenhuys graemeg.lists at gmail.com
Fri Mar 9 08:46:35 CET 2012


Hi,

Can anybody with Assembly knowledge help convert 3 methods in AggPas
(<lcl>/components/aggpas/src) so that it could work under x86_64
systems?

The three methods are shr_int6(), shr_int16() and shr_int32() defined
inside the agg_basics.pas unit.

For example, here is a one method that is often called, but because
there is no 64-bit x86_64 implementation, the agg output is not
correct (compared to the 32-bit version of my program).


function shr_int32;
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 }

end;


I know FPC has built-in 'shr' functionality, but it seems Agg needs a
specific implementation to be compatible with the C compilers. As
noted by the code comment in the agg_basic.pas unit.


// 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.



Any help would be very much appreciated, thanks.


-- 
Regards,
  - Graeme -


_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://fpgui.sourceforge.net




More information about the Lazarus mailing list