How to rotate lower and upper half-word of a 32-bit variable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2015-12-28 1:23 AM
Posted on December 28, 2015 at 10:23
Hi.
I would like to rotate lower and upper half-word of a 32-bit variable as in next example: var = 0x12345678; --> I would like to get 0x56781234; How could I do this as fast as possible (time is critical)? I saw that there are some ASM instructions for that, but I don't know how to implement this in Keil in a .c file somewhere in between of a normal C code. Any suggestions? Have a nice holidays.
This discussion is locked. Please start a new topic to ask your question.
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2015-12-30 3:38 AM
Posted on December 30, 2015 at 12:38
Search for ''__ror intrinsic'' on the arm.com site. I haven't tried using intrinsics myself, (normally I write an assembly routine if things are critical). I'm sure there is some C statement that will optimise to a ROR instruction - you could try various C statements and check the listing.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2015-12-30 4:19 AM
Posted on December 30, 2015 at 13:19 Thanks. I already figured out that. In CMSIS libs I found a __ROR() function. And if I look at assembly code in debugger, there is a ''ror'' instruction, which works exactly how I want.
