We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Good morning everyone Forum I have done a lot of programming and proficient using C but this Kile compiler is new to me and very different. it is confusing me. I have a question and need your help. I wonder how can I rotate the left (<<) the value of variable 'A', so to rotate, bitwise be transferred to another variable 'B'.
thanks hannibal. i had to change the bits_to_protate to 8 and now she is working.
Note that for processors with barrel rotate, you can find _much_ faster ways to rotate multiple steps.
And for processors without barrel rotate, you can still find faster solutions for 8 step rotates.
Mostly bit shifting is done using rotate with carry instruction (check it with your device and compiler), so rotate left 1 bit in C can be:
b = a<<1 | CARRY;
-ichan
No. Mostly shifts are not implemented using rotate instructions.
But the processor shift instructions normally shift out bits into the carry flag, to allow multiple chained shifts for working with data larger than what fits in a single register.
Just that most processors don't have any easy way to access that carry flag. Note that this thread is about ARM processors, not 8051 where the processor registers and lots of bits are directly accessible as byte or bit variables.
thanks ican. very interesting.