"Free ZP" which ones?

Basic and Machine Language

Moderator: Moderators

Post Reply
heaven6502
Vic 20 Drifter
Posts: 29
Joined: Sat Jan 26, 2013 3:30 pm

"Free ZP" which ones?

Post by heaven6502 »

coming from Atari 800 and C64 I am used to switch off OS completly and having the ZP "free".

on the VIC20 I can not do this but using the IRQs mainly so just to be sure. what are the ZPs which are really free? :)
User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: "Free ZP" which ones?

Post by Mike »

heaven6502 wrote:what are the ZPs which are really free? :)
Just $FB..$FE, actually.

...

You find more details in this post of mine. :)
User avatar
srowe
Vic 20 Scientist
Posts: 1340
Joined: Mon Jun 16, 2014 3:19 pm

Re: "Free ZP" which ones?

Post by srowe »

heaven6502 wrote: Sun Feb 18, 2024 2:30 am coming from Atari 800 and C64 I am used to switch off OS completly and having the ZP "free".

on the VIC20 I can not do this but using the IRQs mainly so just to be sure. what are the ZPs which are really free? :)
There are very few locations that are completely unused
  • $2A
  • $52
  • $FB - $FE
There are plenty of locations that are only used for particular subsystems, like the cassette, which can safely used if you're not calling those routines.
User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: "Free ZP" which ones?

Post by Mike »

srowe wrote:
  • $2A
  • $52
  • $FB - $FE
I wouldn't be that sure about $2A and $52. Even though there are no direct ZP operand fields of instructions in the BASIC interpreter that point to these two addresses, these two addresses are part of temporary float values (actually their 5th byte) and might be referenced by indirect address modes.

However, when a program does not use any routines of the BASIC interpreter at all and only calls the KERNAL (i.e. might itself be regarded as 'language' in the broadest sense), then the lower ZP of $00..$8F is essentially free. Again, more details here.
heaven6502
Vic 20 Drifter
Posts: 29
Joined: Sat Jan 26, 2013 3:30 pm

Re: "Free ZP" which ones?

Post by heaven6502 »

As written... I am using it in demo so just IRQ Kernel used. 😉 Thanks will look into the other thread.
tlr
Vic 20 Nerd
Posts: 567
Joined: Mon Oct 04, 2004 10:53 am

Re: "Free ZP" which ones?

Post by tlr »

heaven6502 wrote: Sun Feb 18, 2024 9:15 am As written... I am using it in demo so just IRQ Kernel used. 😉 Thanks will look into the other thread.
If you are using only IRQ and nothing else then all of zp is free and most of the stack, just be sure to set the stack pointer to a convenient spot. $0314 and $0315 must be set up at the time of IRQ.

Code: Select all

>C:fffe  72 ff
.C:ff72  48          PHA
.C:ff73  8A          TXA
.C:ff74  48          PHA
.C:ff75  98          TYA
.C:ff76  48          PHA
.C:ff77  BA          TSX
.C:ff78  BD 04 01    LDA $0104,X   <- check for BRK flag in status word pushed to stack by the IRQ
.C:ff7b  29 10       AND #$10
.C:ff7d  F0 03       BEQ $FF82
.C:ff7f  6C 16 03    JMP ($0316)   <- called if BRK
.C:ff82  6C 14 03    JMP ($0314)   <- called if IRQ
User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: "Free ZP" which ones?

Post by Mike »

Many of the new graphics modes pioneered by tokra and me routinely use the entire ZP, stack and OS workspace (i.e. $0000..$03FF) for graphics data.

The only thing that necessitates the use of ZP are the two indirect-ZP address modes, and maybe the odd cycle saved with ZP (instead of ABS) operands. Placing significant amounts of code or data there almost always is the result of a deliberate design choice (read this as: not wanting to use a RAM expansion, insisting on the unexpanded RAM configuration instead) ... well, it's not my stuff I need to debug. ;)
Post Reply