Remix.run Logo
alphazard 6 days ago

If each memory address mapped to a CPU word sized value, that would make sense, and that is closer to the reality of instructions reading a word of memory at a time. Instead of using the CPU word size as the smallest addressable value, or the smallest possible value (a bit) as the smallest addressable value, we use a byte.

It's an arbitrary grouping, and worse, it's rarely useful to think in terms of it. If you are optimizing access patterns, then you are thinking in terms of CPU words, cache line sizes, memory pages, and disk sectors. None of those are bytes.

wvenable 6 days ago | parent [-]

There was a time, however, where CPUs operated almost exclusively on on 8bit bytes (and had 8bit data buses). Everything else is merely the consequence of that.

dboreham 6 days ago | parent [-]

Quick note that this isn't true. 8-bit CPUs are newer than 36-bit CPUs, and 8-bit bytes were established long before 8-bit CPUs came on the scene. Prior to the mid-70s most machines were word-addressed. The adoption of byte addressing (the subject of the grandparent) gained traction after C and similar languages became popular. C was developed on the pdp-11 which supported byte addressing and it provided a compatible memory model: any pointer value could be de-referenced to a byte. The VAX followed, also with byte addressing and by 1980 you couldn't sell a CPU that didn't support byte addressing (because C wouldn't work with it). 8-bit CPUs had nothing to do with any of this.

Tor3 6 days ago | parent | next [-]

What you say is correct except for the very last part which is inaccurate. C works with word-addressed CPUs (I can see one from here, and it has a C compiler. And was, incidentally, sold into the early nineties). What C needs is a way to work with 8-bit characters, that's all (and even that isn't 100% true, just widely expected). So what a C compiler needs on, say, a 16-bit addressable computer, is a way to access a char, an 8-bit entity (everything else, e.g. int, long etc., is up to the architecture). And that can be done by software, or more typically by the CPU having opcodes to access 8-bit fields within its native addressable word size.

wvenable 6 days ago | parent | prev | next [-]

The comment was about why CPUs still use byte addressing even today. And it's my belief that's due to incomparably wide proliferation of 8bit computers.

Even CPUs that were 32bit with a 16bit data bus, like the 68000 series, required the ability to read and write single bytes to support the wide range of 8bit I/O chips including UARTs, timers, floppy-disk controllers, video controllers that were common at the time. The 8bit bus was king for a long time.

The evolution of Intel CPUs started with 4-bits

zozbot234 6 days ago | parent | prev [-]

The C "char" type need not be 8-bit at all. *nix operating systems enforce 8-bit bytes, but that's historically due to the primacy of text streams on that platform, and is to some extent an arbitrary choice.