[fpc-devel] threadvar implementation

Michael Schnell mschnell at lumino.de
Thu Aug 5 09:47:46 CEST 2010

  On 08/04/2010 10:29 PM, "Vinzent Höfler" wrote:
> |"The source operand is a memory address (offset part)"
>                                            ^^^^^^^^^^^
> Says that only the offset is used.
OK, it says the offset part is _specified_. But the text describes the 
LEA instruction ("8D") itself. regarding the hardware, the segment 
prefix is another self-contained instruction, that does nothing but set 
a flag to be used (and always cleared) by the next instruction. As 
normally it's obvious what they do, the description of the instructions 
usually does not mention these flags. even though, regarding the ASM 
syntax it's allowed to include the "FS:" in the ASM instruction itself 
(with the address specification).

IMHO, if the compiler should issue an error message if yo9u give a 
segment register with LEA, as the result obviously is erroneous. Maybe 
other compilers in fact do this. I only tested Turbo Delphi.

> So I don't know why you seem so confused. After all, it's x86. See signature. :)
To male the LEA instruction work decently with segment registers you 
would need to give two of them, one for the "source" address 
specification and another one for the "target" (the segment register the 
calculated offset is to be used with). This very obviously is not 
possible with the normal ways of the instruction coding ant that is why 
I never assumed it would be possible to specify even only one. The 
current implementation of "LEA" just assumes the same same segment both 
for "source" as for "target", and thus it's clear what it is supposed to 
do (it ignores the flag set by any segment prefix instruction).


More information about the fpc-devel mailing list