Hello everyone,

I was surprised that Delphi 7 generate following asmbler code for this
pascal code. I have turned on Code generation/Optimization.

  fMyRecord.fLength := 0;
  fMyRecord.fCount := 0;
  fMyRecord.fReadOnly := False;

xor edx, edx
mov [eax+$2fc], edx

xor edx, edx
mov [eax+$300], edx

mov byte ptr [eax+$304], $0

I think the optimized asm code will look like this.

xor edx, edx
mov [eax+$2fc], edx
mov [eax+$300], edx
mov [eax+$304], edx

I tested the hand written asm code, it is 5 cpu clock cycle faster. I hate
to put asm in my source code. So the question is how to write delphi code to
generate optimize asm code like this one.

I know this slow down may not sound that much, just for research purpose.

I have enclosed delphi sample code for your reference. I look forward to
hearing from you.

TIA

Best Regards
Leigh

Attachment: Project1.dpr
Description: Binary data

Attachment: Project1.dsk
Description: Binary data

Attachment: Project1.dof
Description: Binary data

Attachment: Project1.cfg
Description: Binary data

Attachment: Project1.res
Description: Binary data

Attachment: Unit1.dfm
Description: Binary data

Attachment: Unit1.pas
Description: Binary data

Reply via email to