[fpc-pascal] intel asm and fpc-1.9.8
Jan Je/lowicki
Jasj at OZI.AR.WROC.PL
Wed Mar 9 17:13:04 CET 2005
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
jasj at ozi.ar.wroc.pl
-------------------------------------------------------------------
Wroclaw University of Agriculture Akademia Rolnicza we Wroclawiu
Department of Mathematics Katedra Matematyki
-------------------------------------------------------------------
More information about the fpc-pascal
mailing list