Keil Logo

REORDER Compiler Directive

Abbreviation

RO

Arguments

None.

Default

Instructions are not reordered.

µVision

Options — C166 — Reorder Instructions to Minimize Pipeline Effects.

Description

The REORDER directive enables the compiler to reorder instructions to minimize wait states and pipeline stalls. REORDER is only useful for XC16x and Super-10 devices where the following instructions may cause stalls (wait states) when the register used in the instruction are set in the prior instruction.

  • MOV Rn,[Rm]
  • MOV Rn,[Rm+data16]
  • MOV xxx,MDL
  • MOV xxx,MDH

The following example:

stmt lvl  source
  1       unsigned int *p;
  2       unsigned int v;
  3
  4       unsigned int func (void)  {
  5   1     unsigned int i1, i2;
  6   1
  7   1     i1 = v * 4;
  8   1     i2 = *p << i1;
  9   1     return (i2);
 10   1   }

demonstrates code generated using the REORDER directive:

Code Generated
Normally
; FUNCTION func (BEGIN)
                  ; SOURCE LINE # 4
                  ; SOURCE LINE # 7

0000 F2F50000 R    MOV       R5,v
0004 5C25          SHL       R5,#02H
;---- 'i1' assigned to 'R5' ----
                  ; SOURCE LINE # 8
0006 F2F10200 R    MOV       R1,p
000A A841          MOV       R4,[R1]
000C 4C45          SHL       R4,R5
;---- 'i2' assigned to 'R4' ----
                  ; SOURCE LINE # 9
                  ; SOURCE LINE # 10
000E CB00          RET
; FUNCTION func (END)
Code Generated
with REORDER
; FUNCTION func (BEGIN)
                  ; SOURCE LINE # 4
                  ; SOURCE LINE # 7
0000 F2F10200 R    MOV       R1,p
0004 F2F50000 R    MOV       R5,v
0008 5C25          SHL       R5,#02H
;---- 'i1' assigned to 'R5' ----
                  ; SOURCE LINE # 8

000A A841          MOV       R4,[R1]
000C 4C45          SHL       R4,R5
;---- 'i2' assigned to 'R4' ----
                  ; SOURCE LINE # 9
                  ; SOURCE LINE # 10
000E CB00          RET
; FUNCTION func (END)
See Also

NOREORDER

Example
C166 EXAMPLE.C REORDER

#pragma reorder
  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.