Post by hydrophilic on Jun 28, 2014 0:27:13 GMT
On the C128 and the CBM-II series (i.e., machines with more than 64K system RAM), chaining BASIC programs is very easy. Once a program is running, it can DLOAD another program which then start from its (the DLOADed file's) beginning, but all variables from the original program are preserved.
Program chaining on othe systems, like C64, is more tricky because the program and variables are in the same bank. In order for program chaining to work, you must ensure that newly loaded program is smaller than the original program... otherwise the newly loaded program will trash some of the variables.
I think we all know that if you don't want the old variables, it is easy to use CLR or RUN command.
So in other words, on C128 (and CBM-II) you can DLOAD a program and not worry about loosing variables... BUT ONLY IN PROGRAM MODE!
I was quite suprised to learn recently, while debugging a BASIC program on the C128, that all BASIC variables are erased when you DLOAD a program in direct mode. I was suprised because it is not needed on the C128 (there is no conflict with program storage and variable storage) and more suprised that I had never noticed this before and never read about it. Well that last part could be my failing memory
So loading a program in direct mode on other machines clears variables because they need it (in general). But the C128 does it because it is a bug! I'm pretty sure they just re-used the same BASIC implementation on the C128 from older machines. Still need to check the CBM-II with VICE, but I suspect it is the same.
All I can say is this is a bug (I don't see how you could call it a feature) which makes debugging multi-load programs more trouble than it needs to be.
Program chaining on othe systems, like C64, is more tricky because the program and variables are in the same bank. In order for program chaining to work, you must ensure that newly loaded program is smaller than the original program... otherwise the newly loaded program will trash some of the variables.
I think we all know that if you don't want the old variables, it is easy to use CLR or RUN command.
So in other words, on C128 (and CBM-II) you can DLOAD a program and not worry about loosing variables... BUT ONLY IN PROGRAM MODE!
I was quite suprised to learn recently, while debugging a BASIC program on the C128, that all BASIC variables are erased when you DLOAD a program in direct mode. I was suprised because it is not needed on the C128 (there is no conflict with program storage and variable storage) and more suprised that I had never noticed this before and never read about it. Well that last part could be my failing memory
So loading a program in direct mode on other machines clears variables because they need it (in general). But the C128 does it because it is a bug! I'm pretty sure they just re-used the same BASIC implementation on the C128 from older machines. Still need to check the CBM-II with VICE, but I suspect it is the same.
All I can say is this is a bug (I don't see how you could call it a feature) which makes debugging multi-load programs more trouble than it needs to be.