Skip to content

Instantly share code, notes, and snippets.

View chintan09's full-sized avatar

Chintan Parikh chintan09

View GitHub Profile
@chintan09
chintan09 / bitReverseMasked
Created March 15, 2012 17:31
bit reversal based on a mask given
// Input : bitReverseMasked(0x9, 1, 3)
// Output : 0x3 [ Reversing bit between low and high]
uint32_t bitReverseMasked(uint32_t val, uint8_t low, uint8_t high)
{
uint32_t mask;
uint32_t rev_val;
uint8_t i;
mask = ((1UL<<(high - low + 1)) - 1) << low;
rev_val = val & ~mask;