RAM Allocation

MPASM Assembler

RAM Allocation

RAM space must be allocated in a data section. Five types of data sections are available:

  • UDATA - Uninitialized data. This is the most common type of data section. Locations reserved in this section are not initialized and can be accessed only by the labels defined in this section or by indirect accesses.
  • UDATA_ACS - Uninitialized access data. This data section is used for variables that will be placed in access RAM of PIC18CXXX devices. Access RAM is used as quick data access for specified instructions.
  • UDATA_OVR - Uninitialized overlaid data. This data section is used for variables that can be declared at the same address as other variables in the same module or in other linked modules. A typical use of this sec tion is for temporary variables.
  • UDATA_SHR - Uninitialized shared data. This data section is used for variables that will be placed in RAM that is unbanked or shared across all banks.
  • IDATA - Initialized data. The linker will generate a lookup table that can be used to initialize the variables in this section to the specified values. The locations reserved by this section can be accessed only by the labels defined in this section or by indirect accesses.
  • The following example shows how a data declaration might be created.

    Absolute Code

    CBLOCK 0x20

    InputGain, OutputGain ;Control loop gains

    HistoryVector ;Must be initialized to 0

    Templ, Temp2, Temp3 ;Used for internal calculations

    ENDC

    Relocatable Code

    IDATA

    HistoryVector DB 0

    UDATA

    InputGain RES 1

    OutputGain RES 1

    UDATA_OVR

    Templ RES 1

    Temp2 RES 1

    Temp3 RES 1

    If necessary, the location of the section may be fixed in memory by supplying the optional address parameter. If more than one of each section type is specified, each section must have a unique name. If a name is not provided, the default section names are: .idata, .udata, .udata_acs, .udata_shr, and .udata_ovr.

    When defining initialized data in an IDATA section, the directives DB, DW, and DATA can be used. DB will define successive bytes of data memory. DW and DATA will define successive words of data memory in low-byte/high-byte order. The following example shows how data will be initialized.

    Relocatable Code

    00001 LIST p=17C44

    00002 IDATA

    0000 01 02 03 00003 Bytes DB 1,2,3

    0003 34 12 78 56 00004 Words DW H'1234',H'5678'

    0007 41 42 43 00 00005 String DB "ABC", 0


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