We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

AR# 51984

EDK MicroBlaze: explanation of Store Halfword Reverse MicroBlaze Instruction


When I use the SHR instruction, it swaps the endianness and stores the result in the other half word (the one next to the original half word).

Is this expected behavior?

code snippet:

  typedef union
        unsigned short int16e;
        unsigned short int16f;
   } structure;
   unsigned int tab[1];
  } structTest_t;

    structTest_t lit2big;
 lit2big.structure.int16e= 0xf055;
 lit2big.structure.int16f= 0xf066;
shr(&lit2big.structure.int16e, 0xad0b);
// print it:
int16e = F055 <- wanted to swap and assign there but didn't
int16f = BAD <- this other got swapped


As per (UG081), this is expected behavior:
If the R bit is set, a halfword reversed memory location is used and the two bytes in the halfword are reversed, storing data with the opposite endianness of the endianness defined by C_ENDIANNESS and the E bit (if virtual protected mode is enabled).
halfword reversed memory location is used " is as expected.
Make sure that you use C_USE_REORDER_INSTR = 1 in the settings - it is on by default so it should be used by default.
If = 0 then it is a plain store without byte reversal.
AR# 51984
Date Created 09/25/2012
Last Updated 10/02/2014
Status Active
Type General Article
  • Microblaze