← Back to context

Comment by hnlmorg

8 hours ago

16 bit programs used 16 bit addresses, generally speaking.

Even with 32bit systems where you’d want more than 4GB RAM, application software still had 32 bit addresses (and thus 4GB memory limit).

I think it was a lot more common for 8bit systems to allow for 16 bit addressing though.

It’s been a while though. So hopefully I’m not misremembering things.

> I think it was a lot more common for 8bit systems to allow for 16 bit addressing though.

The 6502 and Z80 could use 16 bit addressing to access up to 64kb of memory. The 6502 had various other addressing systems, including iirc 8 bits, but none of them were wider tha 16 bits.

  • Oh yeah. I had loads of 6502 and Z80 systems (still do in fact). Can’t believe I forgot about that!

    Though in fairness, I do mostly now just use those systems to teach my kids BASIC

  • Well, most of the addressing modes of the Z80 used a 16-bit register pair (i.e. 0 to 64K-1 bytes) to address, the 6502 used a somewhat stranger set of addressing modes, but once again you could address 0 to 64K-1 bytes.

You had to deal with two flavors of pointer, near and far. Far pointers came with segment selector, for accessing more than 64k. Your choice of memory model influenced the defaults. You might use near pointers for internal references in a module, and far pointers for external references.

  • I guess it was awkward to use languages that had higher level than assembly in order to write 16-bit programs that required more than 64KiB of memory. And also not quite portable, since they were all tied to x86 CPU. Those were messy times I guess. A somewhat similar story was 32-bit PAE, where the the CPU could address more than 4GiB physical memory, but software was still 32-bit and virtual addresses were capped at 4GiB. Linus was right that you must have more virtual memory (preferably 10+ times more) than physical, otherwise you have to jump through hoops. https://cl4ssic4l.wordpress.com/2011/05/24/linus-torvalds-ab...

    • "portable" used to mean "able to be ported" rather than the "comes automatically ported if you just change compiler options" that it means today

And the 32-bit 4GB limit was often really "just a bit under 2GB" depending on the hardware, OS, etc

Not really. 16-bit programs on x86 used 32-bit pointers (effectively 20-bit due to the segment mechanism).

8-bit microprocessors used 16-bit addresses.