__MAP__
 
Syntax

__MAP__   [CODE const_expression]  [CONST const_expression]  [DATA  const_expression]  [STRING  const_expression]
Description


__MAP__ tells the compiler to reserve space, by advancing the 4 pointers.   In all cases it must be a constant expression.  There is no error checking, so the user is responsible for the validity of the values. 

All of these values are byte values. For CODE sets the compiler program counter past 

CONST sets the pointer for constant strings and CONST arrays, it counts down from the end of Flash memory.

DATA sets the pointer for INTEGER and SINGLE variables.   Each increment represents 32 bits/ 4 bytes of memory.

STRING sets the pointer for arrays of BYTE, INTEGER or FLOAT and counts down from &H4000.  Each increment represents 32 bits/ 4 bytes of memory.

When used with no parameters, the compiler will report where the various pointers are left following the compile.

This allows you to reserve space for Flash Write , or for implimenting program overlays.

Example
 


The values for the above map represent current compiler maximums, and the different hardware models may limit the values more.

The first program writes code to the first Flash sector then calls code in the second Flash sector

share_x = 22
share_y = 33

print "start the program and call overlay"
gosub start1
print "we are back"

print share_x

end ' if you don't have an END here or a loop the program will drop through into unprogrammed memory

__MAP__ CODE &H800 CONST &HF000

start1:

print "in the overlay"

return

This program when run shows

start the program and call overlay
in the overlay
we are back
22

Now overlay the second Flash sector with this program

DIM share_x          ' to access global variables in the original program, they must be declared in the same order
DIM share_y

     ' if you declare anything that would produce code before the __MAP__ you will overlay the 1st sector -- which you don't want to do

__MAP__ CODE &H800 CONST &HF000

start1:

'print "THIS IS A NEW OVERLAY"

share_x = share_y

return

Now when run it shows, and it shows the access to share_x was changed

start the program and call overlay
we are back
33
Differences from other BASICs

See also