Zero Page addressing and BASIC

Basic and Machine Language

Moderator: Moderators

Post Reply
SparkyNZ
Vic 20 Enthusiast
Posts: 153
Joined: Tue Jan 18, 2011 2:23 am

Zero Page addressing and BASIC

Post by SparkyNZ »

Is it safe to use the shorter zero page 6502 instruction from a machine code routine called from BASIC?

I think the C64 has special "bank" treatment with address $00.. Does the Vic?

So say for example, I make a SYS call and jump into my routine, can I safely start writing/reading any addresses from $00-FF or should I be pushing some onto the stack and retrieving them when I'm done? Perhaps there is a safe range I can use?
User avatar
Wilson
Vic 20 Enthusiast
Posts: 190
Joined: Mon Sep 28, 2009 7:19 am
Location: Brooklyn, NY

Re: Zero Page addressing and BASIC

Post by Wilson »

The "bank" behavior you're referring to is a feature of the 6510. There are no software considerations needed on the plain 6502 for the $00-$01 addresses.
Some (most even) of the zero-page is used by the KERNAL and BASIC. A lot of it can nonetheless be used if you know what you're doing and are sure it won't conflict with the BASIC program. The $FB-$FE range is free if you only need a couple pointers.
SparkyNZ
Vic 20 Enthusiast
Posts: 153
Joined: Tue Jan 18, 2011 2:23 am

Re: Zero Page addressing and BASIC

Post by SparkyNZ »

Wilson wrote: Fri Sep 29, 2023 7:28 pm The "bank" behavior you're referring to is a feature of the 6510. There are no software considerations needed on the plain 6502 for the $00-$01 addresses.
Some (most even) of the zero-page is used by the KERNAL and BASIC. A lot of it can nonetheless be used if you know what you're doing and are sure it won't conflict with the BASIC program. The $FB-$FE range is free if you only need a couple pointers.
Thank you. I'm only using BASIC for the SYS command to start my program to be honest. Seems to be OK so far.. I've worked my way backwards towards $f0
User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: Zero Page addressing and BASIC

Post by Mike »

More details about zero page usage to be found in those threads:
Greetings,

Michael
Post Reply