Hi Guys,
I have wrote a small logic below which will calculate a value called MASK via which I can calculate the starting and ending number
This logic works fine if A = 0x14000000 B = 0x14000064
Code:
void main()
{
unsigned long ulStartVal = 0x14000000;
unsigned long ulEndVal = 0x14000064;
unsigned long ulMask;
unsigned long ulTempVal;
// Calculate mask
ulMask = ~((ulStartVal) ^ (ulEndVal));
/* This step is kindoff mandatory startval AND operation with mask must give
the value of startval again (value of ulTempVal and ulStartVal must be same) */
ulTempVal = ulStartVal & ulMask;
printf("%x %x",ulTempVal, ulMask);
//Endval calculation with startval and mask
ulEndVal = ~((ulTempVal) ^ (ulMask));
printf("%x",ulEndVal);
}
But the above logic doesn't work fine if A = 0x1400000A B = 0x14000064 means if the value of A has last 8 bits set. C code or pseudo code or any suggestion on logic change is very much welcome.