Keil™, An ARM® Company

Cx51 User's Guide

VARBANKING Compiler Directive

Abbreviation VB
Arguments None: Do not change interrupt code.
(1): Save address extension SFR in interrupt code.
Default The standard C51 library is used.
µVision Options — Target — 'far' memory type support.
Options — Target — save address extension SFR in interrupts.
Description 

The VARBANKING directive instructs the compiler to use alternate library routines that support far memory for classic 8051 devices.

To use far memory, you must configure the memory access functions and an address extension SFR in XBANKING.A51 and include this file in your project. As alternative, set ?B_VARBANKING in the L51_BANK.A51 bank switch configuration file.

VARBANKING(1) adds code to interrupt service routines to save and restore the address extension SFR. Specifically, the following instructions are inserted at the beginning of an interrupt function:

PUSH   ?C?XPAGE1SFR
MOV    ?C?XPAGE1SFR,?C?XPAGE1RST

The symbol ?C?XPAGE1SFR is typically defined in file XBANKING.A51 and specifies the memory location of the address extension SFR. The initial value of this SFR is specified by the ?C?XPAGE1RST symbol. Note that not every version of the XBANKING.A51 requires to save and restore an address extension SFR and therefore sometimes the symbol ?C?XPAGE1SFR does not exist.

The examples in \KEIL\C51\EXAMPLES\FARMEMORY\ show how to use the C51 far memory type on classic 8051 devices.

Note

  • Only interrupt functions in C modules that are translated with the VARBANKING (1) directive save and restore the address extension SFR. If your application contains interrupt routines from assembly modules or libraries you must check them manually.
Example 
C51 SAMPLE.C VARBANKING

C51 MYFILE.C VARBANKING (1)