title: bitwise operation to extract each individual word from a long
body: <p>I have a <code>long</code> that corresponds to an assembly language instruction.
  Here's the problem; the first field is Opcode. It can be either 1 or 2 digits. So for example in <code>120602</code>, 12 is the opcode. In <code>10602</code>, 1 is the opcode.</p>
  
  <p>I want to extract each individual field; where opcode is the first 1-2 numbers on the left, 1 to the right of that is op1mode, 1 to the right of that is op1gpr, 1 to the right of that is op2mode, and finally, the last part is op2gpr.
  Ideally, I want to assign each to its own variable for later use, or separate them in an array.</p>
  
  <p>I was thinking that this can be achievable using bitwise operations; namely masks and shifts. </p>
  
  <p>How would one split the number with just bitwise operations?</p>