mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-06-03 13:18:35 +02:00

usage in case PIC generation is on (some by adding PIC-versions of the assembler code, most by adding -Cg- to the options to be used). Note: the Intel assembler reader does not yet support the Delphi PIC construct, so tests with that (like test/tasmread and test/tcg1) do not work with -Cg on non-Darwin (Darwin needs a different PIC construct) git-svn-id: trunk@9370 -
79 lines
1.7 KiB
ObjectPascal
79 lines
1.7 KiB
ObjectPascal
{ %cpu=i386 }
|
|
{ %OPT=-Cg- }
|
|
{ Source provided for Free Pascal Bug Report 4240 }
|
|
{ Submitted by "Den Jean" on 2005-07-30 }
|
|
{ e-mail: Den.Jean@telenet.be }
|
|
program TestPointArray;
|
|
{$H+}
|
|
{$asmmode intel}
|
|
{$mode delphi}
|
|
|
|
uses
|
|
Classes, SysUtils, Types;
|
|
|
|
type
|
|
PPointArray = ^TPointArray;
|
|
TPointArray = array of TPoint;
|
|
|
|
var
|
|
Points : TPointArray;
|
|
p : PPointArray;
|
|
i : integer;
|
|
|
|
|
|
function GetPointsLength1 (PA: pointer): Integer; cdecl;
|
|
begin
|
|
asm
|
|
mov EAX,[EBP+$08]
|
|
mov i,eax
|
|
end;
|
|
writeln('Within GetPointsLength using Pointer argument:');
|
|
|
|
writeln(Format('--- Address on Stack:$%p',[Pointer(i)]));
|
|
if i <> integer (p)
|
|
then writeln (' * Wrong Address passed on stack');
|
|
|
|
writeln(Format('--- Address using Parameter:$%p',[PA]));
|
|
if integer(PA) <> integer (p)
|
|
then writeln (' * Parameter addresss different from given variable');
|
|
|
|
Result:=Length(TPointArray(PA));
|
|
writeln('--- Array Length:',Result);
|
|
end;
|
|
|
|
{$IFDEF FPC}
|
|
{$asmmode intel}
|
|
{$ENDIF}
|
|
|
|
function GetPointsLength2 (const PA: TPointArray): Integer; cdecl;
|
|
begin
|
|
asm
|
|
mov EAX,[EBP+$08]
|
|
mov i,eax
|
|
end;
|
|
writeln('Within GetPointsLength using const TPointArray argument:');
|
|
|
|
writeln(Format('--- Address on Stack:$%p',[Pointer(i)]));
|
|
if i <> integer (p)
|
|
then writeln (' * Wrong Address passed on stack');
|
|
|
|
writeln(Format('--- Address using Parameter:$%p',[pointer(PA)]));
|
|
if integer(PA) <> integer (p)
|
|
then writeln (' * Parameter addresss different from given variable');
|
|
|
|
Result:=Length(PA);
|
|
writeln('--- Array Length:',Result);
|
|
end;
|
|
|
|
|
|
begin
|
|
SetLength (Points, 3);
|
|
Points [0] := Point (1,2);
|
|
Points [1] := Point (3,4);
|
|
Points [2] := Point (5,6);
|
|
p:=@Points[0];
|
|
writeln(Format('Address of TPointArray:$%p',[p]));
|
|
getPointsLength1(Points);
|
|
getPointsLength2(Points);
|
|
end.
|