[fpc-pascal]byte order

2003-07-04 Thread Mattias Gaertner
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 independen

Re: [fpc-pascal]byte order

2003-07-04 Thread Peter Vreman
> 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/q

Re: [fpc-pascal]byte order

2003-07-04 Thread Matt Emson
The word you are looking for is 'Big Endian'. Have a google on 'Big Endian' and 'Little Endian' on google. this is a delphi routine, it may not work in FPC, certainly I would try it first in Delphi compatibility mode, and with Intel style assembler syntax: function Swap32(value : dword) : dword

Re: [fpc-pascal]byte order

2003-07-04 Thread Mattias Gaertner
On Fri, 4 Jul 2003 11:42:59 +0200 (CEST) "Peter Vreman" <[EMAIL PROTECTED]> wrote: > > 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

Re: [fpc-pascal]byte order

2003-07-04 Thread Peter Vreman
>> > If not, how can I determine the current processor byte order? >> >> {$ifdef FPC_BIG_ENDIAN} >> {$ifdef FPC_LITTLE_ENDIAN} > > Thanks. Oops... this was 1.1 only. For 1.0.x (and still supported by 1.1, but deprecated) it is ENDIAN_LITTLE and ENDIAN_BIG ___