Methods and apparatus are provided for accessing the proper memory in
processors having program and data memories with different sizes. In some
embodiments, a processor is optimized for data access and has registers
that are the same size as the data memories. When a program is compiled,
some implementations identify when a pointer variable points to a piece
of data (data memory) or a function (program memory) and synthesize
different sized operations accordingly. The proper mode and size are
assigned for each pointer. Methods of the present invention do not
require annotation of functions. Existing code does not need to be
modified and there is no opportunity to introduce errors. The invention
does not require extra program memory to be located at directly
accessible locations to store stub code.