| old | Alternate Products | ||
|---|---|---|---|
| PIC16F84-1998 | pic18f26q10 | ||
| PIC16F877a-2001 | PIC16F18877 |
-
PIC-AS
MPLAB X v5.40+ and XC8 v2.20+
bankmask - macro
It is recommended that you mask all addresses used by PIC file register instructions whose operand represents a bank offset.
#include <xc.inc>
copy:
BANKSEL (src) ;select the bank of src
movf BANKMASK(src),w ;move from src, masking the address
BANKSEL (dst) ;select the bank of dst
movwf BANKMASK(dst) ;move to dst, masking the address
The BANKMASK() macro, can perform the mask using the correct values, based on the selected device.
banksel - Pseudo-instructions
The file registers of the pic are held in banks, some are shared across all banks and some program data can also be shared across all banks but this is obviously wasteful of memory so it’s limited to select registers and shared data.
Special function registers, SFR’s are used to control, configure and check the pic’s status.
These tend to be on different banks to the programs variables so you need to change banks or your program will be accessing the wrong bank.
This is where the ‘banksel’ instruction comes in. It makes sure you are addressing the correct memory bank.
When to use banksel
- first access of any UDATA section variable
- first access of register after a subroutine call/external module
- when accessing a banked special function register
- after having accessed a banked SFR(special function register)
When to don’t need to use banksel
- after first access to a UDATA variable other UDATA variables are in the same bank
- UDATA_SHR variables are available on any bank
- accessing Non-banked SFR’s like STATUS etc.. can be done from any bank
Ref
- MPASM to MPLAB XC8 PIC Assembler Migration Guide 50002973A
- MPLAB XC8 PIC Assembler User’s Guide 50002974A
- MPLAB-XC8-PIC-Assembler-User-Guide-50002974
- MPLAB XC8 PIC Assembler User’s Guide for Embedded Engineers
- MPASM to MPLAB XC8 PIC Assembler
- When to use banksel
- There is no make executable in the path. - MPLABX v5.35
- 4.43 list - Listing Options
- 4.8.5 Simple Example - MPASM Assembler User’s Guide
- What is the meaning of Microchip’s acronym TRIS for data direction registers?
- 2.4 Ports
- MPASM Removed? !!!