Direct Addressing

When addressing memory directly, the Effective Address is calculated using two pieces of information:

  1. The run-time content of the Bank Select Register (BSR)
  2. The executing instruction's 7-bit operand
image1.svg
image2.svg

Assembly language programmers must ensure that the BSR is loaded with the proper bank number for the desired memory location. The assembly language instruction MOVLB is the instruction specifically provided by MPASM for loading the BSR.

The assembler DIRECTIVE banksel can also be used to load the BSR. At compile time, the banksel determines the bank of the desired memory location, then configures the MOVLB instruction appropriately for the bank.

Example code:

The following code shows two methods of loading the BSR in assembly language. The first example uses banksel to automatically calculate the BSR. The second example manually calculates the appropriate BSR value.

Users of the MPLAB® XC8 C compiler do not need to be directly concerned with banking. Assignment statements will result in the compiler and linker calculating and inserting the needed MOLVB instructions.

© 2024 Microchip Technology, Inc.
Notice: ARM and Cortex are the registered trademarks of ARM Limited in the EU and other countries.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.