Which bits are set?
2011-05-30

As a device driver developer I deal a lot with register values. Figuring out which bits are set can sometimes be really annoying. I've implemented a simple application that helps deal with this nuisance.

I get so tired of flipping back and forth between device programmer's manuals to determine what bits are what, and then expanding hex values to determine which bits are set. Granted, you tend to decode hex values in your head quite easily with practice over time but sometimes it results too much of a break in your thought process. Instead I wanted to just stop thinking about it and have a tool that would automate it for me thereby speeding up my software development and debugging time.

My tool is called bitter and it's written Python so it should work on whatever platform you use for development. If you think this tool is valuable please let me know what enhancements you'd like to see (if any).

% Usage: bitter [-h] [-n] [-i] [<value> ...]

-h         this text
-n         no colors
-i         loop and prompt for new values

<value>    dec:  decdigit+
           hex:  '0' ('x'|'X') hexdigit+
           oct:  '0' ('o'|'O') octdigit+ | '0' octdigit+
           bin:  '0' ('b'|'B') bindigit+
           bits: comma separated and/or ranges
                 2,6,13-17,30

Download it here: bitter

Here it is in action:

bitter