Example

A simple example illustrates placing data in the extended memory, reading a data from the extended memory and storing the data address to a linear pointer.

Listing: Placing Data in the Linear Memory


...
#include <mmu_lda.h>

#pragma CONST_SEG __LINEAR_SEG DATA_LINEAR

const int x=2;

#pragma CONST_SEG DEFAULT

int y;

void f() { 

  /* y = x; */

  __LOAD_LAP_ADDRESS(x);

  __LOAD_WORD_INC(y);

}

In PRM file, place segment DATA_LINEAR at the correct address.

Note: Objects that are accessed using linear addressing can still be placed in paged segments, but this addressing should be used when objects (for example. variables, arrays) span multiple pages.
Note: Make sure not to define the same memory area both as paged and linear.
  //PRM file

  
  SEGMENTS

  
  ...

  
  //PPAGE_5     =  READ_ONLY    0x058000 TO 0x05BFFF;

  
  ...

  
  ROM_LINEAR  =  READ_ONLY    0x014000'F TO 0x017FFF'F

  
  ...

  
  END

  
  PLACEMENT

  
  ...

  
  DEFAULT_ROM, PAGED_ROM     

  
     INTO PPAGE_0,PPAGE_2,PPAGE_4,/*PPAGE_5,*/
  PPAGE_6,PPAGE_7,ROM1;

  
  ...

  
  DATA_LINEAR     INTO    ROM_LINEAR;

  
  ...

  
  END

  
Note: When use linear address, a single quote ' (in C '\'') character and a F ('F') character should be added to the end of address to let the linker know it is a linear reference.