Page Switching Problem
David Cary email (remove spam text)
Dear Andrew Warren and David Harris,
"David P. Harris" <TELUS.NET> on 2001-04-17 07:34:25 PM asked dpharris
> Why particularly do we need to restore the page bits?
> I thought these are only important when: doing a long call, long goto, or
> otherwise manipulatiing the PCLATH register, say when doing a long table
> look up?
If you don't restore the page bits after a LCALL, this annoying problem happens:
; warning: untested code.
lcall subroutine_on_another page
; ....... (normal, straight-line code)
Gotcha ! that final goto jumps some random location on that other page, rather
than back up to next_iteration.
Change that "lcall" to a "fcall" and then it works as expected (that
subroutine_on_another_page gets called 8 times).
Andrew Warren <CYPRESS.COM> on 2001-04-18 07:20:35 PM noted: aiw
> MPASM's LCALL pseudo-op doesn't restore the page bits after the
> subroutine return.
Currently I have lots of "fcall" scattered through my code
fcall macro subroutine_name
; just in case we do *local* calls or gotos before the next fcall.
This macro lets me call subroutines in any page from any page,
and restores the page bits after return so that I can do "short" call and goto.
(LGOTO works fine as-is).
I see that lots of people have tried to make similar macros that automatically
assemble a short call when possible, but I've never seen anyone succeed.
Using MPASM 02.61.
-- David Cary
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics
See also: www.piclist.com/techref/power/priswitch.htm?key=switching
You must be a member of the
piclist mailing list
(not only a www.piclist.com member) to post to the