Rotate-byte instructions

Started by
6 comments, last by ZackCQB 20 years, 2 months ago
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?
http://thegeekery.org/
Advertisement
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
it wouldn''t be hard to whip something up, but if you know how the ASM will be better anyway.
--- krez ([email="krez_AT_optonline_DOT_net"]krez_AT_optonline_DOT_net[/email])
Yeah, I''m okay at ASM, so I guess I''ll do it that way.
Thanks.
http://thegeekery.org/
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.
I''m stuck with Mingw32, but hopefully I''ll get MSVC sometime.
http://thegeekery.org/
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.)
I''m not going to speed here. This could take three hours for all I care, I just want to get it done.
http://thegeekery.org/

This topic is closed to new replies.

Advertisement