Keil Logo

REENTRANT Compiler Directive

Abbreviation

None.

Arguments

None.

Default

REENTRANT

µVision

Options — C166 — Use Static Memory for Non-register Automatics.

Description

The REENTRANT directive instructs the C166 Compiler to store automatic variables that cannot be allocated to a CPU register on the user stack. The generated code is fully reentrant.

The C166 Compiler uses the MOV Rn,[R0+#d16] and MOV [R0+#d16],Rn instructions to access stack-based variables.

See Also

STATIC

Example
stmt level    source

   1          #pragma reentrant
   2
   3          int rfunc (int i, int j)  {
   4   1        int array[10];
   5   1
   6   1        array[i] = j;
   7   1        return (array[j]);
   8   1      }
   9
  10          #pragma static
  11
  12          int sfunc (int i, int j)  {
  13   1        int array[10];
  14   1
  15   1        array[i] = j;
  16   1        return (array[j]);
  17   1      }

ASSEMBLY LISTING OF GENERATED OBJECT CODE
        ; FUNCTION rfunc (BEGIN  RMASK = @0x4070)
                ; SOURCE LINE # 3
;---- Variable ‘j’ assigned to Register ‘R9’ ----
;---- Variable ‘i’ assigned to Register ‘R8’ ----
0000 06F0ECFF      ADD     R0,#0FFECH
                ; SOURCE LINE # 6
0004 F058          MOV     R5,R8
0006 5C15          SHL     R5,#01H
0008 F060          MOV     R6,R0
000A F046          MOV     R4,R6
000C 0045          ADD     R4,R5
000E B894          MOV     [R4],R9
                ; SOURCE LINE # 7
0010 F049          MOV     R4,R9
0012 5C14          SHL     R4,#01H
0014 0064          ADD     R6,R4
0016 A846          MOV     R4,[R6]
                ; SOURCE LINE # 8
0018 06F01400      ADD     R0,#014H
001C CB00          RET
        ; FUNCTION rfunc (END    RMASK = @0x4070)

        ; FUNCTION sfunc (BEGIN  RMASK = @0x4010)
                ; SOURCE LINE # 12
;---- Variable ‘j’ assigned to Register ‘R9’ ----
;---- Variable ‘i’ assigned to Register ‘R8’ ----
                ; SOURCE LINE # 15
001E F048          MOV     R4,R8
0020 5C14          SHL     R4,#01H
0022 C4940000      MOV     [R4+#array],R9
                ; SOURCE LINE # 16
0026 F049          MOV     R4,R9
0028 5C14          SHL     R4,#01H
002A D4440000      MOV     R4,[R4+#array]
                ; SOURCE LINE # 17
002E CB00          RET
        ; FUNCTION sfunc (END    RMASK = @0x4010)

Related Knowledgebase Articles

  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.