field_byte_start = (field.start // 8) * 8
start -= field_byte_start
end -= field_byte_start
+ extra_shift = 0
if field.type == "mbo":
s = "__gen_mbo(%d, %d)" % \
(start, end)
elif field.type == "address":
+ extra_shift = (31 - (end - start)) // 8 * 8
s = "__gen_address_offset(&values->%s)" % byte.address.name
elif field.type == "uint":
s = "__gen_uint(values->%s, %d, %d)" % \
s = None
if not s == None:
- if byte_start - field_byte_start != 0:
- s = "%s >> %d" % (s, byte_start - field_byte_start)
+ shift = byte_start - field_byte_start + extra_shift
+ if shift:
+ s = "%s >> %d" % (s, shift)
if field == byte.fields[-1]:
print("%s %s;" % (prefix, s))