1
0
mirror of https://github.com/rkujawa/rk65c02.git synced 2025-08-07 11:26:57 +00:00

LDA zero page emulation and test for it.

This commit is contained in:
Radosław Kujawa
2017-01-19 11:49:05 +01:00
parent 49b70f0e1f
commit 6b7ddbf865
4 changed files with 25 additions and 13 deletions

View File

@@ -163,7 +163,7 @@ OP_LDA_IZPX,"lda",IZPX,2,NULL
OP_LDX_IMM,"ldx",IMMEDIATE,2,NULL OP_LDX_IMM,"ldx",IMMEDIATE,2,NULL
OP_NOPI_A4,"nop",IMPLIED,1,NULL OP_NOPI_A4,"nop",IMPLIED,1,NULL
OP_LDY_ZP,"ldy",ZP,2,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_LDX_ZP,"ldx",ZP,2,NULL
OP_SMB2_ZP,"smb2",ZP,2,NULL OP_SMB2_ZP,"smb2",ZP,2,NULL
OP_TAY,"tay",IMPLIED,1,NULL OP_TAY,"tay",IMPLIED,1,NULL
1 OP_BRK brk IMPLIED 1 NULL
163 OP_LDX_IMM ldx IMMEDIATE 2 NULL
164 OP_NOPI_A4 nop IMPLIED 1 NULL
165 OP_LDY_ZP ldy ZP 2 NULL
166 OP_LDA_ZP lda ZP 2 NULL emul_lda
167 OP_LDX_ZP ldx ZP 2 NULL
168 OP_SMB2_ZP smb2 ZP 2 NULL
169 OP_TAY tay IMPLIED 1 NULL

View File

@@ -186,7 +186,6 @@ instruction_data_read_1(rk65c02emu_t *e, instrdef_t *id, instruction_t *i)
case ABSOLUTEY: case ABSOLUTEY:
case IABSOLUTE: case IABSOLUTE:
case IABSOLUTEX: case IABSOLUTEX:
default: default:
printf("unhandled addressing mode for opcode %x\n", printf("unhandled addressing mode for opcode %x\n",
i->opcode); i->opcode);

View File

@@ -5,7 +5,7 @@ VASM=vasm6502_std
VASMFLAGS=-Fbin -c02 VASMFLAGS=-Fbin -c02
TESTS=test_bus test_emulation 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) all : $(TESTS) $(TESTROMS)

View File

@@ -1,6 +1,7 @@
#include <atf-c.h> #include <atf-c.h>
#include <stdio.h> #include <stdio.h>
#include <stdbool.h>
#include <string.h> #include <string.h>
#include "bus.h" #include "bus.h"
@@ -8,6 +9,18 @@
#define ROM_LOAD_ADDR 0xC000 #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_WITHOUT_HEAD(emul_lda);
ATF_TC_BODY(emul_lda, tc) ATF_TC_BODY(emul_lda, tc)
{ {
@@ -17,17 +30,17 @@ ATF_TC_BODY(emul_lda, tc)
b = bus_init(); b = bus_init();
e = rk65c02_init(&b); e = rk65c02_init(&b);
e.regs.PC = ROM_LOAD_ADDR; /* LDA immediate */
ATF_REQUIRE(rom_start(&e, "test_emulation_lda_imm.rom"));
bus_write_1(&b, ROM_LOAD_ADDR, 0xA9); /* ATF_CHECK(e.state == STOPPED); // separate test case for states? */
bus_write_1(&b, ROM_LOAD_ADDR+1, 0xAF); ATF_CHECK(e.regs.PC == ROM_LOAD_ADDR+3); // separate test case for PC? */
bus_write_1(&b, ROM_LOAD_ADDR+2, 0xDB);
rk65c02_start(&e);
ATF_CHECK(e.regs.PC == ROM_LOAD_ADDR+3);
ATF_CHECK(e.regs.A == 0xAF); 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); bus_finish(&b);
} }
@@ -42,7 +55,7 @@ ATF_TC_BODY(emul_nop, tc)
e.regs.PC = ROM_LOAD_ADDR; 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); rk65c02_start(&e);