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) ... ... ...
#pragma NOAREGS // (mark #6) void f3(void) { … … … } #pragma AREGS // (mark #7)
4) What should I do in case that f3 is a library function like sizeof, or printf, for example ? the problems are: (A)it is called from diffrent loactions in the code using diffrent register banks. and (B) I don't know how to tell such a function to use a specific register bank or to be compiled using the NOAREGS pragma.
sizeof is not a library function, it is an operator. Why are you trying to muck about with register banks like this?
The interrupt uses diffrent register bank then the one that the main program uses. I am not sure about if I correctly understood your question: Do you know any better way to do what I does ? I will be happy to learn from you ! p.s. In addition to the sizeof and printf functions, there is also a use in casting, which after compilation creates code that call some of the compier's casting functions. I put these functions too under the same question (#4) that I asked before.
library function like sizeof, or printf, ... it is called from diffrent loactions in the code using diffrent register banks. You can forget about the questions you ask until you get clear in your head the calling such functions (or other lenghty stuff) in an ISR will lead to disaster. The "automatic" compiler functions (address finders, switch porocessor and such) are bank independent. They must be since you "do not know" they are used. Erik