def convert_differend_width(src_reg, dst_reg):
    """
    e.g.:
     8bit   $cd TFR into 16bit, results in: $ffcd
    16bit $1234 TFR into  8bit, results in:   $34

    >>> reg8 = ValueStorage8Bit(name="bar", initial_value=0xcd)
    >>> reg16 = ValueStorage16Bit(name="foo", initial_value=0x0000)
    >>> hex(convert_differend_width(src_reg=reg8, dst_reg=reg16))
    '0xffcd'

    >>> reg16 = ValueStorage16Bit(name="foo", initial_value=0x1234)
    >>> reg8 = ValueStorage8Bit(name="bar", initial_value=0xcd)
    >>> hex(convert_differend_width(src_reg=reg16, dst_reg=reg8))
    '0x34'

    TODO: verify this behaviour on real hardware
    see: http://archive.worldofdragon.org/phpBB3/viewtopic.php?f=8&t=4886
    """
    src_value = src_reg.value
    if src_reg.WIDTH == 8 and dst_reg.WIDTH == 16:
        # e.g.: $cd -> $ffcd
        src_value += 0xff00
    elif src_reg.WIDTH == 16 and dst_reg.WIDTH == 8:
        # This not not really needed, because all 8Bit register will
        # limit the value, too.
        # e.g.: $1234 -> $34
        src_value = src_value & 0xff
    return src_value
def convert_differend_width ( src_reg , dst_reg ) : src_value = src_reg . value if src_reg . WIDTH == 8 and dst_reg . WIDTH == 16 : src_value += 0xff00 elif src_reg . WIDTH == 16 and dst_reg . WIDTH == 8 : src_value = src_value & 0xff return src_value
e.g.:
     8bit   $cd TFR into 16bit, results in: $ffcd
    16bit $1234 TFR into  8bit, results in:   $34

    >>> reg8 = ValueStorage8Bit(name="bar", initial_value=0xcd)
    >>> reg16 = ValueStorage16Bit(name="foo", initial_value=0x0000)
    >>> hex(convert_differend_width(src_reg=reg8, dst_reg=reg16))
    '0xffcd'

    >>> reg16 = ValueStorage16Bit(name="foo", initial_value=0x1234)
    >>> reg8 = ValueStorage8Bit(name="bar", initial_value=0xcd)
    >>> hex(convert_differend_width(src_reg=reg16, dst_reg=reg8))
    '0x34'

    TODO: verify this behaviour on real hardware
    see: http://archive.worldofdragon.org/phpBB3/viewtopic.php?f=8&t=4886