mirror of
https://github.com/MoleskiCoder/EightBitNet.git
synced 2026-04-24 02:17:47 +00:00
.net 9 analysis changes
This commit is contained in:
@@ -3,7 +3,6 @@
|
|||||||
// </copyright>
|
// </copyright>
|
||||||
namespace Fuse
|
namespace Fuse
|
||||||
{
|
{
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|||||||
+45
-10
@@ -2,9 +2,10 @@
|
|||||||
// Copyright (c) Adrian Conlon. All rights reserved.
|
// Copyright (c) Adrian Conlon. All rights reserved.
|
||||||
// </copyright>
|
// </copyright>
|
||||||
|
|
||||||
namespace EightBit
|
namespace Intel8080
|
||||||
{
|
{
|
||||||
using System;
|
using EightBit;
|
||||||
|
using System.Globalization;
|
||||||
|
|
||||||
public class Disassembler(Bus bus)
|
public class Disassembler(Bus bus)
|
||||||
{
|
{
|
||||||
@@ -24,6 +25,8 @@ namespace EightBit
|
|||||||
|
|
||||||
public static string State(Intel8080 cpu)
|
public static string State(Intel8080 cpu)
|
||||||
{
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(cpu);
|
||||||
|
|
||||||
var pc = cpu.PC.Word;
|
var pc = cpu.PC.Word;
|
||||||
var sp = cpu.SP.Word;
|
var sp = cpu.SP.Word;
|
||||||
|
|
||||||
@@ -47,7 +50,11 @@ namespace EightBit
|
|||||||
+ $"H={h:x2} L={l:x2}";
|
+ $"H={h:x2} L={l:x2}";
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Disassemble(Intel8080 cpu) => this.Disassemble(cpu, cpu.PC.Word);
|
public string Disassemble(Intel8080 cpu)
|
||||||
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(cpu);
|
||||||
|
return this.Disassemble(cpu, cpu.PC.Word);
|
||||||
|
}
|
||||||
|
|
||||||
private static string CC(int flag) => flag switch
|
private static string CC(int flag) => flag switch
|
||||||
{
|
{
|
||||||
@@ -59,7 +66,7 @@ namespace EightBit
|
|||||||
5 => "PE",
|
5 => "PE",
|
||||||
6 => "P",
|
6 => "P",
|
||||||
7 => "M",
|
7 => "M",
|
||||||
_ => throw new System.ArgumentOutOfRangeException(nameof(flag)),
|
_ => throw new ArgumentOutOfRangeException(nameof(flag)),
|
||||||
};
|
};
|
||||||
|
|
||||||
private static string ALU(int which) => which switch
|
private static string ALU(int which) => which switch
|
||||||
@@ -72,7 +79,7 @@ namespace EightBit
|
|||||||
5 => "XRA", // XOR n
|
5 => "XRA", // XOR n
|
||||||
6 => "ORA", // OR n
|
6 => "ORA", // OR n
|
||||||
7 => "CMP", // CP n
|
7 => "CMP", // CP n
|
||||||
_ => throw new System.ArgumentOutOfRangeException(nameof(which)),
|
_ => throw new ArgumentOutOfRangeException(nameof(which)),
|
||||||
};
|
};
|
||||||
|
|
||||||
private static string ALU2(int which) => which switch
|
private static string ALU2(int which) => which switch
|
||||||
@@ -85,7 +92,7 @@ namespace EightBit
|
|||||||
5 => "XRI", // XOR n
|
5 => "XRI", // XOR n
|
||||||
6 => "ORI", // OR n
|
6 => "ORI", // OR n
|
||||||
7 => "CPI", // CP n
|
7 => "CPI", // CP n
|
||||||
_ => throw new System.ArgumentOutOfRangeException(nameof(which)),
|
_ => throw new ArgumentOutOfRangeException(nameof(which)),
|
||||||
};
|
};
|
||||||
|
|
||||||
private static Tuple<string, int> Disassemble(int x, int y, int z, int p, int q)
|
private static Tuple<string, int> Disassemble(int x, int y, int z, int p, int q)
|
||||||
@@ -124,6 +131,8 @@ namespace EightBit
|
|||||||
case 1: // ADD HL,rp
|
case 1: // ADD HL,rp
|
||||||
specification = $"DAD {RP(p)}";
|
specification = $"DAD {RP(p)}";
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -147,6 +156,8 @@ namespace EightBit
|
|||||||
specification = "STA {1:X4}H";
|
specification = "STA {1:X4}H";
|
||||||
dumpCount += 2;
|
dumpCount += 2;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -167,8 +178,12 @@ namespace EightBit
|
|||||||
specification = "LDA {1:X4}H";
|
specification = "LDA {1:X4}H";
|
||||||
dumpCount += 2;
|
dumpCount += 2;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,6 +197,8 @@ namespace EightBit
|
|||||||
case 1: // DEC rp
|
case 1: // DEC rp
|
||||||
specification = $"DCX {RP(p)}";
|
specification = $"DCX {RP(p)}";
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -222,8 +239,12 @@ namespace EightBit
|
|||||||
case 7:
|
case 7:
|
||||||
specification = "CMC";
|
specification = "CMC";
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -260,8 +281,12 @@ namespace EightBit
|
|||||||
case 3: // LD SP,HL
|
case 3: // LD SP,HL
|
||||||
specification = "SPHL";
|
specification = "SPHL";
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -299,6 +324,8 @@ namespace EightBit
|
|||||||
case 7: // EI
|
case 7: // EI
|
||||||
specification = "EI";
|
specification = "EI";
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -325,8 +352,12 @@ namespace EightBit
|
|||||||
break;
|
break;
|
||||||
case 3: // FD prefix
|
case 3: // FD prefix
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -338,8 +369,12 @@ namespace EightBit
|
|||||||
case 7: // Restart: RST y * 8
|
case 7: // Restart: RST y * 8
|
||||||
specification = $"RST {y * 8:X2}";
|
specification = $"RST {y * 8:X2}";
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -352,7 +387,7 @@ namespace EightBit
|
|||||||
1 => "D",
|
1 => "D",
|
||||||
2 => "H",
|
2 => "H",
|
||||||
3 => "SP",
|
3 => "SP",
|
||||||
_ => throw new System.ArgumentOutOfRangeException(nameof(rp)),
|
_ => throw new ArgumentOutOfRangeException(nameof(rp)),
|
||||||
};
|
};
|
||||||
|
|
||||||
private static string RP2(int rp) => rp switch
|
private static string RP2(int rp) => rp switch
|
||||||
@@ -361,7 +396,7 @@ namespace EightBit
|
|||||||
1 => "D",
|
1 => "D",
|
||||||
2 => "H",
|
2 => "H",
|
||||||
3 => "PSW",
|
3 => "PSW",
|
||||||
_ => throw new System.ArgumentOutOfRangeException(nameof(rp)),
|
_ => throw new ArgumentOutOfRangeException(nameof(rp)),
|
||||||
};
|
};
|
||||||
|
|
||||||
private static string R(int r) => r switch
|
private static string R(int r) => r switch
|
||||||
@@ -374,7 +409,7 @@ namespace EightBit
|
|||||||
5 => "L",
|
5 => "L",
|
||||||
6 => "M",
|
6 => "M",
|
||||||
7 => "A",
|
7 => "A",
|
||||||
_ => throw new System.ArgumentOutOfRangeException(nameof(r)),
|
_ => throw new ArgumentOutOfRangeException(nameof(r)),
|
||||||
};
|
};
|
||||||
|
|
||||||
private string Disassemble(Intel8080 cpu, ushort pc)
|
private string Disassemble(Intel8080 cpu, ushort pc)
|
||||||
@@ -407,7 +442,7 @@ namespace EightBit
|
|||||||
}
|
}
|
||||||
|
|
||||||
output += '\t';
|
output += '\t';
|
||||||
output += string.Format(specification, (int)immediate, (int)absolute, relative, (int)displacement, indexedImmediate);
|
output += string.Format(CultureInfo.InvariantCulture, specification, (int)immediate, (int)absolute, relative, (int)displacement, indexedImmediate);
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ namespace Intel8080.Test
|
|||||||
{
|
{
|
||||||
var programPath = this.configuration.RomDirectory + "/" + this.configuration.Program;
|
var programPath = this.configuration.RomDirectory + "/" + this.configuration.Program;
|
||||||
var loadAddress = this.configuration.LoadAddress;
|
var loadAddress = this.configuration.LoadAddress;
|
||||||
this.ram.Load(programPath, loadAddress.Word);
|
_ = this.ram.Load(programPath, loadAddress.Word);
|
||||||
|
|
||||||
this.CPU.LoweredHALT += this.CPU_LoweredHALT;
|
this.CPU.LoweredHALT += this.CPU_LoweredHALT;
|
||||||
this.CPU.ExecutingInstruction += this.CPU_ExecutingInstruction_CPM;
|
this.CPU.ExecutingInstruction += this.CPU_ExecutingInstruction_CPM;
|
||||||
@@ -80,7 +80,7 @@ namespace Intel8080.Test
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CPU_ExecutingInstruction_CPM(object sender, System.EventArgs e)
|
private void CPU_ExecutingInstruction_CPM(object? sender, System.EventArgs e)
|
||||||
{
|
{
|
||||||
switch (this.CPU.PC.Word)
|
switch (this.CPU.PC.Word)
|
||||||
{
|
{
|
||||||
@@ -99,8 +99,8 @@ namespace Intel8080.Test
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CPU_LoweredHALT(object sender, System.EventArgs e) => this.LowerPOWER();
|
private void CPU_LoweredHALT(object? sender, System.EventArgs e) => this.LowerPOWER();
|
||||||
|
|
||||||
private void CPU_ExecutingInstruction_Debug(object sender, System.EventArgs e) => System.Console.Error.WriteLine($"{EightBit.Disassembler.State(this.CPU)}\t{this.disassembler.Disassemble(this.CPU)}");
|
private void CPU_ExecutingInstruction_Debug(object? sender, System.EventArgs e) => System.Console.Error.WriteLine($"{Disassembler.State(this.CPU)}\t{this.disassembler.Disassemble(this.CPU)}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+17
-6
@@ -2,9 +2,10 @@
|
|||||||
// Copyright (c) Adrian Conlon. All rights reserved.
|
// Copyright (c) Adrian Conlon. All rights reserved.
|
||||||
// </copyright>
|
// </copyright>
|
||||||
|
|
||||||
namespace EightBit
|
|
||||||
|
namespace Intel8080
|
||||||
{
|
{
|
||||||
using System;
|
using EightBit;
|
||||||
|
|
||||||
public class Intel8080(Bus bus, InputOutput ports) : IntelProcessor(bus)
|
public class Intel8080(Bus bus, InputOutput ports) : IntelProcessor(bus)
|
||||||
{
|
{
|
||||||
@@ -12,7 +13,7 @@ namespace EightBit
|
|||||||
|
|
||||||
private readonly InputOutput ports = ports;
|
private readonly InputOutput ports = ports;
|
||||||
|
|
||||||
private bool interruptEnable = false;
|
private bool interruptEnable;
|
||||||
|
|
||||||
public override Register16 AF
|
public override Register16 AF
|
||||||
{
|
{
|
||||||
@@ -195,6 +196,8 @@ namespace EightBit
|
|||||||
case 0: // NOP
|
case 0: // NOP
|
||||||
this.Tick(4);
|
this.Tick(4);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -357,7 +360,7 @@ namespace EightBit
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.R(y, this.R(z));
|
this.R(y, this.R(z));
|
||||||
if ((y == 6) || (z == 6))
|
if (y == 6 || z == 6)
|
||||||
{
|
{
|
||||||
this.Tick(3); // M operations
|
this.Tick(3); // M operations
|
||||||
}
|
}
|
||||||
@@ -436,6 +439,8 @@ namespace EightBit
|
|||||||
this.SP.Word = this.HL.Word;
|
this.SP.Word = this.HL.Word;
|
||||||
this.Tick(4);
|
this.Tick(4);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -479,6 +484,8 @@ namespace EightBit
|
|||||||
this.EnableInterrupts();
|
this.EnableInterrupts();
|
||||||
this.Tick(4);
|
this.Tick(4);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -504,6 +511,8 @@ namespace EightBit
|
|||||||
this.CallIndirect();
|
this.CallIndirect();
|
||||||
this.Tick(17);
|
this.Tick(17);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -553,6 +562,8 @@ namespace EightBit
|
|||||||
throw new NotSupportedException("Invalid operation mode");
|
throw new NotSupportedException("Invalid operation mode");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -703,12 +714,12 @@ namespace EightBit
|
|||||||
var before = this.A;
|
var before = this.A;
|
||||||
var carry = (this.F & (byte)StatusBits.CF) != 0;
|
var carry = (this.F & (byte)StatusBits.CF) != 0;
|
||||||
byte addition = 0;
|
byte addition = 0;
|
||||||
if (((this.F & (byte)StatusBits.AC) != 0) || (LowNibble(before) > 9))
|
if ((this.F & (byte)StatusBits.AC) != 0 || LowNibble(before) > 9)
|
||||||
{
|
{
|
||||||
addition = 0x6;
|
addition = 0x6;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((this.F & (byte)StatusBits.CF) != 0) || HighNibble(before) > 9 || (HighNibble(before) >= 9 && LowNibble(before) > 9))
|
if ((this.F & (byte)StatusBits.CF) != 0 || HighNibble(before) > 9 || (HighNibble(before) >= 9 && LowNibble(before) > 9))
|
||||||
{
|
{
|
||||||
addition |= 0x60;
|
addition |= 0x60;
|
||||||
carry = true;
|
carry = true;
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
// Copyright (c) Adrian Conlon. All rights reserved.
|
// Copyright (c) Adrian Conlon. All rights reserved.
|
||||||
// </copyright>
|
// </copyright>
|
||||||
|
|
||||||
namespace EightBit
|
namespace Intel8080
|
||||||
{
|
{
|
||||||
using System;
|
using EightBit;
|
||||||
|
|
||||||
[Flags]
|
[Flags]
|
||||||
public enum StatusBits
|
public enum StatusBits
|
||||||
|
|||||||
Reference in New Issue
Block a user