mirror of
https://github.com/pevans/erc-c.git
synced 2025-09-24 22:27:37 +00:00
Add functions for instructions, cycles, and address modes.
This also adds a new table for cycles, and adds unit test functions for the work as well.
This commit is contained in:
@@ -3,6 +3,13 @@
|
||||
#include "mos6502.h"
|
||||
#include "mos6502.enums.h"
|
||||
|
||||
Test(mos6502, addr_mode)
|
||||
{
|
||||
cr_assert_eq(mos6502_addr_mode(0xEA), IMP);
|
||||
cr_assert_eq(mos6502_addr_mode(0xD6), ZPX);
|
||||
cr_assert_eq(mos6502_addr_mode(0xF0), REL);
|
||||
}
|
||||
|
||||
Test(mos6502, get_address_resolver) {
|
||||
INIT_ADDR_MODE();
|
||||
|
||||
|
@@ -93,3 +93,31 @@ Test(mos6502, set_status)
|
||||
|
||||
END_CPU_TEST(mos6502);
|
||||
}
|
||||
|
||||
Test(mos6502, instruction)
|
||||
{
|
||||
cr_assert_eq(mos6502_instruction(0x1D), ORA);
|
||||
cr_assert_eq(mos6502_instruction(0xD8), CLD);
|
||||
cr_assert_eq(mos6502_instruction(0x98), TYA);
|
||||
}
|
||||
|
||||
Test(mos6502, cycles)
|
||||
{
|
||||
START_CPU_TEST(mos6502);
|
||||
|
||||
cr_assert_eq(mos6502_cycles(cpu, 0x76), 6);
|
||||
cr_assert_eq(mos6502_cycles(cpu, 0xBA), 2);
|
||||
|
||||
// In this case, we aren't cross a page boundary, and the number of
|
||||
// cycles should stay at 4
|
||||
cpu->last_addr = 0x5070;
|
||||
cpu->X = 23;
|
||||
cr_assert_eq(mos6502_cycles(cpu, 0x1D), 4);
|
||||
|
||||
// Testing that crossing a page boundary adds one to the number of
|
||||
// cycles
|
||||
cpu->X = 200;
|
||||
cr_assert_eq(mos6502_cycles(cpu, 0x1D), 5);
|
||||
|
||||
END_CPU_TEST(mos6502);
|
||||
}
|
||||
|
Reference in New Issue
Block a user