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?
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?
As above mentioned, what CPU you are using?
hojjatrakhshani wrote:if thats right how we can do this convertion?
If you can't figure it out, you should not touch the boot sector, it's dangerous.
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.
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.
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?
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).
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.
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?