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

Add emulation of WAI instruction.

This commit is contained in:
Radosław Kujawa 2017-02-09 21:53:45 +01:00
parent 5cca703020
commit 4c7a15f524
4 changed files with 30 additions and 2 deletions

View File

@ -202,7 +202,7 @@ OP_SMB4_ZP,"smb4",ZP,2,emul_smb4,false
OP_INY,"iny",IMPLIED,1,emul_iny,false
OP_CMP_IMM,"cmp",IMMEDIATE,2,emul_cmp,false
OP_DEX,"dex",IMPLIED,1,emul_dex,false
OP_WAI,"wai",IMPLIED,1,NULL,false
OP_WAI,"wai",IMPLIED,1,emul_wai,false
OP_CPY_ABS,"cpy",ABSOLUTE,3,emul_cpy,false
OP_CMP_ABS,"cmp",ABSOLUTE,3,emul_cmp,false
OP_DEC_ABS,"dec",ABSOLUTE,3,emul_dec,false

1 opcode_id mnemonic addressing size emulation modify_pc
202 OP_INY iny IMPLIED 1 emul_iny false
203 OP_CMP_IMM cmp IMMEDIATE 2 emul_cmp false
204 OP_DEX dex IMPLIED 1 emul_dex false
205 OP_WAI wai IMPLIED 1 NULL emul_wai false
206 OP_CPY_ABS cpy ABSOLUTE 3 emul_cpy false
207 OP_CMP_ABS cmp ABSOLUTE 3 emul_cmp false
208 OP_DEC_ABS dec ABSOLUTE 3 emul_dec false

View File

@ -1014,3 +1014,11 @@ emul_tya(rk65c02emu_t *e, void *id, instruction_t *i)
instruction_status_adjust_negative(e, e->regs.A);
}
/* WAI - wait for interrupt */
void
emul_wai(rk65c02emu_t *e, void *id, instruction_t *i)
{
e->state = STOPPED;
e->stopreason = WAI;
}

View File

@ -22,6 +22,7 @@ rk65c02_init(bus_t *b)
e.bus = b;
e.state = STOPPED;
e.stopreason = HOST;
e.regs.P = P_UNDEFINED|P_IRQ_DISABLE;
/* reset also clears the decimal flag */
e.regs.P &= ~P_DECIMAL;
@ -32,7 +33,25 @@ rk65c02_init(bus_t *b)
}
/*
* Do interrupt'ey things and start the interrupt service routine.
* Assert the IRQ line.
*/
void
rk65c02_assert_irq(rk65c02emu_t *e)
{
/*
* Clearly this is too simpleton'ish, because more than one device
* might want to assert the interrupt line (on hardware level it is
* active low, so can just be pulled down by any device connected
* to it.
*/
e->irq = true;
if ((e->state == STOPPED) && (e->stopreason == WAI))
rk65c02_start(e);
}
/*
* Respond to interrupt and start the interrupt service routine.
*/
void
rk65c02_irq(rk65c02emu_t *e)

View File

@ -11,6 +11,7 @@ typedef enum {
typedef enum {
STP, /* due to 65C02 STP instruction */
WAI, /* waiting for interrupt */
BREAKPOINT, /* due to breakpoint set */
WATCHPOINT, /* due to watchpoint set */
STEPPED, /* stepped appropriate number of instructions */