Add support for checking deferred EI correctness

This commit is contained in:
Adrian Conlon
2025-08-14 14:57:51 +01:00
parent 4da07a8fa2
commit c67e376d4f
2 changed files with 12 additions and 6 deletions

View File

@@ -56,7 +56,7 @@ namespace LR35902
private bool Stopped { get; set; } private bool Stopped { get; set; }
private bool _deferredInterruptEnable; public bool EI { get; set; }
#region MWR pin #region MWR pin
@@ -196,10 +196,10 @@ namespace LR35902
{ {
this.prefixCB = false; this.prefixCB = false;
if ( this._deferredInterruptEnable) if (this.EI)
{ {
this.EnableInterrupts(); this.EnableInterrupts();
this._deferredInterruptEnable = false; this.EI = false;
} }
if (this.MaskedInterrupts != 0) if (this.MaskedInterrupts != 0)
@@ -235,7 +235,7 @@ namespace LR35902
this.RaiseWR(); this.RaiseWR();
this.RaiseRD(); this.RaiseRD();
this.RaiseMWR(); this.RaiseMWR();
this._deferredInterruptEnable = false; this.EI = false;
} }
protected override void HandleRESET() protected override void HandleRESET()
@@ -839,7 +839,7 @@ namespace LR35902
this.DisableInterrupts(); this.DisableInterrupts();
break; break;
case 7: // EI case 7: // EI
this._deferredInterruptEnable = true; this.EI = true;
break; break;
default: default:
break; break;

View File

@@ -219,6 +219,12 @@
ie_good = this.Check("IE", final.IE.Value, cpu.IE); ie_good = this.Check("IE", final.IE.Value, cpu.IE);
} }
var ei_good = true;
if (final.EI is not null)
{
ei_good = this.Check("EI", final.EI.Value, (byte)(cpu.EI ? 1 : 0));
}
if (!f_good) if (!f_good)
{ {
this.Messages.Add($"Expected flags: {LR35902.Disassembler.AsFlags(final.F)}"); this.Messages.Add($"Expected flags: {LR35902.Disassembler.AsFlags(final.F)}");
@@ -255,7 +261,7 @@
&& d_good && e_good && d_good && e_good
&& h_good && l_good && h_good && l_good
&& ime_good && ime_good
&& ie_good; && ie_good && ei_good;
} }
private void Raise(string what, ushort expected, ushort actual) => this.Messages.Add($"{what}: expected: {expected:X4}, actual: {actual:X4}"); private void Raise(string what, ushort expected, ushort actual) => this.Messages.Add($"{what}: expected: {expected:X4}, actual: {actual:X4}");