ZX81 Memory Confusion

Any discussions related to the creation of new hardware or software for the ZX80 or ZX81
Post Reply
MrVertigo
Posts: 106
Joined: Fri May 27, 2022 9:06 pm

ZX81 Memory Confusion

Post by MrVertigo »

Why do the memory addresses in a 1k ZX81 start at 16384, and not 0? Or 1?

I understand 16384 is 1024x16. Is it something to do with the 16k Ram Pack always having been planned from the beginning, or something else?
dr beep
Posts: 2082
Joined: Thu Jun 16, 2011 8:35 am
Location: Boxmeer

Re: ZX81 Memory Confusion

Post by dr beep »

On Z80 machines ROM starts at #0000.

The ZX81 is designed that RAM starts at 16384 (#4000) and games load at 16393 (#4009).

It is a fact where you have to work with
Moggy
Posts: 3267
Joined: Wed Jun 18, 2008 2:00 pm

Re: ZX81 Memory Confusion

Post by Moggy »

User avatar
1024MAK
Posts: 5118
Joined: Mon Sep 26, 2011 10:56 am
Location: Looking forward to summer in Somerset, UK...

Re: ZX81 Memory Confusion

Post by 1024MAK »

The memory address does start at zero, that’s the ROM.

However, I presume you actually mean, why does the RAM start at 16384?

The answer is that the machine deliberately uses partial address decoding to keep costs of the hardware low. The 64K (65536) address range is deliberately divided into four:
The first ¼ is the area allocated to the ROM.
The second ¼ is the area allocated to the RAM.
The third ¼ is a “ghost” of the ROM area. An unmodified system does not use this area.
The last ¼ is the ghost” of the RAM area that is needed for the display hardware to work.

Each ¼ is of course 16K (16384 bytes).

More detailed information is in this topic.

Mark
ZX81 Variations
ZX81 Chip Pin-outs
ZX81 Video Transistor Buffer Amp

:!: Standby alert :!:
There are four lights!
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb :!:
Looking forward to summer later in the year.
User avatar
mrtinb
Posts: 1911
Joined: Fri Nov 06, 2015 5:44 pm
Location: Denmark
Contact:

Re: ZX81 Memory Confusion

Post by mrtinb »

Sinclair just wanted to make a cheap computer. So they made the memory map very simple:
  • Address 0 - 16k would be ROM, even though only 8k ROM is installed.
  • Address 16k - 32k would be RAM. 1k internal RAM, or 16k external RAM pack. External RAM disables the internal 1k of RAM.
  • Address 32k - 64k is used to "execute" the data on the screen, to write data on the screen. This part is the most complex of the ZX81, and long articles have been written about this. (Or what 1024MAK said, as he knows the details of the hardware better than I.)
This limits the ZX81 to only 16k of RAM.

However some people are smarter, and have made hardware that goes beyond these limitations.
  • If you add memory that responds to addresses 32k - 64k it works, however only for data. No machine code works here.
  • A modification called M1NOT, will enable machine code running at address 32k - 48k.
  • You can add RAM between 8k - 16k, even though Sinclair intended it for extra ROM. But since all programs are load into address 16k and upwards, it's a little trickier to get software here. You can run machine code from here, but you have to load it as part of a program, and copy it down to this location. Basic cannot run at address 8k - 16k.
So you can get RAM packs that fill up all areas, which gives to a total of 56k of RAM. You still need the 8k ROM, so that cannot be disabled, to give you a total 64k of RAM.

Well not so fast. There actually exists new hardware that can put RAM in the total 64k.
  • The ULA replacement vLA, can be switched into a mode, where the total memory is RAM. And you can copy your custom ROM image into this RAM before enabling it.
  • Wilf Rigter's 64k RAM project can do the same.
Martin
https://zx.rtin.be
ZX81, Lambda 8300, Commodore 64, Mac G4 Cube
MrVertigo
Posts: 106
Joined: Fri May 27, 2022 9:06 pm

Re: ZX81 Memory Confusion

Post by MrVertigo »

These are brilliant replies. I understand now. Thanks.

A really great community.
Post Reply