title: Finding a mask value with higher and lower position of the register
body: <p>A 32 bit register i.e. status_reg has 1 field (field_1 &lt;0:31>). To set and clear this register I am trying to get mask value of this register. So in general to get mask value the formula is:</p>
  
  <pre><code>mask = ((~(~0 &lt;&lt; (hbit-lbit+1))) &lt;&lt; lbit)
  </code></pre>
  
  <p>In this <strong>hbit</strong> is higher position bit i.e. 31. And <strong>lbit</strong> is lower position bit i.e.0.
  I am expecting mask value should be 0xFFFFFFFF. But getting mask= 0. Can anyone suggest what is the wrong with mask?</p>
  
  <p>I am using 32 bit system. </p>