[fpc-pascal] Inline ASM code
Karoly Balogh (Charlie/SGR)
charlie at scenergy.dfmk.hu
Thu Aug 24 13:14:08 CEST 2017
Hi,
On Thu, 24 Aug 2017, LacaK wrote:
> Thank you!
> I have hoped, that there is some kind of direct usage. Because
> "fstp a" is compiled into:
> fstps -0x24(%ebp) // address of local variable "a" on stack
> and "pa^ := a" into:
> mov -0x4(%ebp),%eax
> mov -0x40(%eax),%edx // pa
> mov -0x24(%ebp),%eax // a
> mov %eax,(%edx) // a -> pa^
>
> so I hoped, that there is possibility to do it directly :
> fstps (-0x24(%ebp))
> but seems that this construct (use address stored on address) is not
> supported by processors instructions at all.
Such double-dereference is actually supported by the CALL instruction
which can jump to an address stored at the address pointed by the
reference operand, IIRC. But that's the exception. The x86 instruction set
is not too orthogonal, it's full of "special" cases like that one.
But really fast CPUs usually don't like such constructs, because it has
too many interdependencies and sub-instructions (like, address calculation
has to be done multiple times), so it's hard decode, pair and to pipeline
them. Yes, the encoding would be smaller, but less instructions doesn't
directly mean faster execution on most modern processors.
Charlie
More information about the fpc-pascal
mailing list