Sorry, there is an error in my previous post.

----------------------------------------------------------------------------
---------------------
Another is put both code in the source with a different function name.
i.e.

function _BeforeDestruction_pascal(Instance: TObject; OuterMost: ShortInt):
TObject;
begin
  Result := Instance;
  if OuterMost > 0 then Exit;
  Instance.BeforeDestruction;
end;

function _BeforeDestruction(Instance: TObject; OuterMost: ShortInt):
TObject;
asm
       { ->  EAX  = pointer to instance }
       {      DL  = dealloc flag        }

        TEST    DL,DL
        JG      @@outerMost
        RET
@@outerMost:
        PUSH    EAX
        PUSH    EDX
        MOV     EDX,[EAX]
        CALL    DWORD PTR [EDX] + VMTOFFSET TObject.BeforeDestruction
        POP     EDX
        POP     EAX
end;


Regards
Leigh


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Behalf Of Leigh Wanstead
Sent: Thursday, October 02, 2003 10:26 AM
To: Multiple recipients of list delphi
Subject: [DUG]: What is the best way to maintain assembler code with
Delphi code?


Hello everyone,

I have wrote some code which require faster speed which I select to write in
inline assembler code. I want the speed, but I don't have good memory, so I
would rather have pascal code to help me recall the logic, also enjoy the
benefit for upgrading to a different CPU by simply switching to pascal code.
Who knows what will happen next year.

I have read some code in system.pas. It seems that Borland select to use
condition define PUREPASCAL to maintain Delphi code with equivalant inline
assembler code.

I also thought there are two other methods.
---------------------------------------------------------------------
One is put pascal code in comments
i.e.

function _BeforeDestruction(Instance: TObject; OuterMost: ShortInt):
TObject;
{
// Must preserve DL on return!
begin
  Result := Instance;
  if OuterMost > 0 then Exit;
  Instance.BeforeDestruction;
end;
}
asm
       { ->  EAX  = pointer to instance }
       {      DL  = dealloc flag        }

        TEST    DL,DL
        JG      @@outerMost
        RET
@@outerMost:
        PUSH    EAX
        PUSH    EDX
        MOV     EDX,[EAX]
        CALL    DWORD PTR [EDX] + VMTOFFSET TObject.BeforeDestruction
        POP     EDX
        POP     EAX
end;

----------------------------------------------------------------------------
---------------------
Another is put both code in the source with a different function name.
i.e.

function _BeforeDestruction(Instance: TObject; OuterMost: ShortInt):
TObject;
begin
  Result := Instance;
  if OuterMost > 0 then Exit;
  Instance.BeforeDestruction;
end;

function _BeforeDestruction_pascal(Instance: TObject; OuterMost: ShortInt):
TObject;
asm
       { ->  EAX  = pointer to instance }
       {      DL  = dealloc flag        }

        TEST    DL,DL
        JG      @@outerMost
        RET
@@outerMost:
        PUSH    EAX
        PUSH    EDX
        MOV     EDX,[EAX]
        CALL    DWORD PTR [EDX] + VMTOFFSET TObject.BeforeDestruction
        POP     EDX
        POP     EAX
end;

I like all the source code to be compiled, but don't put useless code into
executeable. But Borland way, means that I have to maintain two project
files and put in a project group to let them compile at once. It seems that
memory not release after finish compiling one project still exist in Delphi
7 and Kylix 3. So that option reqired me to do a full rebuild, then have to
shutdown Delphi and restart, in Kylix case worse, I have to restart Linux to
get fresh clean.

I look forward to hearing from you.
TIA

Regards
Leigh


---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED]
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/


---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/

Reply via email to