This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Do-it-yourself _lror_ implementation ?

Dear all,
_lror(unsigned long,unsigned char) is the math lib and implemented as function,not intrinsic function. But now I can not use it and need to implement myself.

Does anyone have the experience to implement it manually ?

I found the following code segments in Forum but it seems wrong after "my" verification:

unsigned long lror(unsigned long n,unsigned steps) {
    unsigned long t1,t2;
    steps &= 0x1f;
    t1 = n << steps;
    t2 = n >> (32-steps);
    return t1 | t2;
}

Ex. n = 0xA5A5A5A5 and steps = 1

[verify sequence]
- steps &= 0x1f => steps = 1
- t1 = 0xA5A5A5A5 << 1 => t1 = 0x4B4B4B4A
- t2 = 0xA5A5A5A5 >> (32-1) => t2 = 1
- t1|t2 => 0x4B4B4B4B !
(But result should be: 0xD2D2D2D2...)

Anything I misunderstood ?

0