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

what's the function of "AREGS"and "NOAREGS"

what's the function of "AREGS"and "NOAREGS", can you provide me some sample, so that I could understand them clear. Are them still useful in current updated versions.
In the manual it is said that with "NOAREGS" the function could be called by another functions using different register bank.

#pragma NOAREGS
char add(char i)
{
    return i+10;
}

void main(void) using 1
{
    ch = add(3);
}

whether I enable or disable #pragma NOAREGS
I always get the right result. If with "NOAREGS" the function could be called by another functions using different register bank, then does it also mean that with "AREGS" the function could not be called by another functions using different register bank. I am very confused with "AREGS"and "NOAREGS".

Parents Reply Children
  • Having a look at this note in Manual:

    "The Cx51 compiler does not and cannot detect a register bank mismatch between functions. Therefore, make sure that functions using alternate register banks call only other functions that do not assume a default register bank."

    I think it is true, so for the above mentioned warning the adjective "missing" is at least disputable. Realize that compile time and run time are different things and the compiler (compile time) doesn't necessarily know the actual RB of a function at run time in general. Sometimes it is up to you to judge and decide. That's why I suggested: don't use using directive with common functions unless you have a really important reason for it (ISR, etc.)