mirror of
https://github.com/jborza/emu6502.git
synced 2025-02-16 17:30:27 +00:00
improved SBC tests (still failing) and compared the expected results with another emulator
This commit is contained in:
parent
bce63b3ae2
commit
0d932b7f61
16
test6502.c
16
test6502.c
@ -2059,6 +2059,7 @@ void test_SBC_IMM_carry() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void test_SBC_IMM_(byte a, byte c, byte operand, byte expected_a, byte expected_n, byte expected_z, byte expected_c, byte expected_v) {
|
void test_SBC_IMM_(byte a, byte c, byte operand, byte expected_a, byte expected_n, byte expected_z, byte expected_c, byte expected_v) {
|
||||||
|
printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
|
||||||
State6502 state = create_blank_state();
|
State6502 state = create_blank_state();
|
||||||
state.a = a;
|
state.a = a;
|
||||||
state.flags.c = c;
|
state.flags.c = c;
|
||||||
@ -2084,13 +2085,13 @@ void test_SBC_IMM_multiple() {
|
|||||||
test_SBC_IMM_(0x04, 0, /* OP */ 0x06, /*A*/ 0xFD, /*N*/ 1, /*Z*/ 0, /*C*/ 1, /*V*/ 0); //borrow from carry bit - 4 + 256 - 6 = 254
|
test_SBC_IMM_(0x04, 0, /* OP */ 0x06, /*A*/ 0xFD, /*N*/ 1, /*Z*/ 0, /*C*/ 1, /*V*/ 0); //borrow from carry bit - 4 + 256 - 6 = 254
|
||||||
//source: http://www.righto.com/2012/12/the-6502-overflow-flag-explained.html
|
//source: http://www.righto.com/2012/12/the-6502-overflow-flag-explained.html
|
||||||
//C7 - carry, B - Borrow, S7 - N, V - V
|
//C7 - carry, B - Borrow, S7 - N, V - V
|
||||||
test_SBC_IMM_(0x50, 0, /* OP */ 0xF0, /*A*/ 0x60, /*N*/ 0, /*Z*/ 0, /*C*/ 0, /*V*/ 0); //Unsigned borrow but no signed overflow
|
test_SBC_IMM_(0x50, 1, /* OP */ 0xF0, /*A*/ 0x60, /*N*/ 0, /*Z*/ 0, /*C*/ 0, /*V*/ 0); //Unsigned borrow but no signed overflow
|
||||||
test_SBC_IMM_(0x50, 1, /* OP */ 0xB0, /*A*/ 0x60, /*N*/ 0, /*Z*/ 0, /*C*/ 0, /*V*/ 1); //Unsigned borrow and signed overflow
|
test_SBC_IMM_(0x50, 1, /* OP */ 0xB0, /*A*/ 0xA0, /*N*/ 1, /*Z*/ 0, /*C*/ 0, /*V*/ 1); //Unsigned borrow and signed overflow
|
||||||
test_SBC_IMM_(0x50, 0, /* OP */ 0x70, /*A*/ 0xE0, /*N*/ 1, /*Z*/ 0, /*C*/ 0, /*V*/ 0); //Unsigned borrow but no signed overflow
|
test_SBC_IMM_(0x50, 1, /* OP */ 0x70, /*A*/ 0xE0, /*N*/ 1, /*Z*/ 0, /*C*/ 0, /*V*/ 0); //Unsigned borrow but no signed overflow
|
||||||
test_SBC_IMM_(0x50, 1, /* OP */ 0x30, /*A*/ 0x20, /*N*/ 0, /*Z*/ 0, /*C*/ 1, /*V*/ 0); //No unsigned borrow or signed overflow
|
test_SBC_IMM_(0x50, 1, /* OP */ 0x30, /*A*/ 0x20, /*N*/ 0, /*Z*/ 0, /*C*/ 1, /*V*/ 0); //No unsigned borrow or signed overflow
|
||||||
test_SBC_IMM_(0xD0, 0, /* OP */ 0xF0, /*A*/ 0xE0, /*N*/ 1, /*Z*/ 0, /*C*/ 0, /*V*/ 0); //Unsigned borrow but no signed overflow
|
test_SBC_IMM_(0xD0, 1, /* OP */ 0xF0, /*A*/ 0xE0, /*N*/ 1, /*Z*/ 0, /*C*/ 0, /*V*/ 0); //Unsigned borrow but no signed overflow
|
||||||
test_SBC_IMM_(0xD0, 1, /* OP */ 0xB0, /*A*/ 0x20, /*N*/ 0, /*Z*/ 0, /*C*/ 1, /*V*/ 0); //No unsigned borrow or signed overflow
|
test_SBC_IMM_(0xD0, 1, /* OP */ 0xB0, /*A*/ 0x20, /*N*/ 0, /*Z*/ 0, /*C*/ 1, /*V*/ 0); //No unsigned borrow or signed overflow
|
||||||
test_SBC_IMM_(0xD0, 0, /* OP */ 0x70, /*A*/ 0x60, /*N*/ 0, /*Z*/ 0, /*C*/ 1, /*V*/ 1); //No unsigned borrow but signed overflow
|
test_SBC_IMM_(0xD0, 1, /* OP */ 0x70, /*A*/ 0x60, /*N*/ 0, /*Z*/ 0, /*C*/ 1, /*V*/ 1); //No unsigned borrow but signed overflow
|
||||||
test_SBC_IMM_(0xD0, 1, /* OP */ 0x30, /*A*/ 0xA0, /*N*/ 1, /*Z*/ 0, /*C*/ 1, /*V*/ 0); //No unsigned borrow or signed overflow
|
test_SBC_IMM_(0xD0, 1, /* OP */ 0x30, /*A*/ 0xA0, /*N*/ 1, /*Z*/ 0, /*C*/ 1, /*V*/ 0); //No unsigned borrow or signed overflow
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2232,13 +2233,16 @@ fp* tests_brk[] = { test_BRK };
|
|||||||
|
|
||||||
void run_suite(fp * *suite, int size) {
|
void run_suite(fp * *suite, int size) {
|
||||||
for (int i = 0; i < size; i++)
|
for (int i = 0; i < size; i++)
|
||||||
|
{
|
||||||
|
printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
|
||||||
suite[i]();
|
suite[i]();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void run_tests() {
|
void run_tests() {
|
||||||
|
RUN(tests_sbc);
|
||||||
RUN(tests_brk);
|
RUN(tests_brk);
|
||||||
RUN(tests_jsr_rts);
|
RUN(tests_jsr_rts);
|
||||||
RUN(tests_sbc);
|
|
||||||
RUN(tests_bit);
|
RUN(tests_bit);
|
||||||
RUN(tests_adc);
|
RUN(tests_adc);
|
||||||
RUN(tests_lda);
|
RUN(tests_lda);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user