[fpc-pascal] Converting String to array of Char generates duplicate local var

cobines cobines at gmail.com
Fri Sep 2 11:04:26 CEST 2011


Hello.

I have definitions:

PluginDir: packed array [0..Pred(16384)] of AnsiChar;
sName: AnsiString;

When I assign AnsiString to array of Char compiler generates code like this:

-4(%ebp) is source string
-17252(%ebp) is local temporary array
4(%ebx) is my destination array of char

# [411] PluginDir:= sName;
        movl    -4(%ebp),%ecx
        leal    -17252(%ebp),%eax
        movl    $16383,%edx
        call    fpc_ansistr_to_chararray
        leal    4(%ebx),%edi
        leal    -17252(%ebp),%esi
        cld
        movl    $4096,%ecx
        rep
        movsl

The result is copying data twice and as you see array is quite big.
Is it not possible to write directly to 4(%ebx)?

FPC 2.7.1 i386-Linux

--
cobines



More information about the fpc-pascal mailing list