Delphi definetly does something special:
Project1.dpr.95: vLarge := ExamineLargeReturnValue;
004091A5 8BC4 mov eax,esp
004091A7 E880FFFFFF call ExamineLargeReturnValue
Project1.dpr.96: for vIndex := 0 to 31 do
004091AC BE20000000 mov esi,$00000020
004091B1 8BDC mov ebx,esp
Project1.dpr.98: writeln( vLarge.mByte[vIndex] );
004091B3 0FB613 movzx edx,[ebx]
004091B6 8BC7 mov eax,edi
004091B8 E87BA5FFFF call @[EMAIL PROTECTED]
E8AEA5FFFF call @[EMAIL PROTECTED]
E8159CFFFF call @[EMAIL PROTECTED]
functions it seems to be efficient, this is misleading though.
I am pretty sure for properties it does something different and
inefficient
yet again ;)
At least last time I used a property for a large type it was hellish slow
;)
Or maybe the assignments caused it, someday I will investigate but not
today
:P*
// *** Begin of Code ***
program Project1;
{$APPTYPE CONSOLE}
{
Test Delphi's calling convention
version 0.01 created on 2 may 2008 by Skybuck Flying.
According to Wikipedia:
Evaluating arguments from left to right,
it p***** three arguments via EAX, EDX, ECX.
Remaining arguments are pushed onto the stack, also left to right.
It's the default calling convention of Borland Delphi.
What it doesn't say is how arguments are returned...
Well for now assume eax... but what if the arguments are bigger than a
longword ;)
What happens when bytes are in the parameters will 4 bytes on the stack
be used or just 1 ?
Let's find out ! ;)
}
uses
SysUtils;
function ExamineLongwordParameters
(
Para1 : longword;
Para2 : longword;
Para3 : longword;
Para4 : longword;
Para5 : longword;
Para6 : longword;
Para7 : longword;
Para8 : longword
) : boolean;
begin
writeln( IntToHex(Para1,4) );
writeln( Para2 );
writeln( Para3 );
writeln( Para4 );
writeln( Para5 );
writeln( Para6 );
writeln( Para7 );
writeln( Para8 );
result := true;
end;
type
Tlarge = packed record
mByte : packed array[0..31] of byte;
end;
function ExamineLargeReturnValue : Tlarge;
var
vIndex : integer;
begin
for vIndex := 0 to 31 do
begin
result.mByte[vIndex] := vIndex;
end;
end;
procedure Main;
var
vIndex : integer;
vLarge : Tlarge;
begin
writeln('program started');
if ExamineLongwordParameters
(
$AABBCCAA, // eax
$AABBCCBB, // edx
$AABBCCCC, // ecx
$AABBCCDD, // stack
$AABBCCEE, // stack
$AABBCCFF, // stack
$AABBCC00, // stack
$AABBCC11 // stack
) then
begin
writeln('true');
end;
vLarge := ExamineLargeReturnValue;
for vIndex := 0 to 31 do
begin
writeln( vLarge.mByte[vIndex] );
end;
writeln('program finished');
end;
begin
try
Main;
except
on E:Exception do
Writeln(E.Classname, ': ', E.Message);
end;
readln;
end.
// *** End of Code ***
Bye,
Skybuck.


|