piclist 2001\01\09\111402a >
Thread: Anyone have a solid strategy for code that spans pages?
www.piclist.com/techref/microchip/devices.htm?key=pic
flavicon
face BY : mike@whitewing.co.uk



On Tue, 9 Jan 2001 22:44:06 +1100, you wrote:

{Quote hidden}

Been there.... This particular problem, of subroutines  called from
lots of places, is easily solved efficiently - for each page-1 routine
have a page-select and goto to it in page zero. adds a minor time
penalty but space is usually more important.
After the first call of a subroutine, this adds no page-swap code
overhead for subsequent calls, so is 'profitable' for any routines
called more then once.

It can also be useful for all page 1 subroutines to exit via a common
point that clears the page 1 bit first. This avoids the page 0 call
having to worry about whether the routine is in page 0 or 1 - things
tend to move about as code grows & changes...!

e.g. page 0 : ..
call p0sub1
...
call p0sub1
....


p0sub1   bsf pclath,page1bit
errorlevel -306 ; supress warning, you know what you're doing...
goto p1sub1
errorlevel +306 ; re-enable warning to catch real errors.

page 1 :

p1sub1
....
goto p1exit



p1exit
bcf pclath,page1bit
return


Having a consistent naming convention is important to avoid major
debug headaches.

Obviously it helps a lot to group subroutines by page to reduce the
number of page-bit swaps, e.g. all subs called by p1sub1 above live in
page 1.

For routines called only once, returning via the 'clear page bit' exit
point is still useful as the calling code doesn't need to clear it.

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


<0e7m5t8m0ud8q8cjeer38rmokh3kj952jc@4ax.com> quoted-printable

In reply to: <000301c07a31$78dcdb20$9cbb2acb@ranma>
See also: www.piclist.com/techref/microchip/devices.htm?key=pic
Reply You must be a member of the piclist mailing list (not only a www.piclist.com member) to post to the piclist. This form requires JavaScript and a browser/email client that can handle form mailto: posts.
Subject (change) Anyone have a solid strategy for code that spans pages?

month overview.

new search...