Click here to download the worksheet (PDF)

## The problem

When doing a lot of low-level system code, you constantly need to build hexadecimal constants and masks for bitwise arithmetic. Maybe you are accessing specific bits of an I/O register, or making sure you extract the proper field of a packed variable.

You can scribble your binary and hexadecimal masks on a loose sheet of paper, but this is error-prone. Most calculators are unwieldy when it comes to bitwise manipulations and spreadsheets are heavyweight.

## The solution

Here is a worksheet you can print to ease the work of applying bitwise operations (rotates, shifts, masks) or building binary and hexadecimal constants.

Its features are:

- Compatible with Letter or A4 paper
- Three grids of 5 lines for 32-bit work
- Separated by nibbles (4-bit groups) for easy conversion from binary to hex
- First and last line of each grid has a hex digit box in each nibble
- Regular (bit 0 is LSb) and PowerPC (bit 0 is MSb) bit indices in each column
- Decimal weight in small in each box (1,2,4,8)

- Table of the 32 first powers of 2
- Decimal/Binary/Hexadecimal conversion table reminder for values 0-15

This worksheet makes quick work of generating mask constants or figuring-out a pesky rlwimi (Rotate Left Word Immediate Mask Insert) operands list.

Click here to download the worksheet (PDF)

Here are some screenshots: