Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2005-07

passing a double parameter on arm

3 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Den Jean

Hi,

There seems to be an ARM ABI bug with passing doubles on arm.

When I call a C-procedure of a library using a c-program, it works.

When I call the C-procedure using a fpc ARM program it doesn't work.

Here is an example:

definition of the c-procedure to call
void QLCDNumber_display2(QLCDNumberH handle, double num);
use of the c-procedure in a c-program that works fine:
QLCDNumber_display2(lcd,142.3);
use of the c-procedure in a pascal program (does not work)
procedure QLCDNumber_display(handle: QLCDNumberH; num: Double); cdecl; overload;  external QtShareName name 'QLCDNumber_display2';
QLCDNumber_Display(lcd,142.3);
but this trick works:
procedure QLCDNumber_display_trick(handle: QLCDNumberH; hinum,lonum:integer); cdecl; overload;  external QtShareName name 'QLCDNumber_display2';
type
  TDoubleRec = record
    Hi : integer;
    Lo : integer;
  end;
  PDoubleRec = ^TDoubleRec;
.....
var
  d : double;
  p : PDoubleRec;
......
d:=142.3;
p:=PDoubleRec(@d);
QLCDNumber_Display_trick(l,p^.hi,p^.lo);

I used :
Free Pascal Compiler version 2.0.1 [2005/07/21] for arm

kind regards,

Den Jean

Florian Klaempfl
to Den Jean
Den Jean wrote 5 lines
Hi, There seems to be an ARM ABI bug with passing doubles on arm. When I call a C-procedure of a library using a c-program, it works.

Tried to fix it in 2.1.1 (untested).

Den Jean
to Florian Klaempfl
Florian Klaempfl wrote
Tried to fix it in 2.1.1 (untested).

I tested it and it works now,
Big thank you.
I used svn revision 728

...................................
Free Pascal Compiler version 2.1.1 [2005/07/23] for arm Copyright (c) 1993-2005 by Florian Klaempfl
/usr/lib/fpc/2.1.1/ppcarm [options] <inputfile> [options] ..................................