piclist 2001\01\10\015351a >
Thread: Anyone have a solid strategy for code that spans pages?
face BY : Tom Mariner email (remove spam text)

Hello Dave,

You are on the right track with the macros. On any of the Microchip devices
with multiple pages of RAM or ROM, we always use macros that state your
present address ($) and the address of the routine you wish to access, then
let the assembler figure out the proper page bits to set and / or clear.
Unfortunately with the code space, the macro has to always set and / or
clear using the the same number of instructions since it gets upset if
differing number of addresses are used. For example, if one called a routine
from the same page, no instructions would be needed, but the macro has to
generate them. Actually, in versions of the compiler long gone, the task was
easier since the assembler would make another pass through the code to see
if the addresses had been modified. Here's a crude example of something that
might work:

;Long Jump
; If on Different Pages, Do Page Set,
LJump   MACRO   AddFrom,AddTo
       IF      (AddTo>>.9) == 0
; Page 0
        BCF    STATUS,PS0
        BCF    STATUS,PS1
        IF     (AddTo>>.9) == 1
; Page 1
         BSF   STATUS,PS0
         BCF   STATUS,PS1
         IF    (AddTo>>.9) == 2
; Page 2
          BCF  STATUS,PS0
          BSF  STATUS,PS1
         IF    (AddTo>>.9) == 3
; Page 3
          BSF  STATUS,PS0
          BSF  STATUS,PS1
       errorlevel      -306
         GOTO  AddTo
       errorlevel      +306

The same type of "Bankswitch From, To" works great with the RAM since it
doesn't rely on your knowing or caring which bank the variables are in. This
method can, in fact set and clear variable numbers of bank bits (including
none) since it doesn't self modify the address space.

Hope this helps.


{Original Message removed}
<000001c07ad2$393884a0$6a8abc18@qmiguest> 7bit

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...