[fpc-devel] Re: systemh.inc InterLockedIncrement64 (var Target: int64)

Thomas Schatzl tom_at_work at gmx.at
Thu Oct 28 16:25:59 CEST 2010


Hi,

On Thu, 28 Oct 2010 08:28:16 -0500, Andrew Brunner
<andrew.t.brunner at gmail.com> wrote:
> I tried to use the assembly code from the x64 unit on a i386 build of
> FPC but FPC throws error on compile.  Why are the specific x64
> instructions being blocked?  The cpu running the code has the ability

In general, the 32 and 64 bit instructions partially use the same opcode
for different actual instructions depending on the processor mode. The code
segment selector contains information about the type of instruction set
used.
It might be worth a try to hack a REX prefix in 32 bit assembly and see
what happens, but I'd assume that either you get an invalid opcode
exception or the prefix is just ignored.
 
What you expect can only be done on more regular ISAs like PowerPC where
you have different instruction encodings for different data sizes.

Complaints about the x86 ISA please direct to AMD and/or Intel :)

> Under Windows there are functions for interlocked*(Int64).

They very likely use cmpxchg8b.

As maybe already mentioned it may be possible to provide such
functionality on x86 processors only. Otoh, some other 32 bit architectures
do not have such an instruction iirc, at least 32 bit powerpc, and armv5 or
earlier (I think for armv6 something like that has been added).

> The either the application developer or possibly the end-user should
> be able to activate x64 instructions either at compile time or run
> time (with no respect to 64 bit binary).  Obviously a 64 bit app would
> have blind access to X64 cpu instructions.

See above. That will not work.

Thomas




More information about the fpc-devel mailing list