[fpc-pascal] FPC on ARM (eg Zaurus)

Den Jean geeken at pandora.be
Wed Nov 24 06:54:43 CET 2004


On Tuesday 23 November 2004 11:13 am, Florian Klaempfl wrote:

> This is indeed an improper implemntation of the arm abi, I'll fix it 
> asap. 

Thanks a lot. In the mean time I changed the binding so that it uses
LargeInt instead of TMethod. So the big demo program almosts works :-)

---------------------------------------------------------------------------------------------------
QHookH = LargeInt; // was TMethod before
procedure QButton_hook_hook_clicked(handle: QButton_hookH; hook: QHookH); cdecl;

procedure TQButton.Hook_clicked(Proc: QButton_clicked_Event);
begin
  QButton_hook_Hook_clicked(Hooks,LargeInt(TMethod(Proc)));  // Proc gets passed by value :-)
end;//                                               ^^^^^^^^^^^^^^^
---------------------------------------------------------------------------------------------------


I am struggling now with (or having fun with, depending on the view point)
 
 * Trigonometric functions. 
        So temporarily I am using series like sin x = x- x^3/3! ....
        Is this related to the fact that there is no Math processor on the Zaurus ? 
        "dmesg" reveals that there is a Netwinder Floating Point Emulator.
        I haven't looked into the details yet. (which values crash what functions, I use cos/sin and arctan2). 
        I'll do so asap.

 * dynamic arrays : TIntArray = array of integer.
    On Intel it works fine but on arm not.
    Bindhelp.pas provides TIntArray pascal helper functions to the binding that is written in C++

    eg. this C-code copies integers from the Qt Int Array to the Pascal dynamic Array of integer

---------------------------------------------------------------------------------------------------
    inline void copyQIntsToPInts(const QValueList<int> &qi, PIntArray pi)
  {
    int len = qi.count();
    int *ints;
    setIntsLength(pi, len); // this is call to a pascal SetIntsLength function
    ints = (int *)getIntsPtr(pi);  // this is a call to a pascal GetIntsPtr function
    for (int i = 0; i < len; i++)
      ints[i] = qi[i]; // here it crashes
  }
----------------------------------------------------------------------------------------------------

    I crashes when it uses the address returned by getintsptr
    GetIntsPtr is provided by bindhelp.pas:
----------------------------------------------------------------------------------------------------
  // Int array helpers
  function GetIntsPtr(const PA: TIntArray): Pointer; cdecl; export;
  begin
    Result := @PA[0];
  end;
----------------------------------------------------------------------------------------------------

It works on intel and not on arm. 
But when I change the definition of GetIntsPtr to:

----------------------------------------------------------------------------------------------------
  function GetIntsPtr(var PA: TIntArray): Pointer; cdecl; export;
  begin
    Result := @PA[0];
  end;
----------------------------------------------------------------------------------------------------

Then it works on the arm to. (changed const to var !)

By the way the definition of the pascal library function in the C++ library is:
----------------------------------------------------------------------------------------------------
  typedef void *PIntArray;
  typedef void *(*GetIntsPtr)(PIntArray pi);
  extern GetIntsPtr getIntsPtr;
----------------------------------------------------------------------------------------------------

*  I am using the last arm snapshot you provided because the current cvs version does not compile

                               
> BTW: What OS do you run on your Zaurus? I've a lot of trouble with  
> OZ 3.5.1 e.g. with that ridiculous dropbear ssh demon used by OZ 3.5.1

I have a Zaurus SL6000. As it is rather new, an upgrade was not a priority yet.
I haven't seen update roms for the SL6000 either.
The SL6000 has a libqte.so.2.3.2 and a libqpe.so.1.5.0


kind regards, 

Jan




More information about the fpc-pascal mailing list