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

Assembly language programmers must ensure that the BSR (Bank Select Register) 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 banksel determines the bank of the desired memory location, then configures the MOVLB instruction appropriately for the bank.

Example code:

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

bsr-example.png

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.

20th Annual
Microchip MASTERs Conference 2016
Register now - Deadline: July 29

JW Marriott Desert Ridge Resort-Phoenix, AZ

© 2016 Microchip Technology, Inc.
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.