Still, you're swap32 function should be longword, not word, no?
word and $FFFF0000 === 0 -- ALWAYS
word shl 16 === 0 -- ALWAYS.
So in effect:
result:=(Swap16(x and $ffff) shl 16) or Swap16((x and $ffff0000) shr 16);
is the same thing as saying
result:=0;
Which means on big-endian systems when your swap function is called, you'll get nothing but zero.
Also, you're sending zero to your swap16 function...
Is what you should have there. What you have right now won't work... Thankfully it's only called on big endian systems -- and you've probably only tested little endian.Code:function Swap32(x:longword):longword; begin result:=(Swap16(x and $ffff) shl 16) or Swap16(x shr 16); end;
It may also need typecasting forced, since swap16 returns word, not longword meaning that shl 16 could STILL result in zero.
Bookmarks