mirror of
https://github.com/jborza/emu6502.git
synced 2024-11-25 03:34:40 +00:00
added tests for CPX, CPY
This commit is contained in:
parent
df2f125588
commit
1c4e2f45b5
6
cpu.c
6
cpu.c
@ -326,10 +326,10 @@ int emulate_6502_op(State6502 * state) {
|
||||
case TYA: state->a = state->y; set_NZ_flags(state, state->a); break;
|
||||
case TSX: state->x = state->sp; set_NZ_flags(state, state->x); break;
|
||||
case TXS: state->sp = state->x; set_NZ_flags(state, state->x); break;
|
||||
case CMP_IMM: CMP(state, pop_byte(state)); break;
|
||||
case CMP_ZP: CMP(state, get_byte_zero_page(state)); break;
|
||||
case CMP_IMM: CMP(state, pop_byte(state)); break; //TODO test
|
||||
case CMP_ZP: CMP(state, get_byte_zero_page(state)); break; //TODO test
|
||||
case CMP_ZPX: CMP(state, get_byte_zero_page_x(state)); break; //TODO test
|
||||
case CMP_ABS: CMP(state, get_byte_absolute(state)); break;//TODO test
|
||||
case CMP_ABS: CMP(state, get_byte_absolute(state)); break;
|
||||
case CMP_ABSX: CMP(state, get_byte_absolute_x(state)); break;//TODO test
|
||||
case CMP_ABSY: CMP(state, get_byte_absolute_y(state)); break;//TODO test
|
||||
case CMP_INDX: CMP(state, get_byte_indirect_x(state)); break;//TODO test
|
||||
|
38
test6502.c
38
test6502.c
@ -1933,7 +1933,6 @@ void test_CMP_ABS_greater_2() {
|
||||
test_cleanup(&state);
|
||||
}
|
||||
|
||||
|
||||
void test_CMP_ABS_less_than() {
|
||||
State6502 state = create_blank_state();
|
||||
state.a = 0x08;
|
||||
@ -1950,6 +1949,41 @@ void test_CMP_ABS_less_than() {
|
||||
test_cleanup(&state);
|
||||
}
|
||||
|
||||
// CPX, CPY
|
||||
void test_CPX_ABS() {
|
||||
State6502 state = create_blank_state();
|
||||
state.x = 0x82;
|
||||
state.flags.n = 1;
|
||||
|
||||
char program[] = { CPX_ABS, 0x45, 0x03 };
|
||||
memcpy(state.memory, program, sizeof(program));
|
||||
state.memory[0x0345] = 0x1A;
|
||||
test_step(&state);
|
||||
|
||||
assert_flag_z(&state, 0x00); // 0x82 != 0x1A
|
||||
assert_flag_n(&state, 0x00);
|
||||
assert_flag_c(&state, 0x01); // 0x82 > 0x1A
|
||||
|
||||
test_cleanup(&state);
|
||||
}
|
||||
|
||||
void test_CPY_ABS() {
|
||||
State6502 state = create_blank_state();
|
||||
state.y = 0x82;
|
||||
state.flags.n = 1;
|
||||
|
||||
char program[] = { CPY_ABS, 0x45, 0x03 };
|
||||
memcpy(state.memory, program, sizeof(program));
|
||||
state.memory[0x0345] = 0x1A;
|
||||
test_step(&state);
|
||||
|
||||
assert_flag_z(&state, 0x00); // 0x82 != 0x1A
|
||||
assert_flag_n(&state, 0x00);
|
||||
assert_flag_c(&state, 0x01); // 0x82 > 0x1A
|
||||
|
||||
test_cleanup(&state);
|
||||
}
|
||||
|
||||
/////////////////////
|
||||
|
||||
typedef void fp();
|
||||
@ -1970,7 +2004,7 @@ fp* tests_pha_pla[] = { test_PHA, test_PLA, test_PHA_PLA };
|
||||
fp* tests_txs_tsx[] = { test_TXS, test_TSX };
|
||||
fp* tests_php_plp[] = { test_PHP, test_PLP };
|
||||
fp* tests_jmp[] = { test_JMP, test_JMP_IND, test_JMP_IND_wrap };
|
||||
fp* tests_cmp[] = { test_CMP_ABS_equal, test_CMP_ABS_greater, test_CMP_ABS_greater_2, test_CMP_ABS_less_than };
|
||||
fp* tests_cmp[] = { test_CMP_ABS_equal, test_CMP_ABS_greater, test_CMP_ABS_greater_2, test_CMP_ABS_less_than, test_CPX_ABS, test_CPY_ABS };
|
||||
|
||||
#define RUN(suite) run_suite(suite, sizeof(suite)/sizeof(fp*))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user