Skip to content

Commit 158a195

Browse files
committed
HLT命令実行時に操作可能にする
1 parent 44833cf commit 158a195

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

asc-simulator-test/Utils.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public static async Task<TestASC> New(ASC.ILoadable[] data)
4646

4747
machine.Stepped += (ce) => {
4848
Console.WriteLine("STEPPED {0}", ce.InstructionCount);
49-
machine.HLT();
49+
machine.Stop();
5050
};
5151

5252
machine.ALU.AssignZTrue += () => {

asc-simulator/Machine/ASC.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ public ushort ToUShort()
207207
}
208208
}
209209

210+
public delegate void MachineStateEventHandler();
210211

211212
// 命令サイクル中に呼び出されるイベント
212213
public event Common.CycleEventHandler CycleBegin;
@@ -219,6 +220,9 @@ public ushort ToUShort()
219220
// ステップ実行が終了したとき
220221
public event Common.CycleEventHandler Stepped;
221222

223+
// HLT命令が実行されたとき
224+
public event MachineStateEventHandler Halted;
225+
222226
// データ変更イベント
223227
public event Common.DataMovedEventHandler PreDataMoved;
224228
public event Common.DataMovedEventHandler DataMoved;
@@ -272,7 +276,7 @@ public ASC()
272276
this.ALU.Overflowed += (ove) =>
273277
{
274278
// オーバーフロー発生時は次の状態で停止する
275-
this.HLT(StopMode.PerStep);
279+
this.Stop(StopMode.PerStep);
276280
};
277281

278282
this.CycleBegin += (ce) => { };
@@ -283,6 +287,7 @@ public ASC()
283287
this.CycleUpdatePC += (ce) => { };
284288

285289
this.Stepped += (ce) => { };
290+
this.Halted += () => { };
286291

287292
this.PreDataMoved += (dme) => { };
288293
this.DataMoved += (dme) => { };
@@ -354,7 +359,7 @@ public void RunOperate()
354359
}
355360

356361
// マシンを停止する
357-
public void HLT(StopMode? nextMode = null)
362+
public void Stop(StopMode? nextMode = null)
358363
{
359364
// 実行モード別のResetEventをリセットしてスレッドを止める
360365
switch (nextMode ?? this._Mode)
@@ -682,7 +687,8 @@ private void _Loop()
682687
break;
683688

684689
case Common.Defines.OPECODE.HLT:
685-
this.HLT();
690+
this.Stop();
691+
this.Halted();
686692
break;
687693
}
688694

asc-simulator/UI/Forms/MainForm.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public Machine.ASC Machine
5858
this._Machine.ALU.Overflowed += this.DidOverflowed;
5959

6060
this._Machine.Stepped += this.DidStepped;
61+
this._Machine.Halted += this.DidHalted;
6162

6263
this.Machine.Registers.DataChanged += this.DidDataChanged;
6364
this.Machine.Registers.DataAccessed += this.DidDataAccessed;
@@ -329,7 +330,7 @@ private void _EnableViews()
329330
// マシンの動作を停止する
330331
private void _StopMachine()
331332
{
332-
this.Machine.HLT();
333+
this.Machine.Stop();
333334
this._EnableViews();
334335
this.Display.Invalidate();
335336
}
@@ -910,6 +911,11 @@ private void DidStepped(Common.CycleEventArgs ce)
910911
this._StopMachine();
911912
}
912913

914+
private void DidHalted()
915+
{
916+
this._StopMachine();
917+
}
918+
913919
#endregion
914920

915921
#region 例外イベントハンドラ

0 commit comments

Comments
 (0)