I want to calculate the value of the mask dynamically based on bit position. For Example: The mask value for 17th bit in a 32 bit value is 0x00020000 and that of 18th bit is 0x00040000. So if I know the bit positions like 17, 18 etc., how can this be converted dynamically to mask values in C? Of course left shifting is one method (1<<17 or 1<<18). But I am thinking left shifting may consume too many instructions!! Or Left shifting itself is the best and efficient method?
Aucun commentaire:
Enregistrer un commentaire