2017-01-18 16:18:19 +00:00
|
|
|
#include <atf-c.h>
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "bus.h"
|
|
|
|
#include "rk65c02.h"
|
|
|
|
|
2017-01-18 23:57:09 +00:00
|
|
|
#define ROM_LOAD_ADDR 0xC000
|
|
|
|
|
2017-01-18 21:37:00 +00:00
|
|
|
ATF_TC_WITHOUT_HEAD(emul_lda);
|
|
|
|
ATF_TC_BODY(emul_lda, tc)
|
2017-01-18 16:18:19 +00:00
|
|
|
{
|
|
|
|
rk65c02emu_t e;
|
|
|
|
bus_t b;
|
|
|
|
|
|
|
|
b = bus_init();
|
|
|
|
e = rk65c02_init(&b);
|
|
|
|
|
2017-01-18 23:57:09 +00:00
|
|
|
e.regs.PC = ROM_LOAD_ADDR;
|
2017-01-18 16:18:19 +00:00
|
|
|
|
2017-01-18 23:57:09 +00:00
|
|
|
bus_write_1(&b, ROM_LOAD_ADDR, 0xA9);
|
|
|
|
bus_write_1(&b, ROM_LOAD_ADDR+1, 0xAF);
|
|
|
|
bus_write_1(&b, ROM_LOAD_ADDR+2, 0xDB);
|
2017-01-18 16:18:19 +00:00
|
|
|
|
|
|
|
rk65c02_start(&e);
|
|
|
|
|
2017-01-18 23:57:09 +00:00
|
|
|
ATF_CHECK(e.regs.PC == ROM_LOAD_ADDR+3);
|
2017-01-18 21:37:00 +00:00
|
|
|
ATF_CHECK(e.regs.A == 0xAF);
|
|
|
|
|
|
|
|
bus_finish(&b);
|
|
|
|
}
|
|
|
|
|
|
|
|
ATF_TC_WITHOUT_HEAD(emul_nop);
|
|
|
|
ATF_TC_BODY(emul_nop, tc)
|
|
|
|
{
|
|
|
|
rk65c02emu_t e;
|
|
|
|
bus_t b;
|
|
|
|
|
|
|
|
b = bus_init();
|
|
|
|
e = rk65c02_init(&b);
|
|
|
|
|
2017-01-18 23:57:09 +00:00
|
|
|
e.regs.PC = ROM_LOAD_ADDR;
|
2017-01-18 21:37:00 +00:00
|
|
|
|
2017-01-18 23:57:09 +00:00
|
|
|
bus_load_file(&b, 0xC000, "test_emulation_nop.rom");
|
2017-01-18 21:37:00 +00:00
|
|
|
|
|
|
|
rk65c02_start(&e);
|
|
|
|
|
2017-01-18 23:57:09 +00:00
|
|
|
ATF_CHECK(e.regs.PC == ROM_LOAD_ADDR+2);
|
2017-01-18 16:18:19 +00:00
|
|
|
|
|
|
|
bus_finish(&b);
|
|
|
|
}
|
|
|
|
|
|
|
|
ATF_TP_ADD_TCS(tp)
|
|
|
|
{
|
2017-01-18 21:37:00 +00:00
|
|
|
ATF_TP_ADD_TC(tp, emul_lda);
|
|
|
|
ATF_TP_ADD_TC(tp, emul_nop);
|
2017-01-18 16:18:19 +00:00
|
|
|
|
|
|
|
return (atf_no_error());
|
|
|
|
}
|
|
|
|
|