gennyble / hext

A Binary File Markup Language
ISC License
23 stars 0 forks source link

Hext Language Documentation #8

Open gennyble opened 3 years ago

gennyble commented 3 years ago

A nice way to say:

The first line that isn't a comment of blank, must be the file header. The header is structured as such:

~<property> <property> ...

You must specify your endianess and bit order. You can set those with little-endian, big-endian, msb0, lsb0. You can specify the endianess before the bit-order, or the other way round.

Hex is the default and must appear in octets. FF is valid, but FFA is not. You can group this all as one, FFOA, or spread it out, FF OA.

Binary is prefixed by a period, like so (ascii A), ..01000001. It can also be spread out .0100 .0010. By default you must have your binary be octets. You cannot, for example, have .0100 F, that's not allowed. You can put padbits in the header to pad out any octets you do not fill. It will pad according to your bitness property.

Decimal is prefixed with an =. You can precede the equals with an integer type and size, i for signed and u for unsigned. Integers can be 8, 16, 32, or 64 bits wide. If you do not specify a width you may not use i or u to specify the type, signed or unsigned. In that case, you'd just prefix all your signed integers with their sign (even the positives). The smallest integer for the decimal value you specified will be chosen. For example, in little-endian, =255 would output FF and =513 would be 01 02. If you write u16=255 you would get FF 00

Signed numbers are currently stored as two's compliment only. In the future you'll be able to specify the kind of negative you want in the header. Available options are: ones-compliment, twos-compliment, sign-magnitude