mirror of
https://github.com/rkujawa/rk65c02.git
synced 2025-04-05 14:37:44 +00:00
LDA zero page emulation and test for it.
This commit is contained in:
parent
49b70f0e1f
commit
6b7ddbf865
@ -163,7 +163,7 @@ OP_LDA_IZPX,"lda",IZPX,2,NULL
|
||||
OP_LDX_IMM,"ldx",IMMEDIATE,2,NULL
|
||||
OP_NOPI_A4,"nop",IMPLIED,1,NULL
|
||||
OP_LDY_ZP,"ldy",ZP,2,NULL
|
||||
OP_LDA_ZP,"lda",ZP,2,NULL
|
||||
OP_LDA_ZP,"lda",ZP,2,emul_lda
|
||||
OP_LDX_ZP,"ldx",ZP,2,NULL
|
||||
OP_SMB2_ZP,"smb2",ZP,2,NULL
|
||||
OP_TAY,"tay",IMPLIED,1,NULL
|
||||
|
|
@ -186,7 +186,6 @@ instruction_data_read_1(rk65c02emu_t *e, instrdef_t *id, instruction_t *i)
|
||||
case ABSOLUTEY:
|
||||
case IABSOLUTE:
|
||||
case IABSOLUTEX:
|
||||
|
||||
default:
|
||||
printf("unhandled addressing mode for opcode %x\n",
|
||||
i->opcode);
|
||||
|
@ -5,7 +5,7 @@ VASM=vasm6502_std
|
||||
VASMFLAGS=-Fbin -c02
|
||||
|
||||
TESTS=test_bus test_emulation
|
||||
TESTROMS=test_emulation_nop.rom
|
||||
TESTROMS=test_emulation_nop.rom test_emulation_lda_imm.rom test_emulation_lda_zp.rom
|
||||
|
||||
all : $(TESTS) $(TESTROMS)
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include <atf-c.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "bus.h"
|
||||
@ -8,6 +9,18 @@
|
||||
|
||||
#define ROM_LOAD_ADDR 0xC000
|
||||
|
||||
bool rom_start(rk65c02emu_t *, const char *);
|
||||
|
||||
bool
|
||||
rom_start(rk65c02emu_t *e, const char *name)
|
||||
{
|
||||
e->regs.PC = ROM_LOAD_ADDR;
|
||||
bus_load_file(e->bus, ROM_LOAD_ADDR, name);
|
||||
rk65c02_start(e);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
ATF_TC_WITHOUT_HEAD(emul_lda);
|
||||
ATF_TC_BODY(emul_lda, tc)
|
||||
{
|
||||
@ -17,17 +30,17 @@ ATF_TC_BODY(emul_lda, tc)
|
||||
b = bus_init();
|
||||
e = rk65c02_init(&b);
|
||||
|
||||
e.regs.PC = ROM_LOAD_ADDR;
|
||||
|
||||
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);
|
||||
|
||||
rk65c02_start(&e);
|
||||
|
||||
ATF_CHECK(e.regs.PC == ROM_LOAD_ADDR+3);
|
||||
/* LDA immediate */
|
||||
ATF_REQUIRE(rom_start(&e, "test_emulation_lda_imm.rom"));
|
||||
/* ATF_CHECK(e.state == STOPPED); // separate test case for states? */
|
||||
ATF_CHECK(e.regs.PC == ROM_LOAD_ADDR+3); // separate test case for PC? */
|
||||
ATF_CHECK(e.regs.A == 0xAF);
|
||||
|
||||
/* LDA zero page */
|
||||
bus_write_1(&b, 0x10, 0xAE);
|
||||
ATF_REQUIRE(rom_start(&e, "test_emulation_lda_zp.rom"));
|
||||
ATF_CHECK(e.regs.A == 0xAE);
|
||||
|
||||
bus_finish(&b);
|
||||
}
|
||||
|
||||
@ -42,7 +55,7 @@ ATF_TC_BODY(emul_nop, tc)
|
||||
|
||||
e.regs.PC = ROM_LOAD_ADDR;
|
||||
|
||||
bus_load_file(&b, 0xC000, "test_emulation_nop.rom");
|
||||
bus_load_file(&b, ROM_LOAD_ADDR, "test_emulation_nop.rom");
|
||||
|
||||
rk65c02_start(&e);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user