big-endian and little-endian convertion
-
- Posts: 21
- Joined: Sun Feb 19, 2012 7:25 am
big-endian and little-endian convertion
hi guys!
the data that stored in volume boot sector are
little-endian format(such as BIOS Parameter Block).
they must convert to big-endian to use?
if thats right how we can do this convertion?
the data that stored in volume boot sector are
little-endian format(such as BIOS Parameter Block).
they must convert to big-endian to use?
if thats right how we can do this convertion?
-
- Member
- Posts: 95
- Joined: Thu Jan 29, 2009 9:13 am
Re: big-endian and little-endian convertion
what system are you working with? x86 does not need to ever use big endian.
Re: big-endian and little-endian convertion
As above mentioned, what CPU you are using?hojjatrakhshani wrote:the data that stored in volume boot sector are
little-endian format(such as BIOS Parameter Block).
they must convert to big-endian to use?
If you can't figure it out, you should not touch the boot sector, it's dangerous.hojjatrakhshani wrote:if thats right how we can do this convertion?
Re: big-endian and little-endian convertion
On 486+ CPUs endiannes conversion is performed by BSWAP instruction.
But as Merlin wrote, you don't need to do that on Intel machines since Intel CPUs are little-endian.
But as Merlin wrote, you don't need to do that on Intel machines since Intel CPUs are little-endian.
-
- Posts: 21
- Joined: Sun Feb 19, 2012 7:25 am
Re: big-endian and little-endian convertion
thanks!
for example bytes per sector stored in BPB with this value 00 02
i dont need convert it to 02 00 fo my calculation?
sorry!i use x86.As above mentioned, what CPU you are using?
for example bytes per sector stored in BPB with this value 00 02
i dont need convert it to 02 00 fo my calculation?
Last edited by hojjatrakhshani on Tue Apr 03, 2012 2:58 am, edited 1 time in total.
Re: big-endian and little-endian convertion
If you're curious look at the functions ntohs() etc, their internal implementation. these will show you how its done on systems that do need it for if you need it later, e.g. for networking most likely or talking to other systems.
Re: big-endian and little-endian convertion
Ah, you don't want to do TCP/IP?Merlin wrote:x86 does not need to ever use big endian.
Every good solution is obvious once you've found it.
Re: big-endian and little-endian convertion
The OP say he's working on boot sector
Re: big-endian and little-endian convertion
Hi,
If it was big endian, then the most significant byte would be first, and it'd be 0x02, 0x00.
Cheers,
Brendan
The bytes 0x00, 0x02 would be 0x0200 in little-endian format, which is what an 80x86 CPU expects. Just read them as a 16-bit word (with no byte swapping required).hojjatrakhshani wrote:sorry!i use x86.
for example bytes per sector stored in BPB with this value 00 02
i dont need convert it to 02 00 fo my calculation?
If it was big endian, then the most significant byte would be first, and it'd be 0x02, 0x00.
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
-
- Member
- Posts: 95
- Joined: Thu Jan 29, 2009 9:13 am
Re: big-endian and little-endian convertion
I apologise for being presumptuous. I know little of tcp/ip but would be shocked to find any Big Endian components in the Fat filesystem.Solar wrote:Ah, you don't want to do TCP/IP?Merlin wrote:x86 does not need to ever use big endian.
- xenos
- Member
- Posts: 1118
- Joined: Thu Aug 11, 2005 11:00 pm
- Libera.chat IRC: xenos1984
- Location: Tartu, Estonia
- Contact:
Re: big-endian and little-endian convertion
Well, if the OP was reading a floppy bootsector on an Atari or some other M68K device, he would have to convert some data to big-endian - but not on an x86 computer.
Just as an off-topic side note, have you ever wondered where the terms big-endian and little-endian actually come from?
Just as an off-topic side note, have you ever wondered where the terms big-endian and little-endian actually come from?
-
- Member
- Posts: 95
- Joined: Thu Jan 29, 2009 9:13 am
Re: big-endian and little-endian convertion
I have stumbled upon the explanation before, im agnostic on the subject(like a PPC).