[fpc-devel] Generated code of constant parameters of double type

Luiz Americo Pereira Camara luizmed at oi.com.br
Sun Nov 16 14:33:15 CET 2008


While discussing if is worth using const parameters for string and 
double types in a Lazarus bug report ( 
http://bugs.freepascal.org/view.php?id=12642 ), it was noticed that does 
not make difference using constant parameters or not for double types.

So is this the expected behavior or a bug in fpc?

Bellow is the generated code (fpc222) and the test program.

Luiz

.section .text.n_p$asmconstparameter_byvalue$double
    .balign 16,0x90
.globl    P$ASMCONSTPARAMETER_BYVALUE$DOUBLE
P$ASMCONSTPARAMETER_BYVALUE$DOUBLE:
# Temps allocated between ebp-8 and ebp-8
# [17] begin
    pushl    %ebp
    movl    %esp,%ebp
    subl    $8,%esp
# Var V located at ebp+8
# Var i located at ebp-8
# [18] i := V;
    movl    8(%ebp),%eax
    movl    %eax,-8(%ebp)
    movl    12(%ebp),%eax
    movl    %eax,-4(%ebp)
# [19] DoIt(i);
    subl    $8,%esp
    movl    -8(%ebp),%eax
    movl    %eax,(%esp)
    movl    -4(%ebp),%eax
    movl    %eax,4(%esp)
    call    P$ASMCONSTPARAMETER_DOIT$DOUBLE
# [20] end;
    leave
    ret    $8

.section .text.n_p$asmconstparameter_byreference$double
    .balign 16,0x90
.globl    P$ASMCONSTPARAMETER_BYREFERENCE$DOUBLE
P$ASMCONSTPARAMETER_BYREFERENCE$DOUBLE:
# Temps allocated between ebp-8 and ebp-8
# [25] begin
    pushl    %ebp
    movl    %esp,%ebp
    subl    $8,%esp
# Var V located at ebp+8
# Var i located at ebp-8
# [26] i := V;
    movl    8(%ebp),%eax
    movl    %eax,-8(%ebp)
    movl    12(%ebp),%eax
    movl    %eax,-4(%ebp)
# [27] DoIt(i);
    subl    $8,%esp
    movl    -8(%ebp),%eax
    movl    %eax,(%esp)
    movl    -4(%ebp),%eax
    movl    %eax,4(%esp)
    call    P$ASMCONSTPARAMETER_DOIT$DOUBLE
# [28] end;
    leave
    ret    $8

-------------- next part --------------
A non-text attachment was scrubbed...
Name: asmConstParameter.pas
Type: text/x-pascal
Size: 377 bytes
Desc: not available
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20081116/372a2486/attachment.pas>


More information about the fpc-devel mailing list