5.1.11 · D1Instruction Set Architecture (ISA)

Foundations — Endianness (big vs little)

2,954 words13 min readBack to topic

Before you can even ask "big-endian or little-endian?", you must already be fluent in a small pile of ideas that the parent note quietly assumes: what a bit is, what a byte is, what an address is, what significance means, and what that scary-looking actually counts. This page builds every one of them from nothing, in order, each on top of the last.


1. The bit — the smallest yes/no

We need the bit because it is the atom of all digital storage. Everything above — bytes, numbers, addresses — is just a group of bits with an agreed meaning.

Figure 1 shows two switches side by side: the teal one down (value , off) and the orange one up (value , on). Read it as the visual definition of a bit — only two states exist, with nothing in between.

Figure — Endianness (big vs little)
Figure 1 — A bit is one switch: down = 0 (off), up = 1 (on). No third option.


2. The byte — eight bits packed together

Why ? Each of the 8 bits doubles the number of patterns: (eight times) . Look at the strip of 8 switches below — every distinct arrangement is one value.

The byte matters because it is the smallest chunk memory actually hands you. You never fetch a single bit from memory; you fetch whole bytes. This is exactly why endianness exists — a big number must be split into bytes, not bits.

Figure 2 draws one byte as a row of 8 coloured switches set to the pattern 00010010. Orange switches are , teal are ; below each you see its bit number ( on the far left down to on the far right, matching the numbering just defined). That exact pattern is the value we will meet again as 0x12. Use the figure to see that "one byte = eight ordered on/off cells".

Figure — Endianness (big vs little)
Figure 2 — One byte = 8 ordered bits, numbered 7 (leftmost, worth 2⁷) down to 0 (rightmost, worth 2⁰). The pattern 00010010 shown here is the value 0x12 (decimal 18).


3. Hexadecimal — writing bytes without pain

Why does two hex digits equal one byte? Because — exactly the number of patterns in a byte. One hex digit covers one nibble ( bits), so two hex digits cover both nibbles ( bits).

We need hex because the parent note writes values like 0x12345678 — that's just 4 bytes (12, 34, 56, 78), each a pair of hex digits. Hex makes the byte boundaries visible at a glance.


4. Significance — which digit is worth more

For 0x12345678, the 12 on the far left is the MSB (worth the most) and the 78 on the far right is the LSB (worth the least). This ordering is the whole reason "big end" vs "little end" even means something.

Figure 3 stacks the four bytes of 0x12345678 as bars whose height is their significance: the tall orange 0x12 (weighted by ) down to the short 0x78 (weighted by ). The arrow across the top reminds you significance decreases as you move right toward the LSB.

Figure — Endianness (big vs little)
Figure 3 — The four bytes of 0x12345678 ranked by significance: MSB 0x12 (×256³) is worth most, LSB 0x78 (×256⁰) worth least.


5. The power — why bytes are weighted by powers of 256

Why exactly and not something else? Because each byte contributes bits, and . Stacking bytes below a byte multiplies that byte's value by exactly times — that is . Note (any number to the power is ), so the LSB is weighted by : it truly is the "ones" byte.


6. The floor and mod tools — pulling ONE byte out

The parent's key formula is . Two new symbols appear here; both answer a precise question.

Why these two, and why together? To grab byte number you need to (1) shift away the bytes below it, then (2) keep only the single byte on the bottom:

  • Dividing by slides byte down to the "ones" position — but leaves higher bytes stuck on top. floor cleans off any fractional leftovers so we have a clean whole number.
  • mod 256 then chops off everything above the bottom byte — because is exactly one byte's worth of values.

7. The address — a numbered slot in memory

With and pinned down, the parent's two rules read cleanly ( is the number of bytes in the value, for a 32-bit integer):

  • Little-endian: (byte goes to offset — straight copy, so LSB at address ).
  • Big-endian: (the index is reversed, so the biggest byte lands at offset , i.e. address ).

8. Beyond two: are big and little the only orders?


Prerequisite map

Bit = one 0 or 1

Byte = 8 bits = 256 values

Nibble = 4 bits = one hex digit

Hex = 2 digits per byte

Significance MSB vs LSB

Weight 256^k per byte

Floor and mod extract one byte

Address = numbered byte slot

Base A and offset i give mem index

Endianness = which byte at lowest address


Equipment checklist

Cover the right side and answer out loud — if any stalls, re-read that section before the main note.

What is a bit, in one phrase?
One storage cell holding exactly or .
How many distinct values fit in one byte, and why?
, because patterns from 8 bits.
Inside a byte, which bit is bit 0 and what is it worth?
The rightmost bit (LSB), weighted by ; bit 7 is the leftmost (MSB), worth .
What is a nibble?
A group of 4 bits (half a byte) = exactly one hex digit's worth, patterns.
What does 0x in front of a number tell you?
The number is written in hexadecimal (base-16).
How many bytes is 0x12345678?
Four bytes: 12, 34, 56, 78.
What decimal number is 0x12345678?
(from ).
Which byte is the MSB in 0xAABBCCDD?
AA — the leftmost, weighted by the largest power.
In , what range does run over?
From (the LSB) up to (the MSB); for 32-bit so .
Why is each byte weighted by and not ?
One byte rolls over after values, so shifting up a byte multiplies worth by .
What does equal?
— floor drops the fractional part.
What does equal?
— the remainder after dividing.
In , what job does the division do?
Shifts byte down to the bottom position.
In that same formula, what job does mod 256 do?
Keeps only the single bottom byte, discarding higher ones.
What does "byte-addressable" mean?
Each memory address names exactly one byte.
What does refer to, in terms of raw address?
The byte at raw address (offset from base ) — mem is indexed from 0 by the offset, so is the byte at address .
Are big- and little-endian the only theoretically possible byte orders?
No — bytes allow orders; middle/mixed-endian (e.g. PDP-11) existed, but only big and little are common.

Connections

  • Parent: Endianness (big vs little) — these foundations feed straight into it.
  • Data Representation — where comes from.
  • Memory Addressing — supplies the numbered-slot model behind and .
  • Bitwise Operations — the floor/mod extraction is done in practice with shifts and masks.
  • Pointers and Type Punning — reads individual bytes at chosen addresses.
  • Network Protocols — the reason two conventions ever meet.