BASIC program location

Anything Sinclair ZX Basic related; history, development, tips - differences between BASIC on the ZX80 and ZX81
Post Reply
stroebeljc
Posts: 114
Joined: Thu Apr 23, 2020 6:02 am
Location: Minneapolis, MN

BASIC program location

Post 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:
John
User avatar
1024MAK
Posts: 5526
Joined: Mon Sep 26, 2011 10:56 am
Location: Looking forward to summer in Somerset, UK...
Contact:

Re: BASIC program location

Post 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
ZX81 Variations
ZX81 Chip Pin-outs
ZX81 Video Transistor Amp

:!: Standby alert :!:
There are four lights!
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb :!:
Spring approaching...
User avatar
XavSnap
Posts: 2193
Joined: Sat May 10, 2008 4:23 pm
Location: 'Zx81 France' Fb group.
Contact:

Re: BASIC program location

Post 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.
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
dr beep
Posts: 2428
Joined: Thu Jun 16, 2011 8:35 am
Location: Boxmeer

Re: BASIC program location

Post 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?
stroebeljc
Posts: 114
Joined: Thu Apr 23, 2020 6:02 am
Location: Minneapolis, MN

Re: BASIC program location

Post 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.
John
stroebeljc
Posts: 114
Joined: Thu Apr 23, 2020 6:02 am
Location: Minneapolis, MN

Re: BASIC program location

Post 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.
John
User avatar
1024MAK
Posts: 5526
Joined: Mon Sep 26, 2011 10:56 am
Location: Looking forward to summer in Somerset, UK...
Contact:

Re: BASIC program location

Post 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
ZX81 Variations
ZX81 Chip Pin-outs
ZX81 Video Transistor Amp

:!: Standby alert :!:
There are four lights!
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb :!:
Spring approaching...
stroebeljc
Posts: 114
Joined: Thu Apr 23, 2020 6:02 am
Location: Minneapolis, MN

Re: BASIC program location

Post 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.
John
User avatar
mrtinb
Posts: 2004
Joined: Fri Nov 06, 2015 5:44 pm
Location: Denmark
Contact:

Re: BASIC program location

Post 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.
Martin
https://zx.rtin.be
ZX81, Lambda 8300, Commodore 64, Mac G4 Cube
User avatar
1024MAK
Posts: 5526
Joined: Mon Sep 26, 2011 10:56 am
Location: Looking forward to summer in Somerset, UK...
Contact:

Re: BASIC program location

Post 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
ZX81 Variations
ZX81 Chip Pin-outs
ZX81 Video Transistor Amp

:!: Standby alert :!:
There are four lights!
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb :!:
Spring approaching...
Post Reply