[lug] A head scratcher for your weekend

Zan Lynx zlynx at acm.org
Thu May 24 18:29:11 MDT 2018


On 5/24/2018 8:15 AM, Rob Nagler wrote:
> 
> I hate little endian machines. They make no sense.

Ah but they do. It took me a while to get it myself, but here is the trick.

If you store the value 3 in big endian it looks like this in a hex dump:
00 00 00 03

In little endian it looks like:
03 00 00 00

The goodness of little endian comes in when you read the value using 
different width instructions. Because 03 00 00 00 is the same number at 
16 bits 03 00 and 8 bits 03.

While with big endian the pointer must be shifted over for different 
width access.

If you're building a RISC system where absolutely every memory access is 
32-bits or 64-bits and anything smaller is done with shift/mask, then 
big endian is OK. Otherwise it is annoying.


-- 
                 Knowledge is Power -- Power Corrupts
                         Study Hard -- Be Evil


More information about the LUG mailing list