H8: fix stack trashing when simultaneous IRQ sources asserted [R. Belmont]

This commit is contained in:
R. Belmont 2010-02-20 05:09:24 +00:00
parent 1ad1e26df8
commit ccd496af62
3 changed files with 16 additions and 2 deletions

View File

@ -138,7 +138,7 @@ static void h8_set_ccr(h83xx_state *h8, UINT8 data)
if(h8->ccr & UIFLAG) h8->h8uiflag = 1;
if(h8->ccr & IFLAG) h8->h8iflag = 1;
h8_check_irqs(h8);
if (!h8->incheckirqs) h8_check_irqs(h8);
}
static INT16 h8_getreg16(h83xx_state *h8, UINT8 reg)
@ -256,6 +256,8 @@ static CPU_RESET(h8)
h8->h8err = 0;
h8->pc = h8_mem_read32(h8, 0) & 0xffffff;
h8->incheckirqs = 0;
// disable timers
h8->h8TSTR = 0;
@ -323,6 +325,9 @@ static int h8_get_priority(h83xx_state *h8, UINT8 bit)
static void h8_check_irqs(h83xx_state *h8)
{
int lv = -1;
h8->incheckirqs = 1;
if (h8->h8iflag == 0)
{
lv = 0;
@ -377,6 +382,8 @@ static void h8_check_irqs(h83xx_state *h8)
if (source != 0xff)
h8_GenException(h8, source);
}
h8->incheckirqs = 0;
}
#define H8_ADDR_MASK 0xffffff

View File

@ -154,7 +154,7 @@ static void h8_set_ccr(h83xx_state *h8, UINT8 data)
if(h8->ccr & UIFLAG) h8->h8uiflag = 1;
if(h8->ccr & IFLAG) h8->h8iflag = 1;
h8_check_irqs(h8);
if (!h8->incheckirqs) h8_check_irqs(h8);
}
static INT16 h8_getreg16(h83xx_state *h8, UINT8 reg)
@ -268,6 +268,8 @@ static CPU_RESET(h8bit)
h8->h8err = 0;
h8->pc = h8_mem_read16(h8, 0);
h8->incheckirqs = 0;
// disable timers
h8->h8TSTR = 0;
h8->FRC = 0;
@ -341,6 +343,8 @@ static void h8_check_irqs(h83xx_state *h8)
{
int lv = 0;
h8->incheckirqs = 1;
if (h8->h8iflag != 0)
{
lv = 2;
@ -386,6 +390,8 @@ static void h8_check_irqs(h83xx_state *h8)
h8_GenException(h8, source);
}
}
h8->incheckirqs = 0;
}
#define H8_ADDR_MASK 0xffff

View File

@ -23,6 +23,7 @@ struct _h83xx_state
UINT8 ccr;
UINT8 h8nflag, h8vflag, h8cflag, h8zflag, h8iflag, h8hflag;
UINT8 h8uflag, h8uiflag;
UINT8 incheckirqs;
cpu_irq_callback irq_cb;
running_device *device;