1
0
mirror of https://github.com/jborza/emu6502.git synced 2024-06-07 16:16:37 +00:00

fixed ADC tests

This commit is contained in:
jborza 2019-04-22 10:17:26 +02:00
parent 1845eb4692
commit b53eef7d91
2 changed files with 7 additions and 2 deletions

4
cpu.c
View File

@ -151,7 +151,11 @@ void ADC(State6502 * state, byte operand) {
byte result = result_word & 0xFF;
//set overflow flag if the result's sign would change - the result doesn't fit into a signed byte
//there is overflow if the inputs do not have different signs and the input sign is different from the output sign
//meaning two numbers that have the same sign are added, and the result has a different sign.
//overflow = <'a' and 'arg' have the same sign> & <the sign of 'a'and 'sum' differs> & <extract sign bit>
state->flags.v = !((state->a ^ operand) & 0x80) && ((state->a ^ result) & 0x80);
state->a = result;
state->flags.n = is_negative(state->a);
state->flags.z = state->a == 0;

View File

@ -2045,8 +2045,9 @@ void test_ADC_IMM_multiple() {
test_ADC_IMM_exec(2, 0, 3, 5, 0, 0, 0, 0); //straight addition
test_ADC_IMM_exec(2, 1, 3, 6, 0, 0, 0, 0); //straight addition with carry
test_ADC_IMM_exec(2, 0, 254, 0, 0, 1, 1, 0); //carry and zero
test_ADC_IMM_exec(2, 0, 253, 255, 1, 0, 0, 1); //just negative
test_ADC_IMM_exec(253, 0, 6, 3, 0, 0, 1, 1); //carry and overflow
test_ADC_IMM_exec(2, 0, 253, 255, 1, 0, 0, 0); //just negative
test_ADC_IMM_exec(253, 0, 6, 3, 0, 0, 1, 0); //carry
test_ADC_IMM_exec(254, 1, 1, 0, 0, 1, 1, 0); //carry and zero
test_ADC_IMM_exec(125, 1, 2, 128, 1, 0, 0, 1); //negative and overflow
}