def _encode_per_element_imm(self, values):
        if len(values) > 16:
            raise AssembleError('Too many immediate values {}'.format(values))

        values.extend([0] * (16-len(values)))
        unsigned = all(map(lambda x: x >= 0, values))
        high = 0
        low  = 0
        for i in reversed(range(16)):
            high <<= 1
            low  <<= 1
            v = values[i]

            if (not unsigned and (v >= 2 or v < -2)) or (unsigned and v >= 4):
                raise AssembleError('{} is not a 2-bit {}signed value'.format(
                        v, ['', 'un'][unsigned]))
            high |= (v & 0x2) >> 1
            low  |= v & 0x1

        return (high << 16) | low, 2*unsigned + 1
dataset/ETHPy150Open nineties/py-videocore/videocore/assembler.py/LoadEmitter._encode_per_element_imm/original