Keil Logo

AREGS Compiler Directive

Abbreviation

AR

Arguments

None.

Default

AREGS

µVision

Options — C51 — Don't use absolute register accesses.

Description

The AREGS control causes the compiler to use absolute addressing for registers R0-R7 to improve the efficiency of the generated code. When this directive is used, the compiler must know the register bank to use to generate code. The register bank may be defined with the REGISTERBANK directive.

For example, using the 8051 instruction set:

  • PUSH and POP instructions may be used only with direct or absolute addresses.
  • Register-to-register moves are not possible.

Using the AREGS directive allows the compiler to directly push and pop registers and to move from register-to-register.

See Also

NOAREGS, REGISTERBANK

Example

The following is a source and code listing which uses both NOAREGS and AREGS.

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


  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.