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

NOAREG & AREG,

Hello,
I'm having trouble understanding the NOAREG, AREG & USING options. I'm also confused with R0-R7 & AR0-AR7.
I've read the support files and manual but i'm still confused.
May I know
a) How is it that using NOAREGs will allow me to disregard register bank currently used when writing function? ( will the registers be automatically saved to stack? )
b) What is the difference with R0 and AR0? How does the USING option affect R0 & AR0? (for example if i put the option "USING 2", have then use R4, does this mean that it is the actually R20 ie in bank 2, whiel AR4 is not affected by the using function)
c) How does USING help me to save stack space?
Best Regards,
AL

Parents
  • Hello,
    First of all I wanted to thank Cole for his excellent explanation. It clears a lot of the fog around this issue, and I think that this explanation should be entered into the manual !

    I still have several questions regarding interrupt coding and relevant compiler directives:

    1) Assuming the following code:

    void UartIsr( void ) INTERRUPT(4) USING(2)
    {
       f1();
    }
    
    #pragma NOAREGS
    void f1(void)
    {
       …
       …
       f2();
       …
       …
    }
    #pragma AREGS
    
    void f2(void)
    {
       …
       …
       …
    }
    
    Does f2 need to have the NOAREG and AREG declarations at it's beginning and end?



    2) Can the use of REGISTERBANK(x) replace the NOAREG and AREG combined with the USING statement? Will this method of writing produce better code performance ? If not, then when should I use the REGISTERBANK(x) and when the AREG - NOAREG statements ?



    3) If I have a function that will be called from several code levels (for example the main application as well as the interrupt subroutine), will the NOAREG declaration allow this code to be correctly compiled?

    Thanks,
    Amit Alon.

Reply
  • Hello,
    First of all I wanted to thank Cole for his excellent explanation. It clears a lot of the fog around this issue, and I think that this explanation should be entered into the manual !

    I still have several questions regarding interrupt coding and relevant compiler directives:

    1) Assuming the following code:

    void UartIsr( void ) INTERRUPT(4) USING(2)
    {
       f1();
    }
    
    #pragma NOAREGS
    void f1(void)
    {
       …
       …
       f2();
       …
       …
    }
    #pragma AREGS
    
    void f2(void)
    {
       …
       …
       …
    }
    
    Does f2 need to have the NOAREG and AREG declarations at it's beginning and end?



    2) Can the use of REGISTERBANK(x) replace the NOAREG and AREG combined with the USING statement? Will this method of writing produce better code performance ? If not, then when should I use the REGISTERBANK(x) and when the AREG - NOAREG statements ?



    3) If I have a function that will be called from several code levels (for example the main application as well as the interrupt subroutine), will the NOAREG declaration allow this code to be correctly compiled?

    Thanks,
    Amit Alon.

Children