Sign in Join

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

Mailing lists / fpc-pascal / 2005-03

Re: intel asm and fpc-1.9.8

3 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

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

Jonas Maebe
to Jan Je/lowicki: I have dozens of blas-like assembler procedures. They have been written about 10 years…
Jan Je/lowicki wrote
Today I tried new fpc 1.9.8. Output generated from fpc 1.9.8 code seems errorenous. The isolated example given below tries to fill an array of float with contstant value. Gdb (5.3) gives no reasonable support, although for 1.0.10 code it does.

The default calling convention changed to register parameters in 1.9.8. Add {$calling fpccall} at the top of your source to revert to the slower stack-based parameter passing.

Jonas

Jan Je/lowicki

Hello,

I have dozens of blas-like assembler procedures. They have been written about 10 years ago and I still use them in both virtualpascal and free pascal programs.

Today I tried new fpc 1.9.8. Output generated from fpc 1.9.8 code seems errorenous. The isolated example given below tries to fill an array of float with contstant value. Gdb (5.3) gives no reasonable support, although for 1.0.10 code it does.

program atest;
type  dvector = array[1..10] of double;
const  dflsize = sizeof(double);
var   x: dvector;   i: integer;   a: double;
  {$ifdef VirtualPascal}
  {$SAVES EBX,ESI,EDI} {$USES EAX,ECX,EDX}  {$endif}
  procedure vecfill(const dim0,dim1: integer;
                    var r: dVector; c: extended); assembler;
  asm
    MOV     EAX,dim1;
    SUB     EAX,dim0;
    MOV     EDX,dflsize
    MUL     EDX
    FLD     TByte ptr [c]
    push    eax
    mov     eax,dim0
    dec     eax
    mov     edx,dflsize
    mul     edx
    MOV     EDX, r
    ADD     EDX,EAX
    pop     eax
    JMP     @@2
  @@1:
    FST     QWord ptr [EDX + EAX]
    SUB     EAX,dflsize
  @@2:
    CMP     EAX,0
    JGE     @@1
    FSTP    ST(0)
  end; {asmvecfill}
begin
  a := 123.45;
  fillchar(x, sizeof(x),0);
  vecfill(2, 5, x, a);
  for i := 1 to 6 do
    writeln(x[i]);
end.

Here is output by fpc 1.9.8:

0.000000000000000E+000
0.000000000000000E+000
0.000000000000000E+000
0.000000000000000E+000

(or access violation when arrays allocated dynamically). Output by fpc 1.0.10 and vp 2.1 which is one I expect:

1.234500000000000E+002
1.234500000000000E+002
1.234500000000000E+002
1.234500000000000E+002

Any ideas?

Jan Jelowicki

------------------------------------------------------------------- Wroclaw University of Agriculture Akademia Rolnicza we Wroclawiu Department of Mathematics Katedra Matematyki -------------------------------------------------------------------

Jan Je/lowicki
Show quoted text 18 lines
From: Jonas Maebe Subject: Re: [fpc-pascal] intel asm and fpc-1.9.8 Date sent: Wed, 9 Mar 2005 17:59:45 +0100 To: FPC-Pascal users discussions Send reply to: FPC-Pascal users discussions On 9 mrt 2005, at 17:13, Jan Je/lowicki wrote: > Today I tried new fpc 1.9.8. Output generated from fpc 1.9.8 code > seems errorenous. The isolated example given below tries to fill an > array of float with contstant value. Gdb (5.3) gives no reasonable > support, although for 1.0.10 code it does. The default calling convention changed to register parameters in 1.9.8. Add {$calling fpccall} at the top of your source to revert to the slower stack-based parameter passing.

Thank you, that was the case. Suggested by your answer, I have found an interesting discusssion in fpc-devel archives. ($calling fpccall should be relalced by oldfpccall, I guess.)

Keeping stack-based convention is slower, but this has minor meaning for me, as I save much more time by putting inner loops into registers (thousands operations per typical call) than I waste using stack frame (one time per call). However, the first operation to be done is to load addresses from stack to registers and I think that should be avoided using new convention.

with regards

Jan Jelowicki

------------------------------------------------------------------- Wroclaw University of Agriculture Akademia Rolnicza we Wroclawiu Department of Mathematics Katedra Matematyki -------------------------------------------------------------------