Date : Fri, 16 Dec 2011 11:25:08 +0000 (WET)
From : BBCMICRO@... (Peter Coghlan)
Subject: 32016 + 32082
>
>> At the BASIC command prompt, the stack is usually at about &FC.
>
>That's *it*? The entire MOS and such takes only *three* bytes of stack?!?
>
After power on / break initialisation, the MOS doesn't take up any stack at all
except when it is processing a MOS call or command or an interrupt.
While sitting at command prompt, we are likely to be waiting for a keypress
somewhere within OSRDCH, in turn having been called from OSWORD 0, which
suggests that there should be at least two return addresses on the stack, plus
maybe a few other bits and pieces saved on entry to the MOS calls etc, ie a
bit more than three bytes, but not too much.
At break, as soon as everything is initialised, the MOS turns over control
to the selected language. The current language is what normally runs and the
language does not have to worry about returning to the MOS so it doesn't have
to keep anything that was on the stack when it was started up and standard
procedure is for the language to initialise the stack pointer to &FF.
BBC BASIC uses the 6502 stack like any 6502 program but to avoid overflowing
it when processing (for example) recursive procedure or function calls, BASIC
saves the contents of the 6502 stack on its own larger stack and reinitialises
the 6502 stack pointer each time it processes a procedure or function,
restoring it on return.
Regards,
Peter Coghlan.