<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>
Date   : Fri, 26 Dec 2008 22:18:48 +0100
From   : kortink@... (John Kortink)
Subject: Using stack page for temp vars

On Fri, 26 Dec 2008 17:26:20 +0000, Phill Harvey-Smith wrote:

>John Kortink wrote:
>> On Fri, 26 Dec 2008 12:45:08 +0000, Phill Harvey-Smith wrote:
>>> I have thought of using the bottom of the stack page starting at &100, 
>>> for such a purpose, as tracing my code in the mess debugger the stack 
>>> pointer always seems to be pretty near the top in the &1Ex area, so as 
>>> long as I don't use too much stack they should never get overwritten.
>> 
>> None of page 1 should be considered free for (ab)use.
>> All of it is stack space. And potentially in use, even
>> unexpectedly (e.g. from interrupt routines).
>
>Technically I suppose that is true, but Acorn does this in their 1770 
>DFS code, acording to setting watchpoints in mess, also the Advanced 
>user guide seems to say that this is done also, on page 272, so I guess 
>Acorn thought it low enough risk to do this.

It's still risk. Needless risk as well. And I
wouldn't suggest that Acorn, being Acorn, was
therefore always following best practices.

>> If you need memory, allocate it on the stack (lower stack
>> pointer, use the claimed bytes, restore stack pointer).
>
>Yeah I am doing this for the OSGBPB control block and storing the low 
>byte of it's address in the &A8-&AF reigon, but doing this for evey 
>variable is a right royal pain, with only 3 8 bit regs to play with....

Yes, but managing it anyway eventually makes for
better code, and probably improves your coding
skills as well.

I used a lot of low page 1 locations in my utility
ROM Procyon, which I can forgive myself somewhat
since it was written 24 years ago, but it's been
a pretty regular source of problems ever since.


John Kortink

-- 

Email    : kortink@...         
Homepage : http://www.inter.nl.net/users/J.Kortink

GoMMC, the ultimate BBC B/Master/Electron storage system :
http://web.inter.nl.net/users/J.Kortink/home/hardware/gommc
<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>