Page 1 of 1

BASIC program location

Posted: Fri Feb 28, 2025 6:20 am
by stroebeljc
I feel like I should know this one, but I can't seem to find the answer easily, so I'll ask the gurus on this forum.
Does that first line of a BASIC program always have to start at address 16509? I'm not talking about using RUN with a line number to change the starting point of a program. I'm talking about where the BASIC program is actually located in memory, and can it be moved somewhere else and run from there. It's easy to make relocatable assembly, but how about relocatable BASIC?
Someone must know. :twisted:

Re: BASIC program location

Posted: Fri Feb 28, 2025 7:46 am
by 1024MAK
The answer is in the ZX81 Programming Manual (chapter 27). But to save you looking, yes, the BASIC program for a ZX81 always starts at 16509.

RUN does start looking at this address, but as long as "lines" look like REMs, the actual program code can be further on.

In the ZX Spectrum, the BASIC program start address is a system variable.

In some ZX81 "clones", the memory address of the start of BASIC may be different.

Mark

Re: BASIC program location

Posted: Fri Feb 28, 2025 8:10 am
by XavSnap
Hi,
The BASIC start offset is set at $400/1024 in the BASIC ROM. ( LD HL,$407D)
The TS1000 demonstrator card change the $402 value to $20 (Was $40), and launch the BASIC at $207D)

I seen a POKE to change the memory bottom (MEMBOT, beatween 16477 and 16506.
It was able to store two basic programs, and swap both listings.

Re: BASIC program location

Posted: Fri Feb 28, 2025 3:30 pm
by dr beep
It only starts at 16509 when you code on a ZX81.

My games only have 1 line of BASIC to start machinecode and that is located over the sysvar.

Question is why do you want to have BASIC elsewhere?

Re: BASIC program location

Posted: Fri Feb 28, 2025 7:35 pm
by stroebeljc
XavSnap wrote: Fri Feb 28, 2025 8:10 am The BASIC start offset is set at $400/1024 in the BASIC ROM. ( LD HL,$407D)
The TS1000 demonstrator card change the $402 value to $20 (Was $40), and launch the BASIC at $207D)
Actually, the modified location in ZX81 ROM is $9DB, but the gist of what you're saying is spot on.

Re: BASIC program location

Posted: Fri Feb 28, 2025 7:36 pm
by stroebeljc
dr beep wrote: Fri Feb 28, 2025 3:30 pm Question is why do you want to have BASIC elsewhere?
It's a philosophical question more than anything. Most other machines, including the ZX Spectrum, allow for this.

Re: BASIC program location

Posted: Fri Feb 28, 2025 8:49 pm
by 1024MAK
The big difference between the ZX81 and the ZX Spectrum is that the later machine came as standard with 16K bytes of RAM (or more).

Additionally, the ZX Spectrum was supposed to support a more flexible I/O system. So it was essential to have space in RAM for that. That meant that the program area (as per the design of the ROM code) could no longer start at a fixed hard coded position in RAM.

The ZX81 was an evolution of the ZX80. The ZX Spectrum was an evolution of the ZX81. But with the increase in both ROM and RAM, the writers of the ROM took the opportunity to make some improvements.

Mark

Re: BASIC program location

Posted: Sat Mar 01, 2025 2:53 pm
by stroebeljc
I get that it's all part of the evolution of computer design. I was wondering if anyone had come up with a clever way to relocate a BASIC program on the Zeddy. It appears to not be possible. That is the answer I'm looking for.

Re: BASIC program location

Posted: Sat Mar 01, 2025 4:36 pm
by mrtinb
The closest thing I've seen is a program called SWAP. Here you can have 2 Basic programs loaded, and SWAP can swap them around, but it is only the first one in the right location you can run.

Re: BASIC program location

Posted: Sat Mar 01, 2025 5:00 pm
by 1024MAK
Without changing the ROM code, no you can't relocate a BASIC program to elsewhere in memory and RUN it from there.

Mark