Question on use of zero page addresses

Basic and Machine Language

Moderator: Moderators

Post Reply
User avatar
AndyH
Vic 20 Afficionado
Posts: 364
Joined: Thu Jun 17, 2004 5:51 am
Website: https://www.hewco.uk
Location: UK
Occupation: Developer

Question on use of zero page addresses

Post by AndyH »

I have a couple of questions about use of the zero page memory.

I was reading Mapping the Vic and it states two memory ranges are used either by BASIC or the Kernal -

$00 - $8f = BASIC working storage
$90 - $ff = Kernal working storage (mostly)

After a machine code program has loaded from tape or disk and is running, or the equivalent for a cartridge, do you know if the BASIC working storage (up to $8f) is safe to use if I am not intending to return to BASIC or use features of BASIC?

I've not looked at loading from tape or disk in my program yet, would this require use of this area of memory?
--
AndyH
HEWCO | Vic 20 blog
User avatar
AndyH
Vic 20 Afficionado
Posts: 364
Joined: Thu Jun 17, 2004 5:51 am
Website: https://www.hewco.uk
Location: UK
Occupation: Developer

Re: Question on use of zero page addresses

Post by AndyH »

I should add that I wrote a program to clear $00 to $ff and then do some general stuff and watched what happened in VICE and <$8f appeared to remain untouched.

Am I opening up a world of pain for myself? :evil:
--
AndyH
HEWCO | Vic 20 blog
groepaz
Vic 20 Scientist
Posts: 1187
Joined: Wed Aug 25, 2010 5:30 pm

Re: Question on use of zero page addresses

Post by groepaz »

Thats pretty much what i would do as well :) most of the zeropage is free if you dont use BASIC at all, you'll need a few locations if you still want to use KERNAL. what exactly you can use depends on which functions you want to use exactly.
I'm just a Software Guy who has no Idea how the Hardware works. Don't listen to me.
User avatar
srowe
Vic 20 Scientist
Posts: 1340
Joined: Mon Jun 16, 2014 3:19 pm

Re: Question on use of zero page addresses

Post by srowe »

V-FORTH uses all of zero page below $90 and then uses KERNAL calls for all its I/O.
User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: Question on use of zero page addresses

Post by Mike »

Hi, Andy,

a posting of mine in an older thread confirms the partition of zeropage between BASIC ($00..$8F) and KERNAL ($90..$FA). As has been pointed out already, $FB..$FE are free. $FF gets overwritten during float -> ASCII conversions (and thus effectively 'belongs' to BASIC).
AndyH wrote:I should add that I wrote a program to clear $00 to $ff and then do some general stuff and watched what happened in VICE and <$8f appeared to remain untouched.
In said thread, the OP did likewise. However (see my response there), you can't really expect that the ROM code still shows the same behaviour regarding zeropage usage, when you overwrite most of its workspace.

...

If you write something that could be in the widest sense be regarded as "language", i.e. it 'replaces' BASIC as user interface and doesn't call any of the routines in the BASIC interpreter in $C000 .. $E47F, then $00..$8F are free for your use. What re-inforces this assessment is - even though the BASIC interpreter calls KERNAL routines to perform some of its work, the KERNAL in turn *never* calls routines in the BASIC interpreter - with two exceptions: cold start (after reset, vectored through $C000) and warm start (after STOP/RESTORE, vectored through $C002). You can thus be sure, that no KERNAL call does change/use BASIC zeropage locations (neither directly nor indirectly).

For something that's supposed to go alongside BASIC, yet still needs some more zeropage, the addresses shared between tape and RS232 operation are useful candidates. Details see here.

Greetings,

Michael
User avatar
AndyH
Vic 20 Afficionado
Posts: 364
Joined: Thu Jun 17, 2004 5:51 am
Website: https://www.hewco.uk
Location: UK
Occupation: Developer

Re: Question on use of zero page addresses

Post by AndyH »

Many thanks - answering everything I need and puts my mind at rest. Loads to read up on.

I did trigger a flashing cursor in the top left by setting the kernal space to 0!
--
AndyH
HEWCO | Vic 20 blog
Post Reply