AgonConsole8 / agon-mos

Official AGON QUARK Firmware for Console8: eZ80 MOS
MIT License
25 stars 10 forks source link

Malloc issues with adl applications (bbcbasic24) #47

Closed stevesims closed 5 months ago

stevesims commented 5 months ago

With the 2.2.0 release it was found that *dir did not work on a freshly started system that booted straight into ADL BASIC.

Further investigation shows that this is an issue with the use of malloc - it seems that malloc will fail, and since DIR had no fallback it would just fail completely.

A fix has been made as part of #46 to allow dir to work in the event of the malloc failing, however this does not address the underlying issue. malloc still fails, this is just being detected, and a fallback to a different non-sorted, and non-coloured, directory display is used instead.

Another piece of functionality that does not work from inside of BASIC24 is the *hotkey command, as that too uses malloc.

Curiously, leaving BASIC via *bye, doing a *dir, and then loading up BASIC again and running it resolves the issue, and after doing so the new version of *dir that shows a sorted directory with colours will work.

stevesims commented 5 months ago

we have a solution to this released as part of 2.2.2

the fix was to perform a malloc(6502); during startup to grab a chunk of memory, which is then immediately freed. including that seems to allow later calls to malloc work inside MOS even when an ADL application has been started which may have changed the stack pointer on the processor