[fpc-pascal]byte order

Peter Vreman peter at freepascal.org
Fri Jul 4 11:42:59 CEST 2003


> Hi,
>
> I need to read 2, 4 or 8 bytes in a processor independent way. For
> example:
> I have 4 bytes ($12 $34 $56 $78), starting with the most signifikant (like
> the 68k processor). Reading a DWord under i386 swaps the bytes
> ($78563412).
> Is there a fast way/procedure to read a word/dword/qword independent of
> the
> processor?
> Something like
>
> function GetWordInLeastSignifikantByteOrder(P: PWord): Word;
>
> If not, how can I determine the current processor byte order?

{$ifdef FPC_BIG_ENDIAN}
{$ifdef FPC_LITTLE_ENDIAN}






More information about the fpc-pascal mailing list