3 ms·
In term of hardware I think this is irrelevant: lines are labelled 0 to n, that's unequivocal. Now, why is bit 0 the lowest? Well I think this follows naturall
by mytailorisrich 5y ago
In term of hardware I think this is irrelevant: lines are labelled 0 to n, that's unequivocal.
Now, why is bit 0 the lowest? Well I think this follows naturally from binary representation as a polynomial of powers or two. So bit 0 is 2^0, bit 1 is 2^1, etc. Representation with digits in base 2 also simply follows standard order of numerals: 100 is one hundred, not zero zero one whether in decimal or binary.
The issue of big-endian vs little-endian really arises when you want to represent a word across bytes. Different people made different choices, since they are equally valid.
Now, over a serial line you can also decide to transmit bits one way or the other, and this can indeed go either way depending on the interface, either LSB (least significant bit) first or MSB (most significant bit) first.
- bruce343434 5y agoI suppose so. But in multibyte numbers (pretty much all of them nowadays) the nice mapping disappears: u32{a,b,c,d} becomes {d,c,b,a} so that bit 8 is actually the 8th bit of byte d. So 0b 00000001 00000000 00000000 00000000 != 2^24. What I don't understand: why not just go all out little endian at that point? It seems like it would complicate circuit design as well given that an arithmetic shift needs weird wiring to properly work across little endian bytes big bits.
- jsmith45 5y agoCPUs don't need to keep the enregistered bits in any particular order. A little endian CPU could very much actually have the whole register stored in most significant bit to least significant bit, or vice versa, a big endian CPU could hypothetically even have the registered stored in little endian order, but that would be a bit odd. The part that matters is that references to smaller version of the same registers grab the correct bits, and that memory reads and writes write individual bytes in the little endian order (or big endian for big endian processors). Lastly bit order matters for any form of serial IO, but once again, it does not need to correspond to the internal ordering used by the processor in any way shape or form. The bit ordering in RAM within an individual byte also does not matter. If a CPU picked a random ordering of bits in a byte (like 46170325 instead of the logical 01234567 or 76543210 orderings) everything would just work as long as nothing else was directly connected to the memory bus. In practice even DMA devices are not connected directly to the memory bus, and all memory access goes through the the CPU's DDR memory controller, so it literally could pick whatever order for mapping bits to bytes that it wanted.