Wow. This is re-inventing the wheel. The NEC protocol is well known, and implemented in a number of different programs and equipment. Please check out
IrScrutinizer, it will save you a lot of time.
The good news is that you got the numbers right! Your hex signal decodes as NEC (NEC2 really), D=141, and F=9. But note that "MSB" or "LSB" is nothing than how you interpret the parameters. For example, 141 = 0x8D = 0b10001101, Read it backwards, and you have 0b10110001 = 0xB1 (= 177), which is exactly the device number you came up with! (IrScrutinizer contains a nice "pocket calculator" for this, btw.) (In Java, this is the function Integer.reverse(int), btw.)