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
  • Still I am confused with Cole's words because the absolute addresses cannot be reliably computed at compile time.The following word is from Chapter 2,Cx51 Compiler User's Guide:

    2
    stmt level source
    1 extern char func ();
    2 char k;
    3
    4 #pragma NOAREGS
    5 noaregfunc () {
    6 1 k = func () + func ();
    7 1 }
    8
    9 #pragma AREGS
    10 aregfunc () {
    11 1 k = func () + func ();
    12 1 }
    ; FUNCTION noaregfunc (BEGIN)
    ; SOURCE LINE # 6
    0000 120000 E LCALL func
    0003 EF MOV A,R7
    0004 C0E0 PUSH ACC
    0006 120000 E LCALL func
    0009 D0E0 POP ACC
    000B 2F ADD A,R7
    000C F500 R MOV k,A
    ; SOURCE LINE # 7
    000E 22 RET
    ; FUNCTION noaregfunc (END)
    ; FUNCTION aregfunc (BEGIN)
    ; SOURCE LINE # 11
    0000 120000 E LCALL func
    0003 C007 PUSH AR7
    0005 120000 E LCALL func
    0008 D0E0 POP ACC
    000A 2F ADD A,R7
    000B F500 R MOV k,A
    ; SOURCE LINE # 12
    000D 22 RET
    ; FUNCTION aregfunc (END)
    Do you mean that
    push AR7
    is not reliable because the AR7 isn't reliably computed at compile time?If it is true,why did you said that all the registers in all the register banks also have unique direct addresses?Is it right that the AREGS directive makes the compiler to generate code using absolute address that will results fatal errors in case that a function,not indicated by REGISTERBANK,is called by an interrupt using using 2 and NOAREGS generate code that always use the current selected register bank when running?

Reply
  • Still I am confused with Cole's words because the absolute addresses cannot be reliably computed at compile time.The following word is from Chapter 2,Cx51 Compiler User's Guide:

    2
    stmt level source
    1 extern char func ();
    2 char k;
    3
    4 #pragma NOAREGS
    5 noaregfunc () {
    6 1 k = func () + func ();
    7 1 }
    8
    9 #pragma AREGS
    10 aregfunc () {
    11 1 k = func () + func ();
    12 1 }
    ; FUNCTION noaregfunc (BEGIN)
    ; SOURCE LINE # 6
    0000 120000 E LCALL func
    0003 EF MOV A,R7
    0004 C0E0 PUSH ACC
    0006 120000 E LCALL func
    0009 D0E0 POP ACC
    000B 2F ADD A,R7
    000C F500 R MOV k,A
    ; SOURCE LINE # 7
    000E 22 RET
    ; FUNCTION noaregfunc (END)
    ; FUNCTION aregfunc (BEGIN)
    ; SOURCE LINE # 11
    0000 120000 E LCALL func
    0003 C007 PUSH AR7
    0005 120000 E LCALL func
    0008 D0E0 POP ACC
    000A 2F ADD A,R7
    000B F500 R MOV k,A
    ; SOURCE LINE # 12
    000D 22 RET
    ; FUNCTION aregfunc (END)
    Do you mean that
    push AR7
    is not reliable because the AR7 isn't reliably computed at compile time?If it is true,why did you said that all the registers in all the register banks also have unique direct addresses?Is it right that the AREGS directive makes the compiler to generate code using absolute address that will results fatal errors in case that a function,not indicated by REGISTERBANK,is called by an interrupt using using 2 and NOAREGS generate code that always use the current selected register bank when running?

Children