Tonight I'd played again a little bit with the possibilities of BASIC 10 (C65 mode). This time I'd focused on the usage of various banks for the BASIC 10 variables.
Normally the variables are stored in bank 1 while the BASIC 10 text is stored in bank 0 (starts at $2000):
(just a quick drawing from me)
But I have found an address to tell the C65/MEGA65 to use another bank for the variables instead of bank 1. It's address $85 (133 dec) in C65 mode (named "var_bank" at page 3 of the current version (2020/11/09) of the "C65 memory map"). And I wanted to see how and if it works.
Let us start:
PRINT PEEK(133) shows you the current (and default) value "1" for the var_bank.
With POKE 133,4 you tell BASIC 10 that it should use bank 4 for the variables from now on.
Let us define a test variable, e.g. A$ = "TEST - BANK 4" and show it with PRINT A$. Okay, you will see: TEST - BANK 4.
Now switch back to bank 1 for var use with POKE 133,1 and let us see the variable with PRINT A$. And you get ... an empty string.
With the use of the build-in monitor we can search for the stored value of A$ in bank 4:
MONITOR and then H 40000 4FFFF 'TEST (search in complete bank 4 for the entry "TEST*").
It's found at address $7FF1 of bank 4:
If you had switch to bank 1 with POKE 133,1 you can define also a string A$, e.g. A$ = "TEST - BANK 1". If you now print the string you get a result which depends on the selected var_bank:
I wrote a simple BASIC 10 demo program to demonstrate the various bank use with bank 1, 4 and 5:
Here's a quick draw to demonstrate the relationship between the value of address $85 (133 dec) and the various bank use for the variables:
Be aware that a var_bank switch applies to all current used BASIC 10 variables. This means that you can't access a variable in e.g. bank 4 while having switched to bank 1. E.g.: Variable A$ in bank 1 is a different one than A$ in bank 4, although it has the same name! You always have to switch to the "right" bank in which your wanted variable is stored before you can access it.
I have tested it (with version "911001" of the C65 ROM) with the Xemu emulator (xmega65) and with the Nexys board, so I suppose it also works with the DevKit or a MEGA65 prototype.
I have attached the demo program as a zipped D81 image, if you want to play around for yourself.