Jump to content
Sign in to follow this  

Force Var To Be In Same Bank

Recommended Posts

I might have missed it, but I don't see a way to force a var to be in the same bank as another var. "@ address" can be used to place a var at a specific address, but that's not what I need; I just need it to be in the same bank as another var.


For example, if I have some code that is accessing the serial port on a PIC16F1827, those registers are in Bank 3, so I would like to put my variables in bank 3 to avoid excessive bank selects. However, on a PIC16F688, those registers are in bank 0. This leads to very awkward code like this:

#ifdef _PIC16F1827
#define ADDRESS  0x180
#ifdef _PIC16F688
 #define ADDRESS  0x20
 unsigned char myvar @ADDRESS;


This code is harder to maintain or understand for others, and takes longer to write. The other problem with this example code is that I have to manually manage all the addresses myself. This gets unwieldy when there are many variables that need to be placed this way (basically, it negates the automatic address assignment job of the compiler).


It would be a lot nicer to just be able to write code like:

 unsigned char myvar @BankOf(rcsta);

or maybe use a pragma:

#pragma bank <other register>
 unsigned char myvar;
#pragman bank any

or something like that.


So, I would like to request a "same bank as (other var)" address assignement feature.





Share this post

Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Create New...