As I dive in and out of the BASIC interpreter and Kernel of the Commodore 64, I thought to shed some light on an error that I was seeing a lot back in the day when I was a teenager: after loading some data file e.g. at $C000-$CFFF and then trying to make any change to the BASIC program in memory I would always get the “?OUT OF MEMORY ERROR” message.
Why is that? Well, when in direct mode the LOAD command sets the pointer to the start of variables for the BASIC interpreter to the end address+1 of the file that was just loaded, even when the secondary address is odd.
Is that correct or not? Well, that depends on whether the LOAD command is understood to only load BASIC programs or also data files without a BASIC program to execute and use such data. From the “Programmer’s reference guide”:
The LOAD statement reads the contents of a program file from tape or disk into memory. […] If LOAD is executed from within a program, the program is RUN. This means that you can use LOAD to “chain” several programs together. None of the variables are cleared during a chain operation.
That should make things clear 🙂