<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>
Date   : Thu, 23 May 1996 11:56:57 +0100
From   : angus@...
Subject: Writing sideways ROM software

Steven Flintham writes:
>I'm writing a sideways ROM and I'm having trouble with using zero page.
>Inevitably my code needs a few zero page locations to work with and I
>don't know where I can use which is 'safe'. Obviously you can mess
>around stacking the locations you intend to use first, but this is
>extremely messy, especially when you can have more than one exit from a
>routine (such as when an error occurs).

I keep meaning to look at my advanced user guide to check the locations, sorry,
I forgot again.

>I've got the (original, I think) BBC Advanced User Guide but it doesn't
>really help. The only thing which looks a bit promising is that (from
>memory) there are a few zero page locations allocated for 'operating
>system commands' or some such. Am I allowed to use those, and if so,
>can I use them on any service call or only on service call 4?

I've not had any trouble using these locations for scratch space, so long as
you don't rely on their values staying the same over any other (or nested) OS
call. The other good parts to use are the Econet locations (if you're not using
an Econet).

>Alternatively, can anyone suggest either suitable zero page locations
>or some 'obvious when you know how' trick to avoid corrupting zero page
>without all that stacking and unstacking.

Stacking and unstacking is quite easy, if you use TSX and copy to/from $101,X.
Even with multiple return points, it's quite easy. I'll try and remember to
bring in the code to the routine I use, what it does is to save the registers,
replace the return address with the address of a routine that restores the
registers, and returns to the original caller. You can then just do
"JSR push_registers" at the entry point to your call, and RTS at the end. The
same principle can be extended to save zero-page locations to the stack too.

a.
--
Angus Duggan, Harlequin Ltd., Barrington Hall, | INET: angus@...            
Barrington, Cambridge CB2 5RG, U.K.            | FAX: +44(0)1223 873873
<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>