mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-14 10:37:23 -07:00
add: fast 8bit reversal.
This commit is contained in:
parent
60afef3938
commit
ede55a1498
5 changed files with 22 additions and 9 deletions
|
@ -729,15 +729,18 @@ void rol(uint8_t *data, const size_t len){
|
|||
data[len-1] = first;
|
||||
}
|
||||
|
||||
// Swap bit order on a uint32_t value. Can be limited by nrbits just use say 8bits reversal
|
||||
// And clears the rest of the bits.
|
||||
uint32_t SwapBits(uint32_t value, int nrbits) {
|
||||
// Swap bit order on a uint32_t value. Can be limited by 'b' just use say 8 bits reversal
|
||||
// note: function clears the rest of the bits.
|
||||
uint32_t SwapBits(uint32_t v, int b) {
|
||||
uint32_t newvalue = 0;
|
||||
for(int i = 0; i < nrbits; i++) {
|
||||
newvalue ^= ((value >> i) & 1) << (nrbits - 1 - i);
|
||||
for(int i = 0; i < b; i++) {
|
||||
newvalue ^= ((v >> i) & 1) << (b - 1 - i);
|
||||
}
|
||||
return newvalue;
|
||||
}
|
||||
uint8_t reflect8(uint8_t b) {
|
||||
return ((b * 0x80200802ULL) & 0x0884422110ULL) * 0x0101010101ULL >> 32;
|
||||
}
|
||||
/*
|
||||
ref http://www.csm.ornl.gov/~dunigan/crc.html
|
||||
Returns the value v with the bottom b [0,32] bits reflected.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue