1
0
mirror of https://github.com/rkujawa/rk65c02.git synced 2024-12-23 07:30:31 +00:00

Experiment with emulating opcode requring operands.

Immediate lda now works.
This commit is contained in:
Radosław Kujawa 2017-01-18 22:37:00 +01:00
parent e7e30292d5
commit 92914d4aa0
4 changed files with 49 additions and 10 deletions

View File

@ -167,7 +167,7 @@ OP_LDA_ZP,"lda",ZP,2,NULL
OP_LDX_ZP,"ldx",ZP,2,NULL
OP_SMB2_ZP,"smb2",ZP,2,NULL
OP_TAY,"tay",IMPLIED,1,NULL
OP_LDA_IMM,"lda",IMMEDIATE,2,NULL
OP_LDA_IMM,"lda",IMMEDIATE,2,emul_lda
OP_TAX,"tax",IMPLIED,1,NULL
OP_NOPI_AC,"nop",IMPLIED,1,NULL
OP_LDY_ABS,"ldy",ABSOLUTE,3,NULL

1 OP_BRK brk IMPLIED 1 NULL
167 OP_LDX_ZP ldx ZP 2 NULL
168 OP_SMB2_ZP smb2 ZP 2 NULL
169 OP_TAY tay IMPLIED 1 NULL
170 OP_LDA_IMM lda IMMEDIATE 2 NULL emul_lda
171 OP_TAX tax IMPLIED 1 NULL
172 OP_NOPI_AC nop IMPLIED 1 NULL
173 OP_LDY_ABS ldy ABSOLUTE 3 NULL

View File

@ -2,12 +2,25 @@
#include "emulation.h"
void
emul_lda(rk65c02emu_t *e, instruction_t *i)
{
instrdef_t id;
id = instruction_decode(i->opcode);
printf("A: %x", e->regs.A);
e->regs.A = i->op1;
printf("A: %x", e->regs.A);
}
void
emul_nop(rk65c02emu_t *e, instruction_t *i)
{
printf("nop!\n");
printf("nop!\n");
printf("nop!\n");
/* printf("nop!\n"); */
}
void
@ -15,3 +28,4 @@ emul_stp(rk65c02emu_t *e, instruction_t *i)
{
e->state = STOPPED;
}

View File

@ -4,6 +4,7 @@
#include "rk65c02.h"
#include "instruction.h"
void emul_lda(rk65c02emu_t *, instruction_t *);
void emul_nop(rk65c02emu_t *, instruction_t *);
void emul_stp(rk65c02emu_t *, instruction_t *);

View File

@ -6,8 +6,8 @@
#include "bus.h"
#include "rk65c02.h"
ATF_TC_WITHOUT_HEAD(emulation_nop);
ATF_TC_BODY(emulation_nop, tc)
ATF_TC_WITHOUT_HEAD(emul_lda);
ATF_TC_BODY(emul_lda, tc)
{
rk65c02emu_t e;
bus_t b;
@ -17,19 +17,43 @@ ATF_TC_BODY(emulation_nop, tc)
e.regs.PC = 0;
bus_write_1(&b, 0, 0xEA);
bus_write_1(&b, 1, 0xDB);
bus_write_1(&b, 0, 0xA9);
bus_write_1(&b, 1, 0xAF);
bus_write_1(&b, 2, 0xDB);
rk65c02_start(&e);
ATF_CHECK(e.regs.PC == 2);
ATF_CHECK(e.regs.PC == 3);
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);
e.regs.PC = 0xC000;
bus_write_1(&b, 0xC000, 0xEA);
bus_write_1(&b, 0xC001, 0xDB);
rk65c02_start(&e);
ATF_CHECK(e.regs.PC == 0xC002);
bus_finish(&b);
}
ATF_TP_ADD_TCS(tp)
{
ATF_TP_ADD_TC(tp, emulation_nop);
ATF_TP_ADD_TC(tp, emul_lda);
ATF_TP_ADD_TC(tp, emul_nop);
return (atf_no_error());
}