Page 1 of 1

Little Endian Big Endian?

Posted: Sun Oct 30, 2005 9:18 pm
by Nik
Ok Mac OS X is Big Endian and Windows is little Endian so what problems to fear when doing a Filetransfer system based on PBs Network libary communicating between Mac OS X and Windows? (All Apps in PB)
bye Nik

Posted: Mon Oct 31, 2005 11:17 am
by Trond
Nothing, I think.

Posted: Mon Oct 31, 2005 11:22 am
by Dare2
I think the actual transfer won't mess with the byte sequence. So the issue, if anything, will be the "endian-ness" of the source data, as this will be retained and therefore either has to be fixed before or after transfer.

But I am guessing.

Posted: Mon Oct 31, 2005 11:56 am
by Nik
If you also have to send the length of the content i would have to make sure that for example both sides use little endain.
Right?

Posted: Mon Oct 31, 2005 1:12 pm
by Fred
Yes, it's true. I don't think it will work for now, i will fix that ASAP.

Posted: Mon Oct 31, 2005 2:50 pm
by Nik
What do you mean it ins't working now? No function for conversion or no network support :wink:

Posted: Mon Oct 31, 2005 4:06 pm
by Nik

Code: Select all

Procedure LittleToBig(Long.l)
  PokeB(@LongBig+2,PeekB(@Long+3))
  PokeB(@LongBig+3,PeekB(@Long+2))
  PokeB(@LongBig,PeekB(@Long+1))
  PokeB(@LongBig+1,PeekB(@Long))
ProcedureReturn LongBig.l
EndProcedure
Is this correct?
I also noticed that 'UNIX' is not the same as PokeS(@Address,"UNIX") Why?
And thats te point that makes us think that it should be called XINU Problem instead of NUXI Problem *confused*

Posted: Mon Oct 31, 2005 7:57 pm
by djes
A little code used for a value from a file...

Code: Select all

nb.l=ReadLong()
MOV eax,nb
BSWAP eax
MOV nb,eax

Posted: Tue Nov 01, 2005 1:22 pm
by Nik
Well it musst be correct but

Code: Select all


nb.l=0
PokeS(@nb,"UNIX",4)
MOV eax,nb
BSWAP eax
MOV nb,eax 

Debug PeekS(@nb,4)
Debuges XINU and it's called the NUXI Problem so wtf

Posted: Tue Nov 01, 2005 2:04 pm
by djes
Sorry, I don't understand. :?

Posted: Tue Nov 01, 2005 2:29 pm
by Dare2
Not 100% sure what we are getting at here, but ...

"UNIX" is 4 bytes long, respresenting here, I think, a 4 byte integer?

XINU is how a 4 byte (long) reversal would appear
NUXI is how 2x2 byte (words) reversal would appear.

Also, are you reversing all data sent one side to the other? I think (stress, think) you would only need to reverse words/longs where those were stored as words/longs in the original data.

So
>> [long]+"ABC"+[word]+[word]+[byte] - or - [1234]ABC[12][34][1]
would go across as
>> [gnol]+"ABC"+[drow]+[drow]+[byte] - or - [4321]ABC[21][43][1]


If you are sending "UNIX" and then, on fixing it on the other side, you are ending up with "XINU" then you don't need to be fixing it.

If you are ending up with "NUXI" (unfixed) on other side, need to be fixing word reversals.

If you are ending up with "XINU" (unfixed) on other side, need to be fixing long reversals.

But I am not really sure what it is that we are talking about. :D What exactly are we trying to address? What are you getting on the "other side"?

Posted: Tue Nov 01, 2005 2:50 pm
by Nik
It was a theoretical Problem :lol: Haven't got a Mac yet but was interested in it and maybe it was good because it seems like it reminded fred at something :lol:
Well maybe I can get my Hands on a Mac then I will test this Theorey in practice. But nice to know how the made this NUXI problem up. Because who the hell would stroe a 4 byte String in 2 words :oops:
Thanks a lot for your efford

Posted: Tue Nov 01, 2005 3:00 pm
by djes
In theory, no. For more details:
http://en.wikipedia.org/wiki/Endian