piclist 2008\07\08\074015a >
Thread: Code packing
face picon face BY : email (remove spam text)(Olin Lathrop)

David Meiklejohn wrote:
> macro   enable_ee_read

Should be:

enable_ee_read macro

>          banksel eecon1
>          bsf     eecon1, rd
> endm
> But then you'd need be aware that, whenever you use 'enable_ee_read',
> you're potentially changing the bank selection.

This is one of the things my environment handles nicely.  The DBANKIF macro
has the same syntax as BANKSEL, but it only makes the minimum changes to get
from the bank you're in to the bank you want to be in.  It works with the
assembly time bank tracking mechanism.

Since you've got a mechanism for setting banks that is free unless the bank
actually needs to be changed, you can now feel better about using it
liberally.  I would write the macro like:

eeread   macro
        dbankif  eecon1
        bsf      eecon1, rd

If following code cared about the bank setting, it would use a DBANKIF.  If
that happened to select the same bank EECON1 was in, then no code would get
generated.  In fact, the EEREAD macro would only be a single instruction if
EECON1 was known to be in unbanked memory (like on a PIC 18), or the bank
was already known to be set to the bank EECON1 is in.

Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products
(978) 742-9014.  Gold level PIC consultants since 2000.
<018401c8e0ef$b4a3d320$0300a8c0@main> 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) Code packing

month overview.

new search...