As mentioned in this answer about how the C64 stores BASIC program text, MS-BASIC uses a pointer called TXTTAB that points to the start of the program text, which is typically at address 1 in a page. For example, on the Commodore 64 it's at address $0801:

 8         1

As 8-Bit Show and Tell points out at 20:29 in this video (which is demonstrating a technique developed decades ago), when moving the BASIC program text start area, you need to ensure that the byte just before your new TXTTAB start point is set to 0 for BASIC to function properly:

POKE 1024 [the byte before the new TXTPTR], yeah, that's the start of BASIC memory, just putting a zero there, which is necessary; if you don't do that you'll get syntax error when you try to do anything in BASIC, even if you try and LIST.

This is not entirely correct; in VICE I tried POKE 2048,1 and LIST still worked, but other commands, such as NEW, RUN and GOTO 10 (after I'd entered a line 10) did produce ?SYNTAX ERROR.

The Apple II+ (emulated with AppleWin) running Applesoft BASIC has similar issues; POKE 2048,1 produces ?SYNTAX ERROR when I type NEW (though it does clear the program) and with the program 10 PRINT "HELLO" in memory, typing RUN produces ?SYNTAX ERROR in 65044.

The same issues also arise on an MSX2 machine (Sony HB-F1XD emulated with OpenMSX): POKE 32768,1 produces syntax errors for NEW and RUN with a program similar to the above.

Why is that location required to be zero?

  • 2
    Is this a duplicate or does the same answer apply? retrocomputing.stackexchange.com/questions/17475/…
    – Justme
    Jun 5, 2022 at 21:33
  • Is your emulator able to set a watchpoint on that address, so that it drops to the debugger when it is read or written? That would help identify the code that accesses it, and then you could try to figure out what it does. Jun 5, 2022 at 22:24
  • @Justme No, that's pretty much entirely unrelated. That guy's just got the start point for BASIC program text incorrect (he's using [TXTTAB]-1 rather than [TXTTAB]). He could make it work fine after loading by setting the value in TXTTAB to $0800 and putting 0 in $07FF. Or recreate the problem above by putting 1 in $07FF. I am not shifting my program to the wrong location; I am simply changing a location just outside my program, a location one that doesn't have any apparent use.
    – cjs
    Jun 6, 2022 at 1:25
  • 1
    @cjs There is a comment that should be an answer for you : "on the first location a 0 is needed because the RUN command starts with the BASIC text pointer pointing to the last read character. This 0 byte provides an end-of-line condition, which let the interpreter search for the next line (an implicit GOTO 0) and advance to $801 as the first line to interpret" which is confirmed by another comment about disassebly of RUN.
    – Justme
    Jun 6, 2022 at 5:00
  • 2
    If this is about the details of New, then better close this and do a dedicated follow up to Why does Applesoft get confused by a nonzero value at $0800? focused on that item Otherwise it's just confusing future readers.
    – Raffzahn
    Jun 6, 2022 at 8:14


You must log in to answer this question.

Browse other questions tagged .