updated prev commit with wrt irq recursion

This commit is contained in:
Michaël Banaan Ananas 2014-02-19 22:16:34 +00:00
parent fdba3ea068
commit ac105cf061
2 changed files with 26 additions and 35 deletions

View File

@ -54,7 +54,6 @@ mn10200_device::mn10200_device(const machine_config &mconfig, const char *tag, d
void mn10200_device::device_start() void mn10200_device::device_start()
{ {
m_p4 = 0xf; m_p4 = 0xf;
m_irq_semaphore = false;
m_program = &space(AS_PROGRAM); m_program = &space(AS_PROGRAM);
m_io = &space(AS_IO); m_io = &space(AS_IO);
@ -136,7 +135,7 @@ void mn10200_device::device_start()
save_item(NAME(m_extmdh)); save_item(NAME(m_extmdh));
save_item(NAME(m_icrl)); save_item(NAME(m_icrl));
save_item(NAME(m_icrh)); save_item(NAME(m_icrh));
save_item(NAME(m_ddr)); save_item(NAME(m_possible_irq));
// register for debugger // register for debugger
state_add( MN10200_PC, "PC", m_pc ).mask(0xffffff).formatstr("%06X"); state_add( MN10200_PC, "PC", m_pc ).mask(0xffffff).formatstr("%06X");
@ -212,6 +211,8 @@ void mn10200_device::device_reset()
for (int i = 0; i < 2; i++) for (int i = 0; i < 2; i++)
for (int address = 0xfc04; address < 0x10000; address++) for (int address = 0xfc04; address < 0x10000; address++)
write_mem16(address, 0); write_mem16(address, 0);
m_possible_irq = false;
} }
@ -219,7 +220,6 @@ void mn10200_device::device_reset()
void mn10200_device::take_irq(int level, int group) void mn10200_device::take_irq(int level, int group)
{ {
m_irq_semaphore = true;
m_cycles -= 7; m_cycles -= 7;
write_mem24(m_a[3] - 4, m_pc); write_mem24(m_a[3] - 4, m_pc);
@ -228,16 +228,10 @@ void mn10200_device::take_irq(int level, int group)
change_pc(0x80008); change_pc(0x80008);
m_psw = (m_psw & 0xf0ff) | (level << 8); m_psw = (m_psw & 0xf0ff) | (level << 8);
m_iagr = group; m_iagr = group;
m_irq_semaphore = false;
} }
void mn10200_device::check_irq() void mn10200_device::check_irq()
{ {
// don't recurse
if (m_irq_semaphore)
return;
if (!m_nmicr && !(m_psw & FLAG_IE)) if (!m_nmicr && !(m_psw & FLAG_IE))
return; return;
@ -274,7 +268,7 @@ void mn10200_device::check_ext_irq()
m_icrl[8] |= (1 << (4 + i)); m_icrl[8] |= (1 << (4 + i));
} }
check_irq(); m_possible_irq = true;
} }
void mn10200_device::execute_set_input(int irqnum, int state) void mn10200_device::execute_set_input(int irqnum, int state)
@ -315,7 +309,7 @@ void mn10200_device::execute_set_input(int irqnum, int state)
if (active) if (active)
{ {
m_icrl[8] |= (1 << (4 + irqnum)); m_icrl[8] |= (1 << (4 + irqnum));
check_irq(); m_possible_irq = true;
} }
} }
@ -346,7 +340,7 @@ int mn10200_device::timer_tick_simple(int tmr)
{ {
// trigger irq // trigger irq
m_icrl[1 + (tmr >> 2)] |= (1 << (4 + (tmr & 3))); m_icrl[1 + (tmr >> 2)] |= (1 << (4 + (tmr & 3)));
check_irq(); m_possible_irq = true;
return 0; return 0;
} }
@ -480,16 +474,20 @@ void mn10200_device::do_branch(bool state)
void mn10200_device::execute_run() void mn10200_device::execute_run()
{ {
bool possible_irq = false;
UINT8 op;
while (m_cycles > 0) while (m_cycles > 0)
{ {
// internal peripheral, external pin, or prev instruction may have changed irq state
while (m_possible_irq)
{
m_possible_irq = false;
check_irq();
}
debugger_instruction_hook(this, m_pc); debugger_instruction_hook(this, m_pc);
m_cycles -= 1; m_cycles -= 1;
op = read_arg8(m_pc); UINT8 op = read_arg8(m_pc);
m_pc += 1; m_pc += 1;
// main opcodes // main opcodes
@ -713,7 +711,7 @@ void mn10200_device::execute_run()
m_psw = read_mem16(m_a[3]); m_psw = read_mem16(m_a[3]);
change_pc(read_mem24(m_a[3] + 2)); change_pc(read_mem24(m_a[3] + 2));
m_a[3] += 6; m_a[3] += 6;
possible_irq = true; m_possible_irq = true;
break; break;
// cmp imm16, an // cmp imm16, an
@ -753,7 +751,7 @@ void mn10200_device::execute_run()
default: default:
illegal(0, op); illegal(0, op);
possible_irq = true; m_possible_irq = true;
break; break;
@ -839,7 +837,7 @@ void mn10200_device::execute_run()
default: default:
illegal(0xf0, op); illegal(0xf0, op);
possible_irq = true; m_possible_irq = true;
break; break;
} }
break; break;
@ -970,7 +968,7 @@ void mn10200_device::execute_run()
default: default:
illegal(0xf2, op); illegal(0xf2, op);
possible_irq = true; m_possible_irq = true;
break; break;
} }
break; break;
@ -1130,7 +1128,7 @@ void mn10200_device::execute_run()
case 0xd0: case 0xd4: case 0xd8: case 0xdc: case 0xd0: case 0xd4: case 0xd8: case 0xdc:
m_cycles -= 1; m_cycles -= 1;
m_psw = m_d[op>>2&3]; m_psw = m_d[op>>2&3];
possible_irq = true; m_possible_irq = true;
break; break;
// mov mdr, dn // mov mdr, dn
@ -1150,7 +1148,7 @@ void mn10200_device::execute_run()
default: default:
illegal(0xf3, op); illegal(0xf3, op);
possible_irq = true; m_possible_irq = true;
break; break;
} }
break; break;
@ -1316,7 +1314,7 @@ void mn10200_device::execute_run()
default: default:
illegal(0xf4, op); illegal(0xf4, op);
possible_irq = true; m_possible_irq = true;
break; break;
} }
m_pc += 3; m_pc += 3;
@ -1477,7 +1475,7 @@ void mn10200_device::execute_run()
default: default:
illegal(0xf5, op); illegal(0xf5, op);
possible_irq = true; m_possible_irq = true;
break; break;
} }
m_pc += 1; m_pc += 1;
@ -1524,7 +1522,7 @@ void mn10200_device::execute_run()
case 0x14: case 0x14:
m_cycles -= 1; m_cycles -= 1;
m_psw |= read_arg16(m_pc); m_psw |= read_arg16(m_pc);
possible_irq = true; m_possible_irq = true;
break; break;
// add imm16, dn // add imm16, dn
@ -1624,7 +1622,7 @@ void mn10200_device::execute_run()
default: default:
illegal(0xf7, op); illegal(0xf7, op);
possible_irq = true; m_possible_irq = true;
break; break;
} }
m_pc += 2; m_pc += 2;
@ -1632,13 +1630,6 @@ void mn10200_device::execute_run()
} // end main switch } // end main switch
// instruction may have changed irq state
if (possible_irq)
{
check_irq();
possible_irq = false;
}
} // end loop } // end loop
} }
@ -1690,7 +1681,7 @@ WRITE8_MEMBER(mn10200_device::io_control_w)
case 0x043: case 0x045: case 0x047: case 0x049: case 0x04b: case 0x043: case 0x045: case 0x047: case 0x049: case 0x04b:
case 0x04d: case 0x04f: case 0x051: case 0x053: case 0x055: case 0x04d: case 0x04f: case 0x051: case 0x053: case 0x055:
m_icrh[(offset & 0x3f) >> 1] = data; m_icrh[(offset & 0x3f) >> 1] = data;
check_irq(); m_possible_irq = true;
break; break;
// external irq control // external irq control

View File

@ -143,7 +143,7 @@ private:
UINT8 m_ddr[8]; UINT8 m_ddr[8];
bool m_irq_semaphore; bool m_possible_irq;
attotime m_sysclock_base; attotime m_sysclock_base;
int m_cycles; int m_cycles;