Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I safely assume that Windows installations will always be little-endian?

I'm writing a userspace filesystem driver on Windows and endianness conversions are something I've been dealing with, as this particular filesystem always stores values in little-endian format and the driver is expected to convert them (if necessary) for the CPU it's running on. However, I find myself wondering if I even need to worry about endianness conversions, since as far as I can tell, desktop Windows only supports little-endian architectures (IA32, x86-84, etc.), and therefore, the on-disk little-endian values are perfectly fine sans conversion. Is this observation accurate, and if so, is it generally acceptable to make the assumption that Windows will always be running on little-endian hardware? Additionally, is it even possible (in 2011) to run Windows on a big-endian emulator or something, such that one could even test for endianness issues?

Edit: For additional clarity, the way my code currently works, I do an endianness check at startup time, and then every time I load a value off the disk, I run it through an inline function that uses an intrinsic to change endianness if the architecture is big-endian. The problem is, I don't know if I might have missed one or more of those places where I needed to do a conversion and the easiest way to see if I screwed up is to run the program on a big-endian architecture. So I'm interested in knowing (a) if it's even necessary to do these checks since Windows doesn't ordinarily run on little-endian platforms (today anyway), and (b) how I could possibly test my code, seeing as I can't think of a way to run Windows on a big-endian architecture, and manually reversing all the multibyte values on disk still involves a manual process that I might well screw up.

like image 848
jgottula Avatar asked Jun 23 '11 04:06

jgottula


People also ask

Is Windows big-endian or little endian?

The following platforms are considered little endian: AXP/VMS, Digital UNIX, Intel ABI, OS/2, VAX/VMS, and Windows. On big endian platforms, the value 1 is stored in binary and is represented here in hexadecimal notation.

Which is better little endian or big-endian Why?

The advantages of Little Endian are: It's easy to read the value in a variety of type sizes. For example, the variable A = 0x13 in 64-bit value in memory at the address B will be 1300 0000 0000 0000 . A will always be read as 19 regardless of using 8, 16, 32, 64-bit reads.

Do most computers use big-endian?

The majority of larger computer systems (server/desktop/laptop) currently use little-endian architectures. The majority of smaller computers (tablets/phones) use an endianness-independent processor architecture, but run operating systems that use little-endian order.

Are modern processors Little Endian?

All Intel architecture chips (8088, 8086, 80186, 80286, 80386, 80486, Pentium, Pentium Pro, Pentium II) are strictly little endian, however to ease information exchange Intel added a byte-ordering instruction (BSWAP) to the 80486 and subsequent chips.


1 Answers

All versions of Windows that you'll see are little-endian, yes. The NT kernel actually runs on a big-endian architecture even today.

like image 116
Ana Betts Avatar answered Oct 02 '22 12:10

Ana Betts