Picomite/PicoMiteVGA V5.07.05 release candidates


Author Message
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4336
Posted: 02:14pm 01 Oct 2022      

r.e. Chess on the Picomite, assuming its memory allocation works in a similar way to MMBasic for DOS (and thus MMB4L which is what I am familiar with) and assuming I am not talking out of my arse then statistics reported by the MEMORY command are irrelevant. MMBasic has a fixed number of variables slots plus a fixed sized heap (from which the additional memory for strings, arrays and some internal scratch buffers are allocated), if these were being exhausted I would expect an MMBasic error message.

What instead I think is happening is that you have too many nested MMBasic SUB/FUNCTION calls. The interpreter implements this by recursion allocating more and more C variables on the Pico stack until it overflows (apparently into the area of RAM that the PicoMite sets aside for program storage). This would be difficult for the firmware to protect against and if possible at all would come with a significant performance penalty.

Assuming the correctness of the above then in order to "fix" this you have to reduce the maximum depth of recursion in the program: reduce the depth of its searches, inline functions, use iterative rather than recursive algorithms or move the recursive algorithms into CSUBs where you have explicit control over stack allocation rather than the MMBasic interpreter.

Best wishes,

Tom
Edited 2022-10-02 00:17 by thwill