<s> import unittest <EOL> import sys <EOL> import py65 . devices . mpu65c02 <EOL> from py65 . tests . devices . test_mpu6502 import Common6502Tests <EOL> class MPUTests ( unittest . TestCase , Common6502Tests ) : <EOL> """<STR_LIT>""" <EOL> def test_repr ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> self . assertTrue ( '<STR_LIT>' in repr ( mpu ) ) <EOL> def test_adc_bcd_off_zp_ind_carry_clear_in_accumulator_zeroes ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . a = <NUM_LIT> <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> mpu . memory [ <NUM_LIT> ] = <NUM_LIT> <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT:5> , mpu . processorCycles ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . a ) <EOL> self . assertEqual ( <NUM_LIT:0> , mpu . p & mpu . CARRY ) <EOL> self . assertEqual ( <NUM_LIT:0> , mpu . p & mpu . NEGATIVE ) <EOL> self . assertEqual ( mpu . ZERO , mpu . p & mpu . ZERO ) <EOL> def test_adc_bcd_off_zp_ind_carry_set_in_accumulator_zero ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . a = <NUM_LIT:0> <EOL> mpu . p |= mpu . CARRY <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> mpu . memory [ <NUM_LIT> ] = <NUM_LIT> <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT:5> , mpu . processorCycles ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . a ) <EOL> self . assertEqual ( <NUM_LIT:0> , mpu . p & mpu . NEGATIVE ) <EOL> self . assertEqual ( <NUM_LIT:0> , mpu . p & mpu . ZERO ) <EOL> self . assertNotEqual ( mpu . CARRY , mpu . p & mpu . CARRY ) <EOL> def test_adc_bcd_off_zp_ind_carry_clear_in_no_carry_clear_out ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . a = <NUM_LIT> <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> mpu . memory [ <NUM_LIT> ] = <NUM_LIT> <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT:5> , mpu . processorCycles ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . a ) <EOL> self . assertEqual ( mpu . NEGATIVE , mpu . p & mpu . NEGATIVE ) <EOL> self . assertEqual ( <NUM_LIT:0> , mpu . p & mpu . CARRY ) <EOL> self . assertEqual ( <NUM_LIT:0> , mpu . p & mpu . ZERO ) <EOL> def test_adc_bcd_off_zp_ind_carry_clear_in_carry_set_out ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . a = <NUM_LIT> <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> mpu . memory [ <NUM_LIT> ] = <NUM_LIT> <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT:5> , mpu . processorCycles ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . a ) <EOL> self . assertEqual ( mpu . CARRY , mpu . p & mpu . CARRY ) <EOL> self . assertEqual ( <NUM_LIT:0> , mpu . p & mpu . NEGATIVE ) <EOL> self . assertEqual ( <NUM_LIT:0> , mpu . p & mpu . ZERO ) <EOL> def test_adc_bcd_off_zp_ind_overflow_cleared_no_carry_01_plus_01 ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . p &= ~ ( mpu . CARRY ) <EOL> mpu . a = <NUM_LIT> <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> mpu . memory [ <NUM_LIT> ] = <NUM_LIT> <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . a ) <EOL> self . assertEqual ( <NUM_LIT:0> , mpu . p & mpu . OVERFLOW ) <EOL> def test_adc_bcd_off_zp_ind_overflow_cleared_no_carry_01_plus_ff ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . p &= ~ ( mpu . CARRY ) <EOL> mpu . a = <NUM_LIT> <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> mpu . memory [ <NUM_LIT> ] = <NUM_LIT> <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . a ) <EOL> self . assertEqual ( <NUM_LIT:0> , mpu . p & mpu . OVERFLOW ) <EOL> def test_adc_bcd_off_zp_ind_overflow_set_no_carry_7f_plus_01 ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . p &= ~ ( mpu . CARRY ) <EOL> mpu . a = <NUM_LIT> <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> mpu . memory [ <NUM_LIT> ] = <NUM_LIT> <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . a ) <EOL> self . assertEqual ( mpu . OVERFLOW , mpu . p & mpu . OVERFLOW ) <EOL> def test_adc_bcd_off_zp_ind_overflow_set_no_carry_80_plus_ff ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . p &= ~ ( mpu . CARRY ) <EOL> mpu . a = <NUM_LIT> <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> mpu . memory [ <NUM_LIT> ] = <NUM_LIT> <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . a ) <EOL> self . assertEqual ( mpu . OVERFLOW , mpu . p & mpu . OVERFLOW ) <EOL> def test_adc_bcd_off_zp_ind_overflow_set_on_40_plus_40 ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . a = <NUM_LIT> <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> mpu . memory [ <NUM_LIT> ] = <NUM_LIT> <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . a ) <EOL> self . assertEqual ( mpu . NEGATIVE , mpu . p & mpu . NEGATIVE ) <EOL> self . assertEqual ( mpu . OVERFLOW , mpu . p & mpu . OVERFLOW ) <EOL> self . assertEqual ( <NUM_LIT:0> , mpu . p & mpu . ZERO ) <EOL> def test_and_zp_ind_all_zeros_setting_zero_flag ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . a = <NUM_LIT> <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> mpu . memory [ <NUM_LIT> ] = <NUM_LIT> <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT:5> , mpu . processorCycles ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . a ) <EOL> self . assertEqual ( mpu . ZERO , mpu . p & mpu . ZERO ) <EOL> self . assertEqual ( <NUM_LIT:0> , mpu . p & mpu . NEGATIVE ) <EOL> def test_and_zp_ind_zeros_and_ones_setting_negative_flag ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . a = <NUM_LIT> <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> mpu . memory [ <NUM_LIT> ] = <NUM_LIT> <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT:5> , mpu . processorCycles ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . a ) <EOL> self . assertEqual ( mpu . NEGATIVE , mpu . p & mpu . NEGATIVE ) <EOL> self . assertEqual ( <NUM_LIT:0> , mpu . p & mpu . ZERO ) <EOL> def test_bit_abs_x_copies_bit_7_of_memory_to_n_flag_when_0 ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . p &= ~ ( mpu . NEGATIVE ) <EOL> mpu . x = <NUM_LIT> <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) ) <EOL> mpu . memory [ <NUM_LIT> ] = <NUM_LIT> <EOL> mpu . a = <NUM_LIT> <EOL> mpu . step ( ) <EOL> self . assertEqual ( mpu . NEGATIVE , mpu . p & mpu . NEGATIVE ) <EOL> self . assertEqual ( <NUM_LIT:4> , mpu . processorCycles ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> def test_bit_abs_x_copies_bit_7_of_memory_to_n_flag_when_1 ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . p |= mpu . NEGATIVE <EOL> mpu . x = <NUM_LIT> <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) ) <EOL> mpu . memory [ <NUM_LIT> ] = <NUM_LIT> <EOL> mpu . a = <NUM_LIT> <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT:0> , mpu . p & mpu . NEGATIVE ) <EOL> self . assertEqual ( <NUM_LIT:4> , mpu . processorCycles ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> def test_bit_abs_x_copies_bit_6_of_memory_to_v_flag_when_0 ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . p &= ~ ( mpu . OVERFLOW ) <EOL> mpu . x = <NUM_LIT> <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) ) <EOL> mpu . memory [ <NUM_LIT> ] = <NUM_LIT> <EOL> mpu . a = <NUM_LIT> <EOL> mpu . step ( ) <EOL> self . assertEqual ( mpu . OVERFLOW , mpu . p & mpu . OVERFLOW ) <EOL> self . assertEqual ( <NUM_LIT:4> , mpu . processorCycles ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> def test_bit_abs_x_copies_bit_6_of_memory_to_v_flag_when_1 ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . p |= mpu . OVERFLOW <EOL> mpu . x = <NUM_LIT> <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) ) <EOL> mpu . memory [ <NUM_LIT> ] = <NUM_LIT> <EOL> mpu . a = <NUM_LIT> <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT:0> , mpu . p & mpu . OVERFLOW ) <EOL> self . assertEqual ( <NUM_LIT:4> , mpu . processorCycles ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> def test_bit_abs_x_stores_result_of_and_in_z_preserves_a_when_1 ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . p &= ~ mpu . ZERO <EOL> mpu . x = <NUM_LIT> <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) ) <EOL> mpu . memory [ <NUM_LIT> ] = <NUM_LIT> <EOL> mpu . a = <NUM_LIT> <EOL> mpu . step ( ) <EOL> self . assertEqual ( mpu . ZERO , mpu . p & mpu . ZERO ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . a ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . memory [ <NUM_LIT> ] ) <EOL> self . assertEqual ( <NUM_LIT:4> , mpu . processorCycles ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> def test_bit_abs_x_stores_result_of_and_nonzero_in_z_preserves_a ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . p |= mpu . ZERO <EOL> mpu . x = <NUM_LIT> <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) ) <EOL> mpu . memory [ <NUM_LIT> ] = <NUM_LIT> <EOL> mpu . a = <NUM_LIT> <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT:0> , mpu . p & mpu . ZERO ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . a ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . memory [ <NUM_LIT> ] ) <EOL> self . assertEqual ( <NUM_LIT:4> , mpu . processorCycles ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> def test_bit_abs_x_stores_result_of_and_when_zero_in_z_preserves_a ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . p &= ~ ( mpu . ZERO ) <EOL> mpu . x = <NUM_LIT> <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) ) <EOL> mpu . memory [ <NUM_LIT> ] = <NUM_LIT> <EOL> mpu . a = <NUM_LIT> <EOL> mpu . step ( ) <EOL> self . assertEqual ( mpu . ZERO , mpu . p & mpu . ZERO ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . a ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . memory [ <NUM_LIT> ] ) <EOL> self . assertEqual ( <NUM_LIT:4> , mpu . processorCycles ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> def test_bit_imm_does_not_affect_n_and_z_flags ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . p |= mpu . NEGATIVE | mpu . OVERFLOW <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> mpu . a = <NUM_LIT> <EOL> mpu . step ( ) <EOL> self . assertEqual ( mpu . NEGATIVE , mpu . p & mpu . NEGATIVE ) <EOL> self . assertEqual ( mpu . OVERFLOW , mpu . p & mpu . OVERFLOW ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . a ) <EOL> self . assertEqual ( <NUM_LIT:2> , mpu . processorCycles ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> def test_bit_imm_stores_result_of_and_in_z_preserves_a_when_1 ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . p &= ~ mpu . ZERO <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> mpu . a = <NUM_LIT> <EOL> mpu . step ( ) <EOL> self . assertEqual ( mpu . ZERO , mpu . p & mpu . ZERO ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . a ) <EOL> self . assertEqual ( <NUM_LIT:2> , mpu . processorCycles ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> def test_bit_imm_stores_result_of_and_when_nonzero_in_z_preserves_a ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . p |= mpu . ZERO <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> mpu . a = <NUM_LIT> <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT:0> , mpu . p & mpu . ZERO ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . a ) <EOL> self . assertEqual ( <NUM_LIT:2> , mpu . processorCycles ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> def test_bit_imm_stores_result_of_and_when_zero_in_z_preserves_a ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . p &= ~ ( mpu . ZERO ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> mpu . a = <NUM_LIT> <EOL> mpu . step ( ) <EOL> self . assertEqual ( mpu . ZERO , mpu . p & mpu . ZERO ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . a ) <EOL> self . assertEqual ( <NUM_LIT:2> , mpu . processorCycles ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> def test_bit_zp_x_copies_bit_7_of_memory_to_n_flag_when_0 ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . p &= ~ ( mpu . NEGATIVE ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> mpu . memory [ <NUM_LIT> ] = <NUM_LIT> <EOL> mpu . x = <NUM_LIT> <EOL> mpu . a = <NUM_LIT> <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT:4> , mpu . processorCycles ) <EOL> self . assertEqual ( mpu . NEGATIVE , mpu . p & mpu . NEGATIVE ) <EOL> def test_bit_zp_x_copies_bit_7_of_memory_to_n_flag_when_1 ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . p |= mpu . NEGATIVE <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> mpu . memory [ <NUM_LIT> ] = <NUM_LIT> <EOL> mpu . x = <NUM_LIT> <EOL> mpu . a = <NUM_LIT> <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT:4> , mpu . processorCycles ) <EOL> self . assertEqual ( <NUM_LIT:0> , mpu . p & mpu . NEGATIVE ) <EOL> def test_bit_zp_x_copies_bit_6_of_memory_to_v_flag_when_0 ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . p &= ~ ( mpu . OVERFLOW ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> mpu . memory [ <NUM_LIT> ] = <NUM_LIT> <EOL> mpu . x = <NUM_LIT> <EOL> mpu . a = <NUM_LIT> <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT:4> , mpu . processorCycles ) <EOL> self . assertEqual ( mpu . OVERFLOW , mpu . p & mpu . OVERFLOW ) <EOL> def test_bit_zp_x_copies_bit_6_of_memory_to_v_flag_when_1 ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . p |= mpu . OVERFLOW <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> mpu . memory [ <NUM_LIT> ] = <NUM_LIT> <EOL> mpu . x = <NUM_LIT> <EOL> mpu . a = <NUM_LIT> <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT:4> , mpu . processorCycles ) <EOL> self . assertEqual ( <NUM_LIT:0> , mpu . p & mpu . OVERFLOW ) <EOL> def test_bit_zp_x_stores_result_of_and_in_z_preserves_a_when_1 ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . p &= ~ mpu . ZERO <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> mpu . memory [ <NUM_LIT> ] = <NUM_LIT> <EOL> mpu . x = <NUM_LIT> <EOL> mpu . a = <NUM_LIT> <EOL> mpu . step ( ) <EOL> self . assertEqual ( mpu . ZERO , mpu . p & mpu . ZERO ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT:4> , mpu . processorCycles ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . a ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . memory [ <NUM_LIT> + mpu . x ] ) <EOL> def test_bit_zp_x_stores_result_of_and_when_nonzero_in_z_preserves_a ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . p |= mpu . ZERO <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> mpu . memory [ <NUM_LIT> ] = <NUM_LIT> <EOL> mpu . x = <NUM_LIT> <EOL> mpu . a = <NUM_LIT> <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT:0> , mpu . p & mpu . ZERO ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT:4> , mpu . processorCycles ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . a ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . memory [ <NUM_LIT> + mpu . x ] ) <EOL> def test_bit_zp_x_stores_result_of_and_when_zero_in_z_preserves_a ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . p &= ~ ( mpu . ZERO ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> mpu . memory [ <NUM_LIT> ] = <NUM_LIT> <EOL> mpu . x = <NUM_LIT> <EOL> mpu . a = <NUM_LIT> <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT:4> , mpu . processorCycles ) <EOL> self . assertEqual ( mpu . ZERO , mpu . p & mpu . ZERO ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . a ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . memory [ <NUM_LIT> + mpu . x ] ) <EOL> def test_brk_clears_decimal_flag ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . p = mpu . DECIMAL <EOL> mpu . memory [ <NUM_LIT> ] = <NUM_LIT> <EOL> mpu . pc = <NUM_LIT> <EOL> mpu . step ( ) <EOL> self . assertEqual ( mpu . BREAK , mpu . p & mpu . BREAK ) <EOL> self . assertEqual ( <NUM_LIT:0> , mpu . p & mpu . DECIMAL ) <EOL> def test_cmp_zpi_sets_z_flag_if_equal ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . a = <NUM_LIT> <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> mpu . memory [ <NUM_LIT> ] = <NUM_LIT> <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT:5> , mpu . processorCycles ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . a ) <EOL> self . assertEqual ( mpu . ZERO , mpu . p & mpu . ZERO ) <EOL> self . assertEqual ( <NUM_LIT:0> , mpu . p & mpu . NEGATIVE ) <EOL> def test_cmp_zpi_resets_z_flag_if_unequal ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . a = <NUM_LIT> <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> mpu . memory [ <NUM_LIT> ] = <NUM_LIT> <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT:5> , mpu . processorCycles ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . a ) <EOL> self . assertEqual ( <NUM_LIT:0> , mpu . p & mpu . ZERO ) <EOL> self . assertEqual ( <NUM_LIT:0> , mpu . p & mpu . NEGATIVE ) <EOL> def test_eor_zp_ind_flips_bits_over_setting_z_flag ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . a = <NUM_LIT> <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> mpu . memory [ <NUM_LIT> ] = <NUM_LIT> <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT:5> , mpu . processorCycles ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . a ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . memory [ <NUM_LIT> ] ) <EOL> self . assertEqual ( mpu . ZERO , mpu . p & mpu . ZERO ) <EOL> def test_eor_zp_ind_flips_bits_over_setting_n_flag ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . a = <NUM_LIT> <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> mpu . memory [ <NUM_LIT> ] = <NUM_LIT> <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT:5> , mpu . processorCycles ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . a ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . memory [ <NUM_LIT> ] ) <EOL> self . assertEqual ( mpu . NEGATIVE , mpu . p & mpu . NEGATIVE ) <EOL> self . assertEqual ( <NUM_LIT:0> , mpu . p & mpu . ZERO ) <EOL> def test_inc_acc_increments_accum ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . memory [ <NUM_LIT> ] = <NUM_LIT> <EOL> mpu . a = <NUM_LIT> <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . a ) <EOL> self . assertEqual ( <NUM_LIT:0> , mpu . p & mpu . ZERO ) <EOL> self . assertEqual ( <NUM_LIT:0> , mpu . p & mpu . NEGATIVE ) <EOL> def test_inc_acc_increments_accum_rolls_over_and_sets_zero_flag ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . memory [ <NUM_LIT> ] = <NUM_LIT> <EOL> mpu . a = <NUM_LIT> <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . a ) <EOL> self . assertEqual ( mpu . ZERO , mpu . p & mpu . ZERO ) <EOL> self . assertEqual ( <NUM_LIT:0> , mpu . p & mpu . NEGATIVE ) <EOL> def test_inc_acc_sets_negative_flag_when_incrementing_above_7F ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . memory [ <NUM_LIT> ] = <NUM_LIT> <EOL> mpu . a = <NUM_LIT> <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . a ) <EOL> self . assertEqual ( <NUM_LIT:0> , mpu . p & mpu . ZERO ) <EOL> self . assertEqual ( mpu . NEGATIVE , mpu . p & mpu . NEGATIVE ) <EOL> def test_jmp_ind_does_not_have_page_wrap_bug ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> self . _write ( mpu . memory , <NUM_LIT:0> , ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) ) <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT:6> , mpu . processorCycles ) <EOL> def test_jmp_iax_jumps_to_address ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . x = <NUM_LIT:2> <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT:6> , mpu . processorCycles ) <EOL> def test_lda_zp_ind_loads_a_sets_n_flag ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . a = <NUM_LIT> <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> mpu . memory [ <NUM_LIT> ] = <NUM_LIT> <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT:5> , mpu . processorCycles ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . a ) <EOL> self . assertEqual ( mpu . NEGATIVE , mpu . p & mpu . NEGATIVE ) <EOL> self . assertEqual ( <NUM_LIT:0> , mpu . p & mpu . ZERO ) <EOL> def test_lda_zp_ind_loads_a_sets_z_flag ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . a = <NUM_LIT> <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> mpu . memory [ <NUM_LIT> ] = <NUM_LIT> <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT:5> , mpu . processorCycles ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . a ) <EOL> self . assertEqual ( mpu . ZERO , mpu . p & mpu . ZERO ) <EOL> self . assertEqual ( <NUM_LIT:0> , mpu . p & mpu . NEGATIVE ) <EOL> def test_ora_zp_ind_zeroes_or_zeros_sets_z_flag ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . p &= ~ ( mpu . ZERO ) <EOL> mpu . a = <NUM_LIT> <EOL> mpu . y = <NUM_LIT> <EOL> mpu . x = <NUM_LIT> <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> mpu . memory [ <NUM_LIT> ] = <NUM_LIT> <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT:5> , mpu . processorCycles ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . a ) <EOL> self . assertEqual ( mpu . ZERO , mpu . p & mpu . ZERO ) <EOL> def test_ora_zp_ind_turns_bits_on_sets_n_flag ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . p &= ~ ( mpu . NEGATIVE ) <EOL> mpu . a = <NUM_LIT> <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> mpu . memory [ <NUM_LIT> ] = <NUM_LIT> <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT:5> , mpu . processorCycles ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . a ) <EOL> self . assertEqual ( mpu . NEGATIVE , mpu . p & mpu . NEGATIVE ) <EOL> self . assertEqual ( <NUM_LIT:0> , mpu . p & mpu . ZERO ) <EOL> def test_phx_pushes_x_and_updates_sp ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . x = <NUM_LIT> <EOL> mpu . memory [ <NUM_LIT> ] = <NUM_LIT> <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . x ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . memory [ <NUM_LIT> ] ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . sp ) <EOL> self . assertEqual ( <NUM_LIT:3> , mpu . processorCycles ) <EOL> def test_phy_pushes_y_and_updates_sp ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . y = <NUM_LIT> <EOL> mpu . memory [ <NUM_LIT> ] = <NUM_LIT> <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . y ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . memory [ <NUM_LIT> ] ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . sp ) <EOL> self . assertEqual ( <NUM_LIT:3> , mpu . processorCycles ) <EOL> def test_plx_pulls_top_byte_from_stack_into_x_and_updates_sp ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . memory [ <NUM_LIT> ] = <NUM_LIT> <EOL> mpu . memory [ <NUM_LIT> ] = <NUM_LIT> <EOL> mpu . sp = <NUM_LIT> <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . x ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . sp ) <EOL> self . assertEqual ( <NUM_LIT:4> , mpu . processorCycles ) <EOL> def test_ply_pulls_top_byte_from_stack_into_y_and_updates_sp ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . memory [ <NUM_LIT> ] = <NUM_LIT> <EOL> mpu . memory [ <NUM_LIT> ] = <NUM_LIT> <EOL> mpu . sp = <NUM_LIT> <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . y ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . sp ) <EOL> self . assertEqual ( <NUM_LIT:4> , mpu . processorCycles ) <EOL> def test_rmb0_clears_bit_0_without_affecting_other_bits ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . memory [ <NUM_LIT> ] = int ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT:5> , mpu . processorCycles ) <EOL> expected = int ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> self . assertEqual ( expected , mpu . memory [ <NUM_LIT> ] ) <EOL> def test_rmb0_does_not_affect_status_register ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . memory [ <NUM_LIT> ] = int ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> expected = int ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> mpu . p = expected <EOL> mpu . step ( ) <EOL> self . assertEqual ( expected , mpu . p ) <EOL> def test_rmb1_clears_bit_1_without_affecting_other_bits ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . memory [ <NUM_LIT> ] = int ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT:5> , mpu . processorCycles ) <EOL> expected = int ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> self . assertEqual ( expected , mpu . memory [ <NUM_LIT> ] ) <EOL> def test_rmb1_does_not_affect_status_register ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . memory [ <NUM_LIT> ] = int ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> expected = int ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> mpu . p = expected <EOL> mpu . step ( ) <EOL> self . assertEqual ( expected , mpu . p ) <EOL> def test_rmb2_clears_bit_2_without_affecting_other_bits ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . memory [ <NUM_LIT> ] = int ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT:5> , mpu . processorCycles ) <EOL> expected = int ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> self . assertEqual ( expected , mpu . memory [ <NUM_LIT> ] ) <EOL> def test_rmb2_does_not_affect_status_register ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . memory [ <NUM_LIT> ] = int ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> expected = int ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> mpu . p = expected <EOL> mpu . step ( ) <EOL> self . assertEqual ( expected , mpu . p ) <EOL> def test_rmb3_clears_bit_3_without_affecting_other_bits ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . memory [ <NUM_LIT> ] = int ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT:5> , mpu . processorCycles ) <EOL> expected = int ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> self . assertEqual ( expected , mpu . memory [ <NUM_LIT> ] ) <EOL> def test_rmb3_does_not_affect_status_register ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . memory [ <NUM_LIT> ] = int ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> expected = int ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> mpu . p = expected <EOL> mpu . step ( ) <EOL> self . assertEqual ( expected , mpu . p ) <EOL> def test_rmb4_clears_bit_4_without_affecting_other_bits ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . memory [ <NUM_LIT> ] = int ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT:5> , mpu . processorCycles ) <EOL> expected = int ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> self . assertEqual ( expected , mpu . memory [ <NUM_LIT> ] ) <EOL> def test_rmb4_does_not_affect_status_register ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . memory [ <NUM_LIT> ] = int ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> expected = int ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> mpu . p = expected <EOL> mpu . step ( ) <EOL> self . assertEqual ( expected , mpu . p ) <EOL> def test_rmb5_clears_bit_5_without_affecting_other_bits ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . memory [ <NUM_LIT> ] = int ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT:5> , mpu . processorCycles ) <EOL> expected = int ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> self . assertEqual ( expected , mpu . memory [ <NUM_LIT> ] ) <EOL> def test_rmb5_does_not_affect_status_register ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . memory [ <NUM_LIT> ] = int ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> expected = int ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> mpu . p = expected <EOL> mpu . step ( ) <EOL> self . assertEqual ( expected , mpu . p ) <EOL> def test_rmb6_clears_bit_6_without_affecting_other_bits ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . memory [ <NUM_LIT> ] = int ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT:5> , mpu . processorCycles ) <EOL> expected = int ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> self . assertEqual ( expected , mpu . memory [ <NUM_LIT> ] ) <EOL> def test_rmb6_does_not_affect_status_register ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . memory [ <NUM_LIT> ] = int ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> expected = int ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> mpu . p = expected <EOL> mpu . step ( ) <EOL> self . assertEqual ( expected , mpu . p ) <EOL> def test_rmb7_clears_bit_7_without_affecting_other_bits ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . memory [ <NUM_LIT> ] = int ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT:5> , mpu . processorCycles ) <EOL> expected = int ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> self . assertEqual ( expected , mpu . memory [ <NUM_LIT> ] ) <EOL> def test_rmb7_does_not_affect_status_register ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . memory [ <NUM_LIT> ] = int ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> expected = int ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> mpu . p = expected <EOL> mpu . step ( ) <EOL> self . assertEqual ( expected , mpu . p ) <EOL> def test_sta_zp_ind_stores_a_leaves_a_and_n_flag_unchanged ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . p = flags = <NUM_LIT> & ~ ( mpu . NEGATIVE ) <EOL> mpu . a = <NUM_LIT> <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> mpu . memory [ <NUM_LIT> ] = <NUM_LIT> <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT:5> , mpu . processorCycles ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . memory [ <NUM_LIT> ] ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . a ) <EOL> self . assertEqual ( flags , mpu . p ) <EOL> def test_sta_zp_ind_stores_a_leaves_a_and_z_flag_unchanged ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . p = flags = <NUM_LIT> & ~ ( mpu . ZERO ) <EOL> mpu . a = <NUM_LIT> <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> mpu . memory [ <NUM_LIT> ] = <NUM_LIT> <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT:5> , mpu . processorCycles ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . memory [ <NUM_LIT> ] ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . a ) <EOL> self . assertEqual ( flags , mpu . p ) <EOL> def test_smb0_sets_bit_0_without_affecting_other_bits ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . memory [ <NUM_LIT> ] = int ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT:5> , mpu . processorCycles ) <EOL> expected = int ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> self . assertEqual ( expected , mpu . memory [ <NUM_LIT> ] ) <EOL> def test_smb0_does_not_affect_status_register ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . memory [ <NUM_LIT> ] = int ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> expected = int ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> mpu . p = expected <EOL> mpu . step ( ) <EOL> self . assertEqual ( expected , mpu . p ) <EOL> def test_smb1_sets_bit_1_without_affecting_other_bits ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . memory [ <NUM_LIT> ] = int ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT:5> , mpu . processorCycles ) <EOL> expected = int ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> self . assertEqual ( expected , mpu . memory [ <NUM_LIT> ] ) <EOL> def test_smb1_does_not_affect_status_register ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . memory [ <NUM_LIT> ] = int ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> expected = int ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> mpu . p = expected <EOL> mpu . step ( ) <EOL> self . assertEqual ( expected , mpu . p ) <EOL> def test_smb2_sets_bit_2_without_affecting_other_bits ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . memory [ <NUM_LIT> ] = int ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT:5> , mpu . processorCycles ) <EOL> expected = int ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> self . assertEqual ( expected , mpu . memory [ <NUM_LIT> ] ) <EOL> def test_smb2_does_not_affect_status_register ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . memory [ <NUM_LIT> ] = int ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> expected = int ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> mpu . p = expected <EOL> mpu . step ( ) <EOL> self . assertEqual ( expected , mpu . p ) <EOL> def test_smb3_sets_bit_3_without_affecting_other_bits ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . memory [ <NUM_LIT> ] = int ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT:5> , mpu . processorCycles ) <EOL> expected = int ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> self . assertEqual ( expected , mpu . memory [ <NUM_LIT> ] ) <EOL> def test_smb3_does_not_affect_status_register ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . memory [ <NUM_LIT> ] = int ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> expected = int ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> mpu . p = expected <EOL> mpu . step ( ) <EOL> self . assertEqual ( expected , mpu . p ) <EOL> def test_smb4_sets_bit_4_without_affecting_other_bits ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . memory [ <NUM_LIT> ] = int ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT:5> , mpu . processorCycles ) <EOL> expected = int ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> self . assertEqual ( expected , mpu . memory [ <NUM_LIT> ] ) <EOL> def test_smb4_does_not_affect_status_register ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . memory [ <NUM_LIT> ] = int ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> expected = int ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> mpu . p = expected <EOL> mpu . step ( ) <EOL> self . assertEqual ( expected , mpu . p ) <EOL> def test_smb5_sets_bit_5_without_affecting_other_bits ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . memory [ <NUM_LIT> ] = int ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT:5> , mpu . processorCycles ) <EOL> expected = int ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> self . assertEqual ( expected , mpu . memory [ <NUM_LIT> ] ) <EOL> def test_smb5_does_not_affect_status_register ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . memory [ <NUM_LIT> ] = int ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> expected = int ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> mpu . p = expected <EOL> mpu . step ( ) <EOL> self . assertEqual ( expected , mpu . p ) <EOL> def test_smb6_sets_bit_6_without_affecting_other_bits ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . memory [ <NUM_LIT> ] = int ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT:5> , mpu . processorCycles ) <EOL> expected = int ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> self . assertEqual ( expected , mpu . memory [ <NUM_LIT> ] ) <EOL> def test_smb6_does_not_affect_status_register ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . memory [ <NUM_LIT> ] = int ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> expected = int ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> mpu . p = expected <EOL> mpu . step ( ) <EOL> self . assertEqual ( expected , mpu . p ) <EOL> def test_smb7_sets_bit_7_without_affecting_other_bits ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . memory [ <NUM_LIT> ] = int ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT:5> , mpu . processorCycles ) <EOL> expected = int ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> self . assertEqual ( expected , mpu . memory [ <NUM_LIT> ] ) <EOL> def test_smb7_does_not_affect_status_register ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . memory [ <NUM_LIT> ] = int ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> expected = int ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> mpu . p = expected <EOL> mpu . step ( ) <EOL> self . assertEqual ( expected , mpu . p ) <EOL> def test_sbc_zp_ind_all_zeros_and_no_borrow_is_zero ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . p &= ~ ( mpu . DECIMAL ) <EOL> mpu . p |= mpu . CARRY <EOL> mpu . a = <NUM_LIT> <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> mpu . memory [ <NUM_LIT> ] = <NUM_LIT> <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT:5> , mpu . processorCycles ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . a ) <EOL> self . assertEqual ( <NUM_LIT:0> , mpu . p & mpu . NEGATIVE ) <EOL> self . assertEqual ( mpu . CARRY , mpu . CARRY ) <EOL> self . assertEqual ( mpu . ZERO , mpu . p & mpu . ZERO ) <EOL> def test_sbc_zp_ind_downto_zero_no_borrow_sets_z_clears_n ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . p &= ~ ( mpu . DECIMAL ) <EOL> mpu . p |= mpu . CARRY <EOL> mpu . a = <NUM_LIT> <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> mpu . memory [ <NUM_LIT> ] = <NUM_LIT> <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT:5> , mpu . processorCycles ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . a ) <EOL> self . assertEqual ( <NUM_LIT:0> , mpu . p & mpu . NEGATIVE ) <EOL> self . assertEqual ( mpu . CARRY , mpu . CARRY ) <EOL> self . assertEqual ( mpu . ZERO , mpu . p & mpu . ZERO ) <EOL> def test_sbc_zp_ind_downto_zero_with_borrow_sets_z_clears_n ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . p &= ~ ( mpu . DECIMAL ) <EOL> mpu . p &= ~ ( mpu . CARRY ) <EOL> mpu . a = <NUM_LIT> <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> mpu . memory [ <NUM_LIT> ] = <NUM_LIT> <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT:5> , mpu . processorCycles ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . a ) <EOL> self . assertEqual ( <NUM_LIT:0> , mpu . p & mpu . NEGATIVE ) <EOL> self . assertEqual ( mpu . CARRY , mpu . CARRY ) <EOL> self . assertEqual ( mpu . ZERO , mpu . p & mpu . ZERO ) <EOL> def test_sbc_zp_ind_downto_four_with_borrow_clears_z_n ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . p &= ~ ( mpu . DECIMAL ) <EOL> mpu . p &= ~ ( mpu . CARRY ) <EOL> mpu . a = <NUM_LIT> <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> mpu . memory [ <NUM_LIT> ] = <NUM_LIT> <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT:5> , mpu . processorCycles ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . a ) <EOL> self . assertEqual ( <NUM_LIT:0> , mpu . p & mpu . NEGATIVE ) <EOL> self . assertEqual ( <NUM_LIT:0> , mpu . p & mpu . ZERO ) <EOL> self . assertEqual ( mpu . CARRY , mpu . CARRY ) <EOL> def test_stz_zp_stores_zero ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . memory [ <NUM_LIT> ] = <NUM_LIT> <EOL> mpu . memory [ <NUM_LIT> : <NUM_LIT> + <NUM_LIT:2> ] = [ <NUM_LIT> , <NUM_LIT> ] <EOL> self . assertEqual ( <NUM_LIT> , mpu . memory [ <NUM_LIT> ] ) <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . memory [ <NUM_LIT> ] ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT:3> , mpu . processorCycles ) <EOL> def test_stz_zp_x_stores_zero ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . memory [ <NUM_LIT> ] = <NUM_LIT> <EOL> mpu . memory [ <NUM_LIT> : <NUM_LIT> + <NUM_LIT:2> ] = [ <NUM_LIT> , <NUM_LIT> ] <EOL> self . assertEqual ( <NUM_LIT> , mpu . memory [ <NUM_LIT> ] ) <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . memory [ <NUM_LIT> ] ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT:4> , mpu . processorCycles ) <EOL> def test_stz_abs_stores_zero ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . memory [ <NUM_LIT> ] = <NUM_LIT> <EOL> mpu . memory [ <NUM_LIT> : <NUM_LIT> + <NUM_LIT:3> ] = [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] <EOL> self . assertEqual ( <NUM_LIT> , mpu . memory [ <NUM_LIT> ] ) <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . memory [ <NUM_LIT> ] ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT:4> , mpu . processorCycles ) <EOL> def test_stz_abs_x_stores_zero ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . memory [ <NUM_LIT> ] = <NUM_LIT> <EOL> mpu . x = <NUM_LIT> <EOL> mpu . memory [ <NUM_LIT> : <NUM_LIT> + <NUM_LIT:3> ] = [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] <EOL> self . assertEqual ( <NUM_LIT> , mpu . memory [ <NUM_LIT> ] ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . x ) <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . memory [ <NUM_LIT> ] ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT:5> , mpu . processorCycles ) <EOL> def test_tsb_sp_ones ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . memory [ <NUM_LIT> ] = <NUM_LIT> <EOL> self . _write ( mpu . memory , <NUM_LIT> , [ <NUM_LIT> , <NUM_LIT> ] ) <EOL> mpu . a = <NUM_LIT> <EOL> self . assertEqual ( <NUM_LIT> , mpu . memory [ <NUM_LIT> ] ) <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . memory [ <NUM_LIT> ] ) <EOL> self . assertEqual ( mpu . ZERO , mpu . p & mpu . ZERO ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT:5> , mpu . processorCycles ) <EOL> def test_tsb_sp_zeros ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . memory [ <NUM_LIT> ] = <NUM_LIT> <EOL> self . _write ( mpu . memory , <NUM_LIT> , [ <NUM_LIT> , <NUM_LIT> ] ) <EOL> mpu . a = <NUM_LIT> <EOL> self . assertEqual ( <NUM_LIT> , mpu . memory [ <NUM_LIT> ] ) <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . memory [ <NUM_LIT> ] ) <EOL> self . assertEqual ( <NUM_LIT:0> , mpu . p & mpu . ZERO ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT:5> , mpu . processorCycles ) <EOL> def test_tsb_abs_ones ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . memory [ <NUM_LIT> ] = <NUM_LIT> <EOL> self . _write ( mpu . memory , <NUM_LIT> , [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] ) <EOL> mpu . a = <NUM_LIT> <EOL> self . assertEqual ( <NUM_LIT> , mpu . memory [ <NUM_LIT> ] ) <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . memory [ <NUM_LIT> ] ) <EOL> self . assertEqual ( mpu . ZERO , mpu . p & mpu . ZERO ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT:6> , mpu . processorCycles ) <EOL> def test_tsb_abs_zeros ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . memory [ <NUM_LIT> ] = <NUM_LIT> <EOL> self . _write ( mpu . memory , <NUM_LIT> , [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] ) <EOL> mpu . a = <NUM_LIT> <EOL> self . assertEqual ( <NUM_LIT> , mpu . memory [ <NUM_LIT> ] ) <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . memory [ <NUM_LIT> ] ) <EOL> self . assertEqual ( <NUM_LIT:0> , mpu . p & mpu . ZERO ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT:6> , mpu . processorCycles ) <EOL> def test_trb_sp_ones ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . memory [ <NUM_LIT> ] = <NUM_LIT> <EOL> self . _write ( mpu . memory , <NUM_LIT> , [ <NUM_LIT> , <NUM_LIT> ] ) <EOL> mpu . a = <NUM_LIT> <EOL> self . assertEqual ( <NUM_LIT> , mpu . memory [ <NUM_LIT> ] ) <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . memory [ <NUM_LIT> ] ) <EOL> self . assertEqual ( mpu . ZERO , mpu . p & mpu . ZERO ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT:5> , mpu . processorCycles ) <EOL> def test_trb_sp_zeros ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . memory [ <NUM_LIT> ] = <NUM_LIT> <EOL> self . _write ( mpu . memory , <NUM_LIT> , [ <NUM_LIT> , <NUM_LIT> ] ) <EOL> mpu . a = <NUM_LIT> <EOL> self . assertEqual ( <NUM_LIT> , mpu . memory [ <NUM_LIT> ] ) <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . memory [ <NUM_LIT> ] ) <EOL> self . assertEqual ( <NUM_LIT:0> , mpu . p & mpu . ZERO ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT:5> , mpu . processorCycles ) <EOL> def test_trb_abs_ones ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . memory [ <NUM_LIT> ] = <NUM_LIT> <EOL> self . _write ( mpu . memory , <NUM_LIT> , [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] ) <EOL> mpu . a = <NUM_LIT> <EOL> self . assertEqual ( <NUM_LIT> , mpu . memory [ <NUM_LIT> ] ) <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . memory [ <NUM_LIT> ] ) <EOL> self . assertEqual ( mpu . ZERO , mpu . p & mpu . ZERO ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT:6> , mpu . processorCycles ) <EOL> def test_trb_abs_zeros ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> mpu . memory [ <NUM_LIT> ] = <NUM_LIT> <EOL> self . _write ( mpu . memory , <NUM_LIT> , [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] ) <EOL> mpu . a = <NUM_LIT> <EOL> self . assertEqual ( <NUM_LIT> , mpu . memory [ <NUM_LIT> ] ) <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . memory [ <NUM_LIT> ] ) <EOL> self . assertEqual ( <NUM_LIT:0> , mpu . p & mpu . ZERO ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT:6> , mpu . processorCycles ) <EOL> def test_dec_a_decreases_a ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , [ <NUM_LIT> ] ) <EOL> mpu . a = <NUM_LIT> <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT:0> , mpu . p & mpu . ZERO ) <EOL> self . assertEqual ( <NUM_LIT:0> , mpu . p & mpu . NEGATIVE ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . a ) <EOL> def test_dec_a_sets_zero_flag ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , [ <NUM_LIT> ] ) <EOL> mpu . a = <NUM_LIT> <EOL> mpu . step ( ) <EOL> self . assertEqual ( mpu . ZERO , mpu . p & mpu . ZERO ) <EOL> self . assertEqual ( <NUM_LIT:0> , mpu . p & mpu . NEGATIVE ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . a ) <EOL> def test_dec_a_wraps_at_zero ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , [ <NUM_LIT> ] ) <EOL> mpu . a = <NUM_LIT> <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT:0> , mpu . p & mpu . ZERO ) <EOL> self . assertEqual ( mpu . NEGATIVE , mpu . p & mpu . NEGATIVE ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . a ) <EOL> def test_bra_forward ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , [ <NUM_LIT> , <NUM_LIT> ] ) <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT:2> , mpu . processorCycles ) <EOL> def test_bra_backward ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , [ <NUM_LIT> , <NUM_LIT> ] ) <EOL> mpu . pc = <NUM_LIT> <EOL> mpu . step ( ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT:3> , mpu . processorCycles ) <EOL> def test_wai_sets_waiting ( self ) : <EOL> mpu = self . _make_mpu ( ) <EOL> self . assertFalse ( mpu . waiting ) <EOL> self . _write ( mpu . memory , <NUM_LIT> , [ <NUM_LIT> ] ) <EOL> mpu . pc = <NUM_LIT> <EOL> mpu . step ( ) <EOL> self . assertTrue ( mpu . waiting ) <EOL> self . assertEqual ( <NUM_LIT> , mpu . pc ) <EOL> self . assertEqual ( <NUM_LIT:3> , mpu . processorCycles ) <EOL> def _get_target_class ( self ) : <EOL> return py65 . devices . mpu65c02 . MPU <EOL> def test_suite ( ) : <EOL> return unittest . findTestCases ( sys . modules [ __name__ ] ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( defaultTest = '<STR_LIT>' ) </s>
