[fpc-devel]saveregisters bug?

Aleksey V. Vaneev picoder at sbis.komi.ru
Thu Jan 24 21:08:22 CET 2002


Just tried to use 'saveregisters' flag in DLL library's function.

this code is generated at the end of that function:
        popl    %ebx
        popl    %esi
        popl    %edi
        movl    %eax,28(%esp)

This is obviously incorrect since popal will destroy result in %eax.
Also, some optimisation could be made if saveregisters declared: those
3 push/pops are not really needed.

Along with this I've encountered some problems using DLL calls in
Delphi methods... Seems to be, Delphi needs all registers to be
preserved during call or else afterwards some pointers are destroyed
and normal accessing object's vars is impossible (it traps in
fact). As a temporary measure I've used something like that:

asm pushad end; DLLCall(); asm popad end;

Of course, with 'saveregisters' this problem can be solved if the
code generated for it was correct.

BTW, maybe it is possible to add implicit pushad/popad calls in
exported DLL funcs/procedures? If not, then I dunno why you've
included those implicit 3 push/pops...

Best regards,
 Aleksey                          mailto:picoder at sbis.komi.ru

More information about the fpc-devel mailing list