# Path: MC6809/components/MC6809data/MC6809_op_data.py
# REG_S = "S"
# 
# REG_U = "U"
# 
# REG_X = "X"
# 
# REG_Y = "Y"
# 
# Path: MC6809/utils/bits.py
# def is_bit_set(value, bit):
#     """
#     Return True/False if the bit at offset >bit< is 1 or 0 in given value.
# 
#     bit 7 |      | bit 0
#        ...10111101
# 
#     e.g.:
# 
#     >>> is_bit_set(0x01, bit=0) # 00000001
#     True
#     >>> is_bit_set(0xfd, bit=1) # 11111101
#     False
#     >>> is_bit_set(int('10000000', 2), bit=7)
#     True
#     >>> is_bit_set(int('01111111', 2), bit=7)
#     False
#     >>> is_bit_set(int('1111000011110000', 2), bit=11)
#     False
#     >>> is_bit_set(int('1111000011110000', 2), bit=12)
#     True
#     """
#     return False if value & 2 ** bit == 0 else True
# 
# Path: MC6809/utils/byte_word_values.py
# def signed5(x):
#     """ convert to signed 5-bit """
#     if x > 0xf:  # 0xf == 2**4-1 == 15
#         x = x - 0x20  # 0x20 == 2**5 == 32
#     return x
# 
# def signed8(x):
#     """ convert to signed 8-bit """
#     if x > 0x7f:  # 0x7f ==  2**7-1 == 127
#         x = x - 0x100  # 0x100 == 2**8 == 256
#     return x
# 
# def signed16(x):
#     """ convert to signed 16-bit """
#     if x > 0x7fff:  # 0x7fff ==  2**15-1 == 32767
#         x = x - 0x10000  # 0x100 == 2**16 == 65536
#     return x


from MC6809.components.MC6809data.MC6809_op_data import REG_S, REG_U, REG_X, REG_Y
from MC6809.utils.bits import is_bit_set
from MC6809.utils.byte_word_values import signed5, signed8, signed16
        addr_mode = postbyte & 0x0f
        self.cycles += 1
        offset = None
        # TODO: Optimized this, maybe use a dict mapping...
        if addr_mode == 0x0:
            #             log.debug("\t0000 0x0 | ,R+ | increment by 1")
            ea = register_value
            register_obj.increment(1)
        elif addr_mode == 0x1:
            #             log.debug("\t0001 0x1 | ,R++ | increment by 2")
            ea = register_value
            register_obj.increment(2)
            self.cycles += 1
        elif addr_mode == 0x2:
            #             log.debug("\t0010 0x2 | ,R- | decrement by 1")
            register_obj.decrement(1)
            ea = register_obj.value
        elif addr_mode == 0x3:
            #             log.debug("\t0011 0x3 | ,R-- | decrement by 2")
            register_obj.decrement(2)
            ea = register_obj.value
            self.cycles += 1
        elif addr_mode == 0x4:
            #             log.debug("\t0100 0x4 | ,R | No offset")
            ea = register_value
        elif addr_mode == 0x5:
            #             log.debug("\t0101 0x5 | B, R | B register offset")
            offset = signed8(self.accu_b.value)
        elif addr_mode == 0x6:
            #             log.debug("\t0110 0x6 | A, R | A register offset")

# Path: MC6809/components/MC6809data/MC6809_op_data.py
# REG_S = "S"
# 
# REG_U = "U"
# 
# REG_X = "X"
# 
# REG_Y = "Y"
# 
# Path: MC6809/utils/bits.py
# def is_bit_set(value, bit):
#     """
#     Return True/False if the bit at offset >bit< is 1 or 0 in given value.
# 
#     bit 7 |      | bit 0
#        ...10111101
# 
#     e.g.:
# 
#     >>> is_bit_set(0x01, bit=0) # 00000001
#     True
#     >>> is_bit_set(0xfd, bit=1) # 11111101
#     False
#     >>> is_bit_set(int('10000000', 2), bit=7)
#     True
#     >>> is_bit_set(int('01111111', 2), bit=7)
#     False
#     >>> is_bit_set(int('1111000011110000', 2), bit=11)
#     False
#     >>> is_bit_set(int('1111000011110000', 2), bit=12)
#     True
#     """
#     return False if value & 2 ** bit == 0 else True
# 
# Path: MC6809/utils/byte_word_values.py
# def signed5(x):
#     """ convert to signed 5-bit """
#     if x > 0xf:  # 0xf == 2**4-1 == 15
#         x = x - 0x20  # 0x20 == 2**5 == 32
#     return x
# 
# def signed8(x):
#     """ convert to signed 8-bit """
#     if x > 0x7f:  # 0x7f ==  2**7-1 == 127
#         x = x - 0x100  # 0x100 == 2**8 == 256
#     return x
# 
# def signed16(x):
#     """ convert to signed 16-bit """
#     if x > 0x7fff:  # 0x7fff ==  2**15-1 == 32767
#         x = x - 0x10000  # 0x100 == 2**16 == 65536
#     return x


# Path: MC6809/components/mc6809_addressing.py
from MC6809.components.MC6809data.MC6809_op_data import REG_S, REG_U, REG_X, REG_Y
from MC6809.utils.bits import is_bit_set
from MC6809.utils.byte_word_values import signed5, signed8, signed16

        addr_mode = postbyte & 0x0f
        self.cycles += 1
        offset = None
        # TODO: Optimized this, maybe use a dict mapping...
        if addr_mode == 0x0:
            #             log.debug("\t0000 0x0 | ,R+ | increment by 1")
            ea = register_value
            register_obj.increment(1)
        elif addr_mode == 0x1:
            #             log.debug("\t0001 0x1 | ,R++ | increment by 2")
            ea = register_value
            register_obj.increment(2)
            self.cycles += 1
        elif addr_mode == 0x2:
            #             log.debug("\t0010 0x2 | ,R- | decrement by 1")
            register_obj.decrement(1)
            ea = register_obj.value
        elif addr_mode == 0x3:
            #             log.debug("\t0011 0x3 | ,R-- | decrement by 2")
            register_obj.decrement(2)
            ea = register_obj.value
            self.cycles += 1
        elif addr_mode == 0x4:
            #             log.debug("\t0100 0x4 | ,R | No offset")
            ea = register_value
        elif addr_mode == 0x5:
            #             log.debug("\t0101 0x5 | B, R | B register offset")
            offset = signed8(self.accu_b.value)
        elif addr_mode == 0x6:
            #             log.debug("\t0110 0x6 | A, R | A register offset")

            offset = signed8(self.accu_a.value)