[fpc-devel] generated assembler

Graeme Geldenhuys graemeg.lists at gmail.com
Wed Sep 3 12:04:23 CEST 2008


On 9/3/08, Martin Schreiber <fpmse at bluewin.ch> wrote:
>
> You could use breakpoints and the (dis-)assembler window of MSEide, it lists
>  mixed pascal and machine code.

Thanks Martin, I'll take a look.

What I'm trying to find out (with my rusty assembler knowledge) is if
a lot of IFDEF's around procedure calls, compared to only one IFDEF
inside a procedure would make a difference in performance and the code
generated.

I would prefer example 2 (it looks cleaner and would be less work),
and from my quick/crude analysis, it seems both options generate
pretty much the same code if the gDEBUG define is disabled (does NOT
exist).


Example #1...

  procedure Log(AParam1: string);
  begin
    writeln('LOG: ' + AParam1);
  end;

var
  i, j: integer;
  s: string;
begin
  {$IFDEF gDEBUG} Log('Starting...'); {$ENDIF}
  s := '%d + %d = %d';
  i := 5;
  j := 2;
  {$IFDEF gDEBUG} Log('calculating result'); {$ENDIF}
  {$IFDEF gDEBUG} Log(Format(s, [i, j, i+j])); {$ENDIF}
  {$IFDEF gDEBUG} Log('Done.'); {$ENDIF}
end.



versus Example #2...


  procedure Log(AParam1: string);
  begin
    {$IFDEF gDEBUG}
    writeln('LOG: ' + AParam1);
    {$ENDIF}
  end;

var
  i, j: integer;
  s: string;
begin
  Log('Starting...');
  s := '%d + %d = %d';
  i := 5;
  j := 2;
  Log('calculating result');
  Log(Format(s, [i, j, i+j]));
  Log('Done.');
end.



Regards,
  - Graeme -


_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/



More information about the fpc-devel mailing list