Skip to content

Commit

Permalink
cpu/mb88xx: Added an internal flag set on servicing an interrupt and …
Browse files Browse the repository at this point in the history
…cleared by RTI. (#11868)

Suppressing nested interrupts appears to fix issues in Arabian (MT03916 and MT08436).

Also renamed m_nf to m_if to match the datasheet.
  • Loading branch information
hackbar committed Dec 25, 2023
1 parent ddf9fb6 commit 2a7298b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
27 changes: 14 additions & 13 deletions src/devices/cpu/mb88xx/mb88xx.cpp
Expand Up @@ -56,7 +56,7 @@ DEFINE_DEVICE_TYPE(MB8844, mb8844_cpu_device, "mb8844", "Fujitsu MB8844")
#define TEST_CF() (m_cf & 1)
#define TEST_VF() (m_vf & 1)
#define TEST_SF() (m_sf & 1)
#define TEST_NF() (m_nf & 1)
#define TEST_IF() (m_if & 1)

#define UPDATE_ST_C(v) m_st=(v&0x10) ? 0 : 1
#define UPDATE_ST_Z(v) m_st=(v==0) ? 0 : 1
Expand Down Expand Up @@ -201,7 +201,7 @@ void mb88_cpu_device::device_start()
save_item(NAME(m_cf));
save_item(NAME(m_vf));
save_item(NAME(m_sf));
save_item(NAME(m_nf));
save_item(NAME(m_if));
save_item(NAME(m_pio));
save_item(NAME(m_TH));
save_item(NAME(m_TL));
Expand All @@ -210,6 +210,7 @@ void mb88_cpu_device::device_start()
save_item(NAME(m_SB));
save_item(NAME(m_SBcount));
save_item(NAME(m_pending_interrupt));
save_item(NAME(m_in_irq));

state_add( MB88_PC, "PC", m_PC).formatstr("%02X");
state_add( MB88_PA, "PA", m_PA).formatstr("%02X");
Expand Down Expand Up @@ -239,7 +240,7 @@ void mb88_cpu_device::state_import(const device_state_entry &entry)
m_cf = (m_debugger_flags & 0x04) ? 1 : 0;
m_vf = (m_debugger_flags & 0x08) ? 1 : 0;
m_sf = (m_debugger_flags & 0x10) ? 1 : 0;
m_nf = (m_debugger_flags & 0x20) ? 1 : 0;
m_if = (m_debugger_flags & 0x20) ? 1 : 0;
break;

case STATE_GENPC:
Expand All @@ -262,7 +263,7 @@ void mb88_cpu_device::state_export(const device_state_entry &entry)
if (TEST_CF()) m_debugger_flags |= 0x04;
if (TEST_VF()) m_debugger_flags |= 0x08;
if (TEST_SF()) m_debugger_flags |= 0x10;
if (TEST_NF()) m_debugger_flags |= 0x20;
if (TEST_IF()) m_debugger_flags |= 0x20;
break;

case STATE_GENPC:
Expand All @@ -284,7 +285,7 @@ void mb88_cpu_device::state_string_export(const device_state_entry &entry, std::
TEST_CF() ? 'C' : 'c',
TEST_VF() ? 'V' : 'v',
TEST_SF() ? 'S' : 's',
TEST_NF() ? 'I' : 'i');
TEST_IF() ? 'I' : 'i');

break;
}
Expand All @@ -306,14 +307,15 @@ void mb88_cpu_device::device_reset()
m_cf = 0;
m_vf = 0;
m_sf = 0;
m_nf = 0;
m_if = 0;
m_pio = 0;
m_TH = 0;
m_TL = 0;
m_TP = 0;
m_SB = 0;
m_SBcount = 0;
m_pending_interrupt = 0;
m_in_irq = 0;
}

/***************************************************************************
Expand Down Expand Up @@ -359,12 +361,12 @@ void mb88_cpu_device::execute_set_input(int inputnum, int state)
/* On rising edge trigger interrupt.
* Note this is a logical level, the actual pin is high-to-low voltage
* triggered. */
if ( (m_pio & INT_CAUSE_EXTERNAL) && !m_nf && state != CLEAR_LINE )
if ( (m_pio & INT_CAUSE_EXTERNAL) && !m_if && state != CLEAR_LINE )
{
m_pending_interrupt |= INT_CAUSE_EXTERNAL;
}

m_nf = state != CLEAR_LINE;
m_if = state != CLEAR_LINE;
}

void mb88_cpu_device::update_pio_enable( uint8_t newpio )
Expand Down Expand Up @@ -413,8 +415,9 @@ void mb88_cpu_device::update_pio( int cycles )
}

/* process pending interrupts */
if (m_pending_interrupt & m_pio)
if (!m_in_irq && m_pending_interrupt & m_pio)
{
m_in_irq = true;
uint16_t intpc = GETPC();

m_SP[m_SI] = intpc;
Expand All @@ -429,9 +432,6 @@ void mb88_cpu_device::update_pio( int cycles )
{
/* if we have a live external source, call the irqcallback */
standard_irq_callback( 0, intpc );
/* The datasheet doesn't mention if the interrupt flag
* is cleared, but it seems to be only for this case. */
m_pio &= ~INT_CAUSE_EXTERNAL;
m_PC = 0x02;
}
else if (m_pending_interrupt & m_pio & INT_CAUSE_TIMER)
Expand Down Expand Up @@ -727,7 +727,7 @@ void mb88_cpu_device::execute_run()
break;

case 0x25: /* tsti ZCS:..x */
m_st = m_nf ^ 1;
m_st = m_if ^ 1;
break;

case 0x26: /* tstv ZCS:..x */
Expand Down Expand Up @@ -814,6 +814,7 @@ void mb88_cpu_device::execute_run()

case 0x3c: /* rti ZCS:... */
/* restore address and saved state flags on the top bits of the stack */
m_in_irq = false;
m_SI = ( m_SI - 1 ) & 3;
m_PC = m_SP[m_SI] & 0x3f;
m_PA = (m_SP[m_SI] >> 6) & 0x1f;
Expand Down
3 changes: 2 additions & 1 deletion src/devices/cpu/mb88xx/mb88xx.h
Expand Up @@ -148,7 +148,7 @@ class mb88_cpu_device : public cpu_device
uint8_t m_cf; /* Carry flag: 1 bit */
uint8_t m_vf; /* Timer overflow flag: 1 bit */
uint8_t m_sf; /* Serial Full/Empty flag: 1 bit */
uint8_t m_nf; /* Interrupt flag: 1 bit */
uint8_t m_if; /* Interrupt flag: 1 bit */

/* Peripheral Control */
uint8_t m_pio; /* Peripheral enable bits: 8 bits */
Expand Down Expand Up @@ -176,6 +176,7 @@ class mb88_cpu_device : public cpu_device

/* IRQ handling */
uint8_t m_pending_interrupt;
bool m_in_irq;

memory_access<11, 0, 0, ENDIANNESS_BIG>::cache m_cache;
memory_access<11, 0, 0, ENDIANNESS_BIG>::specific m_program;
Expand Down

0 comments on commit 2a7298b

Please sign in to comment.