Rotate-byte instructions
Is there any Rotate-bit instructions in C/C++? I mean the C/C++ equivalents of Assembly''s ROL and ROR instructions. Or am I stuck using embedded ASM?
There isn''t.
“Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.” — Brian W. Kernighan (C programming language co-inventor)
“Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.” — Brian W. Kernighan (C programming language co-inventor)
Some compilers supply functions to do it. For example, MSVC uses the _rotl() and _rotr() functions. And because of the magic of compiler intrisics they turn into ROL and ROR assembly instructions when compiled in release mode.
The good news is that MinGW, because it uses the Microsoft C runtime, has the _rotl() and _rotr() functions. So you can use them without resorting to inline assembly.
The bad news is that, even with optimization, MinGW doesn''t recognize _rotl() or _rotr() as intrinsics so they''ll show up in the machine code as function calls. (At least of MinGW 3.2 20020817-1, I haven''t upgraded my non-cygwin gcc builds on my system in a while.)
The bad news is that, even with optimization, MinGW doesn''t recognize _rotl() or _rotr() as intrinsics so they''ll show up in the machine code as function calls. (At least of MinGW 3.2 20020817-1, I haven''t upgraded my non-cygwin gcc builds on my system in a while.)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement