I post here as it is more related to Basic anyway.
Is there a process to diagnose Out of Memory problems in Basic ?
My goal would be to put a breakpoint with Oricutron in the ROM where it detects the problem and then check the different memory zones to find out if it's a stack problem, an array problem or a string problem (or something else I forget).
Would there be something like this in a document somewhere ?
Debugging Out of Memorry errors ?
Re: Debugging Out of Memorry errors ?
IMO this can be stack issue or modifications in zero page which lead to BASIC error.
Can you post short piece of code to reproduce the problem?
Can you post short piece of code to reproduce the problem?
- Hialmar
- Flight Lieutenant
- Posts: 349
- Joined: Tue Mar 04, 2014 11:25 am
- Location: Toulouse, France
- Contact:
Re: Debugging Out of Memorry errors ?
I had something like that before but I'm not sure if it is the same problem.
I'll try this if I can't find a solution.
Maybe copying the page 0 and the stack somewhere before switching programs and then restoring them could be enough ?
Geoff Phillips says in his book that in order to switch from one Basic program to another ideally I would need to save the first 1500 bytes and restore them. The problem is that I'm not sure I would have enough RAM after that for my programs.
I'll try this if I can't find a solution.
Maybe copying the page 0 and the stack somewhere before switching programs and then restoring them could be enough ?
Geoff Phillips says in his book that in order to switch from one Basic program to another ideally I would need to save the first 1500 bytes and restore them. The problem is that I'm not sure I would have enough RAM after that for my programs.
Re: Debugging Out of Memorry errors ?
In common copying 1500 bytes is OK as size, but this includes the IO space $03xx where reading and writing can lead to unexpected problems. I think more correctly is to store and restore pages 0,1,2 and maybe page 4 (to preserve DOS if needed).
Don't forget to set the stack pointer and CPU flags too .
Don't forget to set the stack pointer and CPU flags too .
- Hialmar
- Flight Lieutenant
- Posts: 349
- Joined: Tue Mar 04, 2014 11:25 am
- Location: Toulouse, France
- Contact:
Re: Debugging Out of Memorry errors ?
I will look at the book again to find out which 1500 bytes to save.
As you say they can't be continuous in memory.
Here is what he says in the part about multitasking 2 Basic programs:
As you say they can't be continuous in memory.
Here is what he says in the part about multitasking 2 Basic programs:
Got it, he says 1500 as there are two programs each with its 3 pages of 256 bytes.The major problem with switching between two BASIC programs is that they
need their own versions of page 0, stack, and page 2 memory. Since copying
1500 bytes of data is a time-consuming task, even for machine code, we can
only afford to interchange the running of the two programs about every twelfth of
a second. Any less than that and we would be spending too little time on the
actual programs; any more and the interchange would become more noticeable.