1
0
mirror of https://github.com/pevans/erc-c.git synced 2024-11-30 08:51:53 +00:00
erc-c/tests/mos6502.exec.c

64 lines
1.2 KiB
C
Raw Normal View History

2017-12-04 02:19:17 +00:00
#include <criterion/criterion.h>
#include "mos6502.h"
#include "mos6502.enums.h"
#include "mos6502.tests.h"
2017-12-04 02:19:17 +00:00
TestSuite(mos6502_exec, .init = setup, .fini = teardown);
2017-12-04 02:19:17 +00:00
Test(mos6502_exec, brk)
{
vm_8bit orig_P = cpu->P;
2017-12-04 02:19:17 +00:00
cpu->PC = 123;
mos6502_handle_brk(cpu, 0);
cr_assert_eq(cpu->PC, 125);
cr_assert_eq(cpu->P & INTERRUPT, INTERRUPT);
cr_assert_eq(mos6502_pop_stack(cpu), orig_P);
2017-12-04 02:19:17 +00:00
cr_assert_eq(mos6502_pop_stack(cpu), 123);
}
Test(mos6502_exec, jmp)
2017-12-04 02:19:17 +00:00
{
cpu->PC = 123;
cpu->last_addr = 234;
mos6502_handle_jmp(cpu, 0);
cr_assert_eq(cpu->PC, 234);
}
Test(mos6502_exec, jsr)
2017-12-04 02:19:17 +00:00
{
cpu->PC = 123;
cpu->last_addr = 235;
mos6502_handle_jsr(cpu, 0);
cr_assert_eq(cpu->PC, 235);
cr_assert_eq(mos6502_pop_stack(cpu), 125);
}
Test(mos6502_exec, nop)
2017-12-04 02:19:17 +00:00
{
// currently this test does nothing -- we _should_ test to see if we
// pass the right number of cycles, though.
}
Test(mos6502_exec, rti)
2017-12-04 02:19:17 +00:00
{
mos6502_push_stack(cpu, 222);
mos6502_push_stack(cpu, cpu->P);
2017-12-04 02:19:17 +00:00
mos6502_handle_rti(cpu, 0);
cr_assert_eq(cpu->PC, 222);
}
Test(mos6502_exec, rts)
2017-12-04 02:19:17 +00:00
{
mos6502_push_stack(cpu, 333);
mos6502_handle_rts(cpu, 0);
2017-12-04 02:19:17 +00:00
cr_assert_eq(cpu->PC, 333);
}