UDATA_SHR Example

MPASM Assembler

UDATA_SHR Example

Directives highlighted in this example for PIC16FXXX devices are:

  • udata_shr

Program Functional Description

This program demonstrates the utility of the udata_shr directive, which is used when generating an object file. This directive declares the beginning of a section of shared uninitialized data. This directive is used to declare variables that are allocated in RAM that is shared across all RAM banks (i.e. unbanked RAM.)

Commented Code Listing

list p=16f877 ;Select the device.

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

;for the selected device.

shared_data udata_shr ;Declares the beginning of a data

;section named 'shared data',

var res 1 ;which is shared by all banks.

;'var' is the location which can

;be accessed irrespective of

;banksel bits.

bank0_var udata 0X20 ;Declares beginning of a data

var0 res 1 ;section named 'bank0_var',

;which is in bank0. var0 is

;allocated the address 0x20.

bank1_var udata 0xa0 ;Declares beginning of a data

var1 res 1 ;section named 'bank1_var',

;which is in bank1. var1 is

;allocated the addess 0xa0

bank2_var udata 0x120 ;Declares beginning of a data

var2 res 1 ;section named 'bank2_var',

;which is in bank2. var2 is

;allocated the addess 0x120

bank3_var udata 0x1a0 ;Declares beginning of a data

var3 res 1 ;section named 'bank3_var',

;which is in bank3. var3 is

;allocated the addess 0x1a0

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 sectionINTRT.

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

start ;with directive 'CODE'.

banksel var0 ;Select bank0.

movlw H'00'

movwf var ;var is accessible from bank0.

banksel var1 ;Select bank1.

movlw H'01'

movwf var ;var is accessible from bank1

;also.

banksel var2 ;Select bank2.

movlw H'02'

movwf var ;var is accessible from bank2

;also.

banksel var3 ;Select bank3.

movlw H'03'

movwf var ;var is accessible from bank3

;also.

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