This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

#pragma REGISTERBANK(x) and AREGS/NOAREGS directivs

Hello,
I would like to get more specific information regarding the use of #pragma REGISTERBANK(x) and AREGS/NOAREGS directivs.

Assuming the following code:

void UartIsr(void) INTERRUPT(4) USING(2)
{
   f1();
}

#pragma REGISTERBANK(2) // (mark #0)
void f1(void)
{
   …
   …
   f2();
   …
   …
}
#pragma REGISTERBANK(0) // (mark #1)
...
...
...
#pragma REGISTERBANK(2) // (mark #2)
void f2(void)
{
   …
   f3();
   …
   …
}
#pragma REGISTERBANK(0) // (mark #3)

...
...
...

#pragma REGISTERBANK(2) // (mark #4)
void f3(void)
{
   …
   …
   …
}
#pragma REGISTERBANK(0) // (mark #5)

...
...
...


1) I know that the line with the remrk (//mark #1) is vital for the proper execution of the code. I don't know whether the lines with remrks mark#1-5 are essential (or will the compiler know that they should inherit the registerbank from the calling function?). Please answer for each code mark separately.
please assume that all functions will be called ONLY from the showed code, and not from any other function that may call them using diffrent register bank.

2) Scenario 2: Please assume that each line that contains the pragma directive "REGISTERBANK(2)" will be replaced with "NOAREGS", and ecah line that contains the pragma directive "REGISTERBANK(0)" will be replaced with "AREGS", and re-answer question #1.

3) Scenario 3: Using the code above, please assume that function f3 CAN be called from another place that use registerbank 0 (the main application). in this case should the code of f3 be as folows:

#pragma NOAREGS // (mark #6)
void f3(void)
{
   …
   …
   …
}
#pragma AREGS // (mark #7)
? in such a case, which line with remarks should be left as they are and which shouldn't ?


Regards,
Amit Alon.