Ejemplo n.º 1
0
    def execute(self, processor, memory, pc):
        result, half_carry, _ = bitwise_sub(0, processor.main_registers['a'])

        set_condition = processor.set_condition
        set_condition('s', to_signed(result) < 0)
        set_condition('z', result == 0)
        set_condition('h', half_carry)
        set_condition('p', processor.main_registers['a'] == 0x80)
        set_condition('n', True)
        set_condition('c', processor.main_registers['a'] != 0x00)
        processor.main_registers['a'] = result
        return 8, False, pc
Ejemplo n.º 2
0
    def execute(self, processor, memory, pc):
        result, half_carry, _ = bitwise_sub(0, processor.main_registers['a'])

        set_condition = processor.set_condition
        set_condition('s', to_signed(result) < 0)
        set_condition('z', result == 0)
        set_condition('h', half_carry)
        set_condition('p', processor.main_registers['a'] == 0x80)
        set_condition('n', True)
        set_condition('c', processor.main_registers['a'] != 0x00)
        processor.main_registers['a'] = result
        return 8, False, pc
Ejemplo n.º 3
0
def _cp_value(processor, value, carry):
    signed_a = to_signed(processor.main_registers['a'])
    if carry:
        value = (value + 1) & 0xff
    result, half_carry, full_carry = bitwise_sub(processor.main_registers['a'], value)
    signed_result = to_signed(result)

    set_condition = processor.set_condition
    set_condition('s', signed_result < 0)
    set_condition('z', result == 0)
    set_condition('h', half_carry)
    set_condition('p', (signed_a < 0) != (signed_result < 0))
    set_condition('n', True)
    set_condition('c', full_carry)
Ejemplo n.º 4
0
def _cp_value(processor, value, carry):
    signed_a = to_signed(processor.main_registers['a'])
    if carry:
        value = (value + 1) & 0xff
    result, half_carry, full_carry = bitwise_sub(processor.main_registers['a'],
                                                 value)
    signed_result = to_signed(result)

    set_condition = processor.set_condition
    set_condition('s', signed_result < 0)
    set_condition('z', result == 0)
    set_condition('h', half_carry)
    set_condition('p', (signed_a < 0) != (signed_result < 0))
    set_condition('n', True)
    set_condition('c', full_carry)
Ejemplo n.º 5
0
def _block_compare(processor, memory, increment):
    src_addr = processor.get_16bit_reg('hl')

    value_to_compare = memory[src_addr]
    result, half_carry, full_carry = bitwise_sub(processor.main_registers['a'], value_to_compare)

    src_addr = (src_addr + increment) % 0x10000
    processor.set_16bit_reg('hl', src_addr)

    new_bc = _decrement_bc(processor)

    processor.set_condition('s', result & 0b10000000 != 0)
    processor.set_condition('z', result == 0)
    processor.set_condition('h', half_carry)
    processor.set_condition('p', new_bc != 0)
    processor.set_condition('n', True)
Ejemplo n.º 6
0
def _block_compare(processor, memory, increment):
    src_addr = processor.get_16bit_reg('hl')

    value_to_compare = memory[src_addr]
    result, half_carry, full_carry = bitwise_sub(processor.main_registers['a'],
                                                 value_to_compare)

    src_addr = (src_addr + increment) % 0x10000
    processor.set_16bit_reg('hl', src_addr)

    new_bc = _decrement_bc(processor)

    processor.set_condition('s', result & 0b10000000 != 0)
    processor.set_condition('z', result == 0)
    processor.set_condition('h', half_carry)
    processor.set_condition('p', new_bc != 0)
    processor.set_condition('n', True)