private void Interrupt(Interrupts interrupt, ushort? errorCode = null)
{
// !!! Must handle stack_values
// If this is not a reset interrupt, we should save PS and PC.
if (interrupt != Interrupts.Reset) {
ushort ps = PS;
if (Interrupt_IsFault(interrupt))
PS_U = !PS_S;
PS_S = true;
PS_I = true;
PS_Q = interrupt == Interrupts.HWI;
StackPush(0xffff, ps);
StackPush(0xffff, PC);
if (errorCode != null)
StackPush(0xffff, errorCode.Value);
}
PC = ReadMemInt16((ushort)((ushort)interrupt * 2), SegmentIndex.IS);
Cycles += 7;
}