I have a vague recollection from my earliest days that the ZX80 only shipped with 1K of RAM.

If this RAM was used to store both the program and the contents of the 32x24 screen, wouldn't that mean only about 256 bytes were available for programming?

Or was there some trick used for video memory, such as a separate section of memory dedicated to the screen, apart from the advertised 1K RAM?


Both the ZX80 and the ZX81 had a variable-size display file (DFILE). They didn't store the complete screen contents, but rather only the characters per line up to a terminating newline. This collapsed DFILE is activated when the ZX detects less than 3 1/4kB of memory on startup. A collapsed DFILE can thus be as small as 24+1 bytes (initial HALT, 24 NEWLINEs, or HALT instructions) for an empty screen.

Because ZX-80 and ZX-81 "execute" the DFILE in the display output routine as NOPs, the terminating newline character has to be the opcode of a HALT instruction (76h). This stops the CPU fetching bytes from the DFILE and makes it internally execute NOPs until interrupted (which happens at the end of each scanline, 8 times per character line). The video hardware simply generates white space pixels for the rest of the line.

This results in much less screen memory used than the 768 bytes you would otherwise need for a full screen, at least if you did not fill the complete lines with 32 characters.

Here is a detailed description of how this works (on Grant Searle's great Z80 pages).

  • 5
    Wow, Grant has way too much time on his hands :-) That's an impressive set of pages, I especially liked the "how to build your own complete zx80/zx81/ace" stuff. The execution of the display file is rather bizarre ... – user6464 Oct 15 '18 at 13:35
  • 2
    @paxdiablo bizarre is not the proper term, IMHO. Ingenious fits it better. – tofro Oct 15 '18 at 13:49
  • 1
    @tofro yeah, I've written one of only two emulators that score 100% timing accuracy to a real ZX81, I was just trying to keep it simple by sticking to the thing already being discussed. I don't think IX is involved though — probably you meant I, which contributes the top 8 bits of the refresh address and therefore the top 7 bits of the character lookup address? Nowhere near as good as Grant Searle's documentation, but my hardware summary is at github.com/TomHarte/CLK/wiki/The-ZX80-and-ZX81 – Tommy Oct 15 '18 at 14:54
  • 1
    The Atari 2600 Basic Programming cartridge manages to go one better than this--it generates a line of text from the tokenized source, then displays it, generates another line of text using the same buffer, displays that, etc.thus avoiding any duplication between memory used to store a tokenized program and memory used to display it as text. – supercat Oct 15 '18 at 15:33
  • 1
    @supercat but then again, re: "better", a program running on the ZX80 and ZX81 can output anything it wants over the whole screen, subject to available memory, whereas I think the Atari BASIC offers only two lines out of twelve for your own output? Which, admittedly, is still a superhuman feat with only 128 bytes of RAM. – Tommy Oct 15 '18 at 15:48

It did not (at least not without ugly tricks). In addition to tofro's answer, a simple program at ZX-81 looking something like this (writing from memory):

10 FOR Y=1 TO 24
20 FOR X=1 TO 32

... was enough to achieve Out-of-memory error, because there was not enough room in memory for this measly program, system variables and a full display.

  • 2
    Seems to be not true. At least not on ZX80 on this emulator nocanvas.zame-dev.org/0004 – UncleBod Oct 16 '18 at 9:36
  • 2
    @UncleBod are you able to show the code you ran? The ZX 80 does not have an AT, like the ZX Spectrum does and like Edheldil's code shows. – Wilson Oct 16 '18 at 11:15
  • I guess just PRINT "X"; would achieve what the author is trying to communicate? – Tommy Oct 16 '18 at 12:20
  • @wilson As above, except only PRINT "X"; instead of PRINT AT (Which ZX80 doesn't have). The program size might differ 4-5 bytes, not more. And really, to cram as much as possible into a computer was a sport in those days. Search for ZX81 1K Chess.... – UncleBod Oct 16 '18 at 12:28

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.