On Mon, Dec 17, 2012 at 9:13 AM, james cardona
<JAMES....@pseg.com> wrote:
Does this "ONLY" mean that function calls are not allowed in this page? and if so, is that function calls outside of the page? or all function calls?
No, this comment is a little misleading. As long as you use a correct prototype, with a section attribute added, e.g.
__machine3__ void foo (void);
then you can use make calls to it from anywhere. Without such a prototype, it can only safely be called from code inside the same page. (Intra-page calls don't change the ROM bank.) The prototypes are not used for a few cases of calls from outside: callsets, deff functions, and leff functions don't require them. (Technical point: callsets auto-detect the section, and for deffs/leffs you put the section in the md file inside a page() parameter.)
The only thing that won't work is if you have a function in one page X, called foo(), without a prototype, and from a different page Y you say:
foo();
The compiler will assume foo() is also in page Y, and generate incorrect calling code, which will usually lead to a crash pretty quickly.
If you define a prototype without the section header, like this:
void foo (void);
it will still fail, because the compiler needs to know that foo() is in page X instead.
If you know a function will never be called outside of the file it is defined in, it is good practice to add "static" to it, which will enforce that and keep you from mistakenly calling it.
- Brian