User manual

mikroBasic PRO for dsPIC30/33 and PIC24
MikroElektronika
173
Memory Type Qualiers
In addition to the standard storage qualiers(const, volatile) the compiler introduces storage qualiers of near
and far.
Near Memory Qualier
1. Data Memory Objects
The qualier near is used to denote that a variable is allocated in near data space (the rst 8 kB of Data
memory). Such variables can sometimes be accessed more efciently than variables not allocated (or not
known to be allocated) in near data space.
If variables are allocated in the near data section, the compiler is often able to generate better (more
compact) code than if the variables are not allocated in the near data section.
2. Program Memory Objects
The qualier near is used to denote that a constant is allocated in the default program memory page
(32kB segment of program memory). Default program memory page is the one with most free space and
is set by the compiler by analyzing program memory pages.
This qualier is set as default by the compiler, if no other qualier is used.
Far Memory Qualier
1 Data Memory Objects
The qualier far is used to denote that a variable will not be in near data space (i.e. the variable can be
located anywhere in data memory). This qualier is set as default by the compiler, if no other qualier is
used.
2. Program Memory Objects
The qualier far is used to denote that a constant can be allocated anywhere in the program memory, in
the page pointed to by PSVPAG register.
Location of object based on memory qualiers:
Qualier/Memory Data Memory Program Memory
near
First 8 kB of RAM In default page
far
Anywhere in RAM In page pointed to PSVPAG register
Example:
dim i as char ‘ far memory qualier is set, variable i can allocated somewhere in data memory
dim j as char near near memory qualier is set, variable j will be allocated in the
rst 8kB of data memory
const k as longint = 10000 ‘ near memory qualier is set, constant k will be allocated
in the default memory page
Related topics: dsPIC Memory Organization, dsPIC Memory Type Speciers