Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does my AMD-based machine use little endian or big endian?

I'm going though a computers system course and I'm trying to establish, for sure, if my AMD based computer is a little-endian machine? I believe it is because it would be Intel-compatible.

Specifically, my processor is an AMD 64 Athlon x2.

I understand that this can matter in C programming. I'm writing C programs and a method I'm using would be affected by this. I'm trying to figure out if I'd get the same results if I ran the program on an Intel based machine (assuming that is little endian machine).

Finally, let me ask this: Would any and all machines capable of running Windows (XP, Vista, 2000, Server 2003, etc) and, say, Ubuntu Linux desktop be little endian?

like image 520
Frank V Avatar asked Jun 21 '09 23:06

Frank V


People also ask

How do I know if my machine is big-endian or little endian?

If it is little-endian, it would be stored as “01 00 00 00”. The program checks the first byte by dereferencing the cptr pointer. If it equals to 0, it means the processor is big-endian(“00 00 00 01”), If it equals to 1, it means the processor is little-endian (“01 00 00 00”).

What machines use little endian?

Intel based processors are little endians. ARM processors were little endians. Current generation ARM processors are bi-endian.

What machines are big-endian?

Solely big-endian architectures include the IBM z/Architecture and OpenRISC. Some instruction set architectures are "bi-endian" and allow running software of either endianness; these include Power ISA, SPARC, ARM AArch64, C-Sky, and RISC-V.

Are all Windows machines little endian?

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


1 Answers

All x86 and x86-64 machines (which is just an extension to x86) are little-endian.

You can confirm it with something like this:

#include <stdio.h> int main() {     int a = 0x12345678;     unsigned char *c = (unsigned char*)(&a);     if (*c == 0x78) {        printf("little-endian\n");     } else {        printf("big-endian\n");     }     return 0; } 
like image 200
mmx Avatar answered Oct 08 '22 11:10

mmx