mirror of
https://github.com/jborza/emu6502.git
synced 2024-06-15 23:29:40 +00:00
fixed a bug setting the carry flag in ASL
This commit is contained in:
parent
4186df1468
commit
dc88cf14e6
3
cpu.c
3
cpu.c
|
@ -208,9 +208,10 @@ void CPY(State6502 * state, byte operand) {
|
||||||
cmp_internal(state, state->y, operand);
|
cmp_internal(state, state->y, operand);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Aritmetic Shift Left
|
||||||
byte asl(State6502 * state, byte operand) {
|
byte asl(State6502 * state, byte operand) {
|
||||||
byte result = operand << 1;
|
byte result = operand << 1;
|
||||||
state->flags.c = operand > 0x80;
|
state->flags.c = (operand & 0x80) == 0x80;
|
||||||
set_NZ_flags(state, result);
|
set_NZ_flags(state, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
33
test6502.c
33
test6502.c
|
@ -2391,6 +2391,37 @@ void test_RTI() {
|
||||||
test_cleanup(&state);
|
test_cleanup(&state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ASL
|
||||||
|
|
||||||
|
void test_ASL_ACC(byte a, byte expected_a, byte expected_c) {
|
||||||
|
State6502 state = create_blank_state();
|
||||||
|
state.a = a;
|
||||||
|
|
||||||
|
//arrange
|
||||||
|
char program[] = { ASL_ACC };
|
||||||
|
memcpy(state.memory, program, sizeof(program));
|
||||||
|
|
||||||
|
//act
|
||||||
|
test_step(&state);
|
||||||
|
|
||||||
|
//assert
|
||||||
|
assertA(&state, expected_a);
|
||||||
|
assert_flag_c(&state, expected_c);
|
||||||
|
|
||||||
|
//cleanup
|
||||||
|
test_cleanup(&state);
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_asl_multiple() {
|
||||||
|
test_ASL_ACC(/* A */ 0x0, /* Result*/ 0x0, /* C */ 0);
|
||||||
|
test_ASL_ACC(/* A */ 0x1, /* Result*/ 0x2, /* C */ 0);
|
||||||
|
test_ASL_ACC(/* A */ 0x1F, /* Result*/ 0x3E, /* C */ 0);
|
||||||
|
test_ASL_ACC(/* A */ 0x7F, /* Result*/ 0xFE, /* C */ 0);
|
||||||
|
test_ASL_ACC(/* A */ 0x80, /* Result*/ 0x0, /* C */ 1);
|
||||||
|
test_ASL_ACC(/* A */ 0x81, /* Result*/ 0x2, /* C */ 1);
|
||||||
|
test_ASL_ACC(/* A */ 0xFF, /* Result*/ 0xFE, /* C */ 1);
|
||||||
|
}
|
||||||
|
|
||||||
/////////////////////
|
/////////////////////
|
||||||
|
|
||||||
typedef void fp();
|
typedef void fp();
|
||||||
|
@ -2419,6 +2450,7 @@ fp* tests_jsr_rts[] = { test_JSR, test_JSR_RTS, test_RTS };
|
||||||
fp* tests_brk[] = { test_BRK };
|
fp* tests_brk[] = { test_BRK };
|
||||||
fp* tests_branch[] = { test_branching_multiple };
|
fp* tests_branch[] = { test_branching_multiple };
|
||||||
fp* tests_rti[] = { test_RTI };
|
fp* tests_rti[] = { test_RTI };
|
||||||
|
fp* tests_asl[] = { test_asl_multiple };
|
||||||
|
|
||||||
#define RUN(suite) run_suite(suite, sizeof(suite)/sizeof(fp*))
|
#define RUN(suite) run_suite(suite, sizeof(suite)/sizeof(fp*))
|
||||||
|
|
||||||
|
@ -2431,6 +2463,7 @@ void run_suite(fp * *suite, int size) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void run_tests() {
|
void run_tests() {
|
||||||
|
RUN(tests_asl);
|
||||||
RUN(tests_rti);
|
RUN(tests_rti);
|
||||||
RUN(tests_branch);
|
RUN(tests_branch);
|
||||||
RUN(tests_sbc);
|
RUN(tests_sbc);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user