Writing bitfields with varying field lengths

Grumfish nobody at nowhere.com
Mon Aug 18 19:32:49 EDT 2003


In order to familiarize my self with Flash files and their bytecode I've 
started to make an assembler. My first problem is writing the bitfields 
the format uses often. It is a series of fields, each can be a different 
number of bits, combined into the least amount of bytes possible. Extra 
bits in the last byte are padded with zeros. I would like to make a 
function that takes a size and value for each field needed, calculate 
the amount of needed bytes, place the values, and the nretun a binary 
string of the resulting bitfield. I am at a complete loss on how to 
place the values into the field. I've Googled but have found nothing 
helpful. Can anybody help?





More information about the Python-list mailing list