[fpc-pascal] x86 asm bswap

Sven Barth pascaldragon at googlemail.com
Wed Feb 6 11:13:49 CET 2013


Am 06.02.2013 11:01, schrieb Juha Manninen:
> On Wed, Feb 6, 2013 at 10:40 AM, Jeppe Græsdal Johansen
> <jjohan07 at student.aau.dk> wrote:
>> function TPNGProcessor.SwapLong( const aValue: Cardinal ): Cardinal;
>> begin
>>     result := BeToN(aValue);
>> end;
> Thanks, it works!
> There are so many functions in FPC libraries which I don't know
> anything about. This was one of them.
It could be that BeToN is the wrong function (it depends on how the 
method is used). What it does is the following: if the target cpu is big 
endian (m68k, powerpc) then just return the value, otherwise (i386) swap 
the endianess.

So you should check what SwapLong is really used for.

There are three possible functions:
BeToN (as mentioned above)
LeToN (leave as is if little endian, convert otherwise)
SwapEndian (change always)

Regards,
Sven



More information about the fpc-pascal mailing list