Paging and Banking Issues
In many cases, RAM allocation will span multiple banks, and executable code will span multiple pages. In these cases, it is necessary to perform proper bank and page set-up to properly access the labels. However, since the absolute addresses of these variable and address labels are not known at assembly time, it is not always possible to place the proper code in the source file. For these situations, two new directives,
BANKSEL
andPAGESEL
have been added. These directives instruct the linker to generate the correct bank or page selecting code for a specified label. An example of how code should be converted is shown below.Absolute Code
LIST P=12C509
#include "P12C509.INC"
Varl EQU H'10'
Var2 EQU H'30'
...
MOVLW InitialValue
BCF FSR, 5
MOVWF Varl
BSF FSR, 5
MOVWF Var2
BSF STATUS, PA0
CALL Subroutine
...
Subroutine CLRW ;In Page 1
...
RETLW 0
Relocatable Code
LIST P=12C509
#include "P12C509.INC"
UDATA
Varl RES 1
Var2 RES 1
...
CODE
MOVLW InitialValue
BANKSEL Varl
MOVWF Varl
BANKSEL Var2
MOVWF Var2
PAGESEL Subroutine
CALL Subroutine
...
Subroutine CLRW
...
RETLW 0
Microchip Technology Inc. Microchip's Web Site Voice: (480) 792-7200 Fax: (480) 899-9210 Microchip's E-mail Address |