Bitfield is not working as intended (16 bit / 32 bit limitation)

I’m writing my first 010 template. It’s meant for a specific binary file structure.
The file format makes use of bitfields.

Basically there are a couple of variables placed in 4 bytes.
I want my template to read the variables, but it’s not working as intended.

This is the binary file: (use right-click → save as to download)

This is my template: (use right-click → save as to download)

As you can see, all the bitfields will add up to 32 bits (6+2+2+1+1+20=32) = 4 bytes.
But the program doesn’t try to get the last 20 bits (baseAddress) from the first four bytes in the file, but takes them from the third, fourth, fifth and sixth bytes.
The issue is that I am using int as the variable datatype. And int is a 32-bit-variable type.
To me it looks like 010 Editor only supports 16- and 32-bit variable types.

But I have to read that 20-bit-value really from the correct position. Is there a way to make my template work as intended?

Hello reditec. Using bitfields is complicated and there are a number of options in 010 Editor to control how bitfields are applied. The short answer is that you should call:


at the beginning of your file. This should pack all the variables in 32-bits. If you want a longer explanation of how the packing works you can check out our manual at:
Let us know if you have any trouble getting the packing to work as expected.

SweetScape Software

1 Like

Thank you so much :slight_smile: @sweetscape