IDATA Example

MPASM Assembler

IDATA Example

Directives highlighted in this example are:

  • idata

Program Functional Description

The directive idata is used when generating an object file. It reserves RAM locations for variables and directs the linker to generate a lookup table that may be used to initialize the variables specified in this section. The Starting Address of the lookup table can be obtained from the Map (.map) file.

Commented Code Listing

list p=16f877 ;Select the device.

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

;for the selected device.

group1 IDATA 0x20 ;Initialized data at location

;20h.

group1_var1 res 1 ;group1_var1 located at 0x20,

;initialized with 0.

group1_var2 res 1 ;group1_var2 located at 0x21,

;initialized with 0.

group2 IDATA ;Declaration of group2 data. The

;addresses for variables under

;this data section are allocated

;automatically by the linker.

group2_var1 db 1,2,3,4 ;4 bytes in RAM are reserved.

group2_var2 dw H'1234 ';1 word in RAM is reserved.

RST CODE 0x0 ;The code section named RST is

;placed at H'0'.

;Following instruction 'goto

;start' is placed in code

;section RST.

goto start ;Jumps to the location labelled

;'start'.

PGM CODE ;Code section named PGM is

;declared. It is a relocatable

;code section since no absolute

;address is specified.

start

;

;

end


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