I built an external 8K RAM circuit that replaced the 8K ROM of Sinclair ZX81 and I also pulled out address lines from the ULA (dogsbody) so that character generation worked. I wrote a small machine code program that copied the ROM to high RAM, switched manually, copied to RAM in (0-8K area) that replaced ROM, and write protected the ROM manually. It would not work if I didn't write protect the ROM, as far as I can remember. I had the 1st release of the ZX81 ROM (550).

Is there a ZX81 BASIC ROM that doesn't require write lock? I know there are three official releases of the ROM (550, 622, 649/V2), and at least two later: Shoulders of Giants (SG) and The Big Bang (x2c).

Why does the RAM (that replaces ROM) need to be write protected? Is it because there are instructions in the official ROM code that write to the ROM area. Why would one need to do that?

BTW my RAM that replaced the ROM was also battery powered by two AA batteries when the main power was off.

  • 3
    I built such a thing at least two times many years ago. The best solution is to write protect the RAM against writes at the 0-8K range, but to keep it writable at another range. This way you can still deliberately patch its contents without being hit by flaws of the BASIC. Jun 7, 2021 at 6:48

1 Answer 1


Directly to answer your question:

  • yes, if the RAM copy is substituted after the machine has started up;
  • otherwise, not reliably, as it's likely the first five bytes have been altered.

With reference to The complete Timex TS1000/Sinclair ZX81 ROM disassembly notice the 'skip constants' routine starting at the bottom of page 87 of the PDF, page 52 of the real book, in particular these lines at the top of the next page:

LD DE,+0000                    ; The dummy address.
CALL 19FE,STK-CONST            ; Perform imaginary stacking of an
                               ; expanded constant.

The STK-CONST routine is at the top of page 87/52 but you don't need to read most of it, just the first few words of the description from a page prior: "This subroutine places on the calculator stack..." and its restatement that goes with the two lines at the bottom of that page from 19FC:

LD H, D     ; This subroutine performs the
LD L, E     ; manipulatory operation of adding a
            ; 'last value' to the calculator stack;
            ; hence HL is set to point to one past the
            ; present 'last value' and hence point to
            ; the result.

So, ignoring the rest of the code:

  • DE points to the location of the calculator stack at entry of STK-CONST;
  • this routine writes to that stack; and
  • the skip constants routine provides a dummy value of DE=0 in order to negate that behaviour.

So: If you have RAM rather than ROM at address 0 then it'll actually be overwritten with five bytes, representing one of the ZX81's format of floating-point numbers.

Given that a Z80 always starts reading instructions from address 0 after reset, that'll cause the machine no longer to start up correctly.

Sadly, 'skip constants' isn't especially obscure — it's used every time the machine parses a BASIC line number.

Disclaimer: I learnt of this flaw through empirical debugging — trapping for writes into the ROM area and then working backwards. I considered the discovery of one such flaw sufficient to answer the question. I am not aware whether this is the only obstacle.

  • Shouldn't it be possible to just tie the write enable line on the RAM pretending to be a ROM so that writing is disabled?
    – UncleBod
    Jun 7, 2021 at 5:58
  • 2
    @UncleBod, I assumed that's what mobluse meant by "write-protect". Jun 7, 2021 at 7:24
  • Of the different ROMs 550, 622, 649/V2, SG, and x2c, which do you refer to? Maybe you mean the latest official ROM i.e. 649/V2. Maybe some of the later ROMs can be used in RAM without write-protect.
    – mobluse
    Jun 23, 2021 at 8:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .