BANKISEL Example

MPASM Assembler

BANKISEL Example

Directives highlighted in this example are:

  • bankisel

Program Functional Description

This program demonstrates the utility of the bankisel directive. This directive generates the appropriate code to set/clear the IRP bit of the STATUS register for an indirect access.

Commented Code Listing

list p=16f877 ;Select the device.

#include <p16f877.inc> ;Include standard header file

;for the selected device.

group1 udata H'20' ;group1 data stored at locations

;starting at H'20'(IRP bit 0).

group1_var1 res 1 ;group1_var1 located at H'20'.

group1_var2 res 1 ;group1_var2 located at H'21'.

group2 udata H'120' ;group2 data stored at locations

;starting at H'120'(IRP bit 1).

group2_var1 res 1 ;group2_var1 located at H'120'.

group2_var2 res 1 ;group2_var2 located at H'121'.

RST CODE H'0' ;The code section named RST

;is placed at H'0'. The

;instruction 'goto start' is

;placed in code section RST

goto start ;Jumps to the location labelled

;'start'.

INTRT CODE H'4' ;The code section named INTRT is

;placed at H'4'.The instruction

;'goto service_int' is placed in

;code section INTRT.

goto service_int ;Jumps to the location labelled

;'service_int'.

PGM CODE ;This is the beginning of the

;code section named PGM. It is a

;relocatable code section since

;no absolute address is given

;along with directive 'CODE'.

start

movlw H'20' ;This part of the code addresses

movwf FSR ;variables group1_var1 &

bankisel group1_var1 ;group1_var2 indirectly.

clrf INDF

incf FSR,F

clrf INDF

movwf FSR

bankisel group2_var1

clrf INDF

incf FSR,F

clrf INDF

goto $

service_int

retfie

end


Microchip Technology Inc.
Microchip's Web Site
Voice: (480) 792-7200
Fax: (480) 899-9210
Microchip's E-mail Address
PreviousNext