[fpc-devel] Bug with R+ and assembler functionsHi,

Jonas Maebe jonas.maebe at elis.ugent.be
Thu Nov 3 12:04:31 CET 2005


On 3 nov 2005, at 11:53, Markus Kämmerer wrote:

>     .stabn 68,0,257,.Ll49 - EDITOR_FINDUMBRUCH$formal$LONGINT$$LONGINT
> .Ll49:
> # [257] mov   esi,data
>     movl    %eax,%esi
>     .stabn 68,0,258,.Ll50 - EDITOR_FINDUMBRUCH$formal$LONGINT$$LONGINT
> .Ll50:
> # [258] mov   ebx,zlen
>     movl    %edx,%ebx
>     .stabn 68,0,259,.Ll51 - EDITOR_FINDUMBRUCH$formal$LONGINT$$LONGINT
>
> Findumbruch awaits the "data" in esi.

No, in eax. "movl %eax, %esi" means "move the contents of eax into  
esi". This is AT&T assembler notation, not Intel.

> With the R+ version, the value is
> loaded to esi before range check.

No, what is loaded in esi is "offset". The range check is to make  
sure that in the expression "cont[offset]", offset is not going past  
the end of the array.

> In the R- version the value is located
> in ecx and not been copied to esi, which is the bug.

No. At least one problem is that in your assembler function, you use  
esi and ebx without saving/restoring them. ebx, esi and edi are  
callee-saved registers in the new default calling convention of FPC  
2.0 (register calling), just like in C/C++.


Jonas




More information about the fpc-devel mailing list