Variable length determined by first bit of a byte

0 votes
asked Jan 23, 2017 in Grammars by lapplandscohan (150 points)

I'm creating a grammar for MIDI-files.

One structure is a variable length number field where the first bit indicates if this is the last byte of data in the structure and the remaining 7 bits are actual data. As long as the first bit is 1 the next byte is also a part of the number field.

Examples:

  • 0100 0000 = 100 0000
  • 10100 0000   1100 1100   0100 0000 = 0 1000   0010 0110   0100 0000
How do I accomplish this in Synalyze it!?

1 Answer

0 votes
answered Jan 24, 2017 by andreas (3,300 points)

For this I'd recommend to use a scripted data type - this allows also to modify the value conveniently and write it back to the file.

Please have a look at the "custom data type" scripts on this page: https://www.synalysis.net/scripts.html

If you need any assistance for this, please let me know :)

...