Mercurial > lcfOS
view python/ppci/bitfun.py @ 352:899ae3aea803
First kernel run for vexpressA9
author | Windel Bouwman |
---|---|
date | Sun, 09 Mar 2014 11:55:55 +0100 |
parents | 3bb7dcfe5529 |
children | 98ff43cfdd36 |
line wrap: on
line source
def rotate_right(v, n): """ bit-wise Rotate right n times """ mask = (2**n) - 1 mask_bits = v & mask return (v >> n) | (mask_bits << (32 - n)) def rotate_left(v, n): assert n >= 0 assert n < 32 return rotate_right(v, 32 - n)