1
0
mirror of https://github.com/rkujawa/rk65c02.git synced 2024-12-13 01:29:57 +00:00

Implement absolute X, absolute Y addressing.

This commit is contained in:
Radosław Kujawa 2017-01-23 10:48:37 +01:00
parent 452e4b3806
commit ee16c64310

View File

@ -189,18 +189,29 @@ instruction_data_write_1(rk65c02emu_t *e, instrdef_t *id, instruction_t *i, uint
case ACCUMULATOR: case ACCUMULATOR:
case IMMEDIATE: case IMMEDIATE:
case IZPX: case IZPX:
/* XXX */
iaddr = bus_read_1(e->bus, i->op1 + e->regs.X); iaddr = bus_read_1(e->bus, i->op1 + e->regs.X);
iaddr |= (bus_read_1(e->bus, i->op1 + e->regs.X + 1) << 8); iaddr |= (bus_read_1(e->bus, i->op1 + e->regs.X + 1) << 8);
bus_write_1(e->bus, iaddr, val); bus_write_1(e->bus, iaddr, val);
case IZPY: case IZPY:
/* XXX */
iaddr = bus_read_1(e->bus, i->op1 + e->regs.Y); iaddr = bus_read_1(e->bus, i->op1 + e->regs.Y);
iaddr |= (bus_read_1(e->bus, i->op1 + e->regs.Y + 1) << 8); iaddr |= (bus_read_1(e->bus, i->op1 + e->regs.Y + 1) << 8);
bus_write_1(e->bus, iaddr, val); bus_write_1(e->bus, iaddr, val);
case RELATIVE:
case ABSOLUTEX: case ABSOLUTEX:
bus_write_1(e->bus, (i->op1 + (i->op2 << 8)) + e->regs.X, val);
break;
case ABSOLUTEY: case ABSOLUTEY:
bus_write_1(e->bus, (i->op1 + (i->op2 << 8)) + e->regs.Y, val);
break;
case RELATIVE:
case IABSOLUTE: case IABSOLUTE:
case IABSOLUTEX: case IABSOLUTEX:
/*
* IABSOLUTE, IABSOLUTEX, RELATIVE are only for branches
* and jumps. They do not read or write anything, only modify
* PC which is handled within emulation of a given opcode.
*/
default: default:
printf("unhandled addressing mode for opcode %x\n", printf("unhandled addressing mode for opcode %x\n",
i->opcode); i->opcode);
@ -255,10 +266,19 @@ instruction_data_read_1(rk65c02emu_t *e, instrdef_t *id, instruction_t *i)
rv = bus_read_1(e->bus, i->op1 + (i->op2 << 8)); rv = bus_read_1(e->bus, i->op1 + (i->op2 << 8));
break; break;
case ABSOLUTEX: case ABSOLUTEX:
rv = bus_read_1(e->bus, (i->op1 + (i->op2 << 8)) + e->regs.X);
break;
case ABSOLUTEY: case ABSOLUTEY:
rv = bus_read_1(e->bus, (i->op1 + (i->op2 << 8)) + e->regs.Y);
break;
case IABSOLUTE: case IABSOLUTE:
case IABSOLUTEX: case IABSOLUTEX:
case RELATIVE: case RELATIVE:
/*
* IABSOLUTE, IABSOLUTEX, RELATIVE are only for branches
* and jumps. They do not read or write anything, only modify
* PC which is handled within emulation of a given opcode.
*/
default: default:
printf("unhandled addressing mode for opcode %x\n", printf("unhandled addressing mode for opcode %x\n",
i->opcode); i->opcode);