In gen_mtp3field_code_internal() it is not immediately clear what the
OPC value processing code does and whether it does it correctly. I have
verified that it combines byte swapping and bit shifting and indeed
processes the value consistently with the specification. To make it
easier to follow in future, replace the custom code and the custom
bitmask with a combination of SWAPLONG() and a bitwise shift. The
resulting bytecode remains intact (thus no OPC tests change).
The DPC value processing code is plain byte swapping with no bitwise
shift. The comparison uses BPF_W, but DPC spans only two adjacent
bytes, so change it to BPF_H and use SWAPSHORT(), similar to the above.
The resulting bytecode has the same effect (no DPC apply tests change),
but the SNR becomes better, which is the only change in the
corresponding DPC accept tests, e.g.:
-(000) ld [4]
-(001) and #0xff3f0000
-(002) jeq #0xd6310000 jt 3 jf 4
+(000) ldh [4]
+(001) and #0xff3f
+(002) jeq #0xd631 jt 3 jf 4
The SLS value processing code already uses BPF_B, so just reformat it
along the same lines. The resulting bytecode remains intact (thus no
SLS tests change).
All of the above applies the same to the HSL variants ("hdpc", "hopc"
and "hsls"), which differ by the field offsets only. Add comments to
explain the updated code and replace several hard-coded values with
named constants.