VM.Altair8800.Core 1.0.1

dotnet add package VM.Altair8800.Core --version 1.0.1
                    
NuGet\Install-Package VM.Altair8800.Core -Version 1.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="VM.Altair8800.Core" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="VM.Altair8800.Core" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="VM.Altair8800.Core" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add VM.Altair8800.Core --version 1.0.1
                    
#r "nuget: VM.Altair8800.Core, 1.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package VM.Altair8800.Core@1.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=VM.Altair8800.Core&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=VM.Altair8800.Core&version=1.0.1
                    
Install as a Cake Tool

VM.Altair8800.Core

NuGet Version Target Framework

基于 S100 总线架构 的 Altair 8800 模拟器核心库。CPU、内存、I/O 设备均作为总线设备热插拔,适合构建复古计算机模拟器、嵌入式系统仿真或 8080 指令集学习工具。

v1.0.1 修复说明:已修复 INR/DCR 的辅助进位标志(AC)逻辑,重命名 I/O 辅助方法消除 API 二义性,补全了 ADD/ADC/SUB/SBB 等算术指令实现。


🚀 快速创建:5 分钟跑起一个 8080 虚拟机

使用 QuickVM 包装类,您只需 3 行代码即可加载程序并运行:

using VM.Altair8800.Core;

// 1. 创建虚拟机(自动包含 4KB RAM 和 8080 CPU)
var vm = new QuickVM();

// 2. 加载机器码(例如:MVI A, 0x42;HLT 停机)
byte[] program = new byte[] { 0x3E, 0x42, 0x76 };
vm.LoadProgram(program, startAddress: 0x0000);

// 3. 运行直到遇到 HLT 指令
vm.Run();

// 查看 CPU 状态
Console.WriteLine(vm.CPU.GetStatus()); 
// 输出: PC=0003 A=42 F=00 BC=0000 DE=0000 HL=0000 SP=FFFF

控制面板操作(模拟 Altair 前面板)

通过 DoControl 模拟拨动开关:

vm.SetAddressBit(0, true);  // 地址最低位拨到 ON
vm.SetDataBit(1, true);     // 数据第 1 位拨到 ON
vm.DoControl("DEP");        // 写入数据到当前地址
vm.DoControl("EXAM");       // 读取当前地址内容到 LED
vm.DoControl("SS");         // 单步执行一条指令
vm.DoControl("RESET");      // 复位 CPU

🔌 自定义硬件:挂载你自己的 S100 设备

核心库定义了 IS100Device 接口。任何实现该接口的类,都可以像插卡一样挂载到 S100 总线上,CPU 读写内存或 I/O 端口时自动路由。

示例 1:实现一个虚拟串口卡(I/O 端口 0x01)

public class SerialPortCard : IS100Device, IConnectS100Bus
{
    private S100Bus _bus;
    private byte _lastReceived;

    public void SetBus(S100Bus bus) => _bus = bus;

    // 不处理内存映射
    public bool HandlesMemory(ushort address) => false;
    public byte ReadMemory(ushort address) => 0xFF;
    public void WriteMemory(ushort address, byte value) { }

    // 仅处理 I/O 端口 0x01
    public bool HandlesIO(byte port) => port == 0x01;

    public byte ReadIO(byte port)
    {
        Console.WriteLine($"[Serial] 读取端口 0x{port:X2}: 0x{_lastReceived:X2}");
        return _lastReceived;
    }

    public void WriteIO(byte port, byte value)
    {
        _lastReceived = value;
        Console.WriteLine($"[Serial] 发送字符: {(char)value} (0x{value:X2})");
    }
}

示例 2:挂载自定义设备到总线

不依赖 QuickVM,直接使用底层 BasicControl 构建:

var bus = new S100Bus();
var cpu = new Cpu8080();
var memory = new MemoryRam(0x0000, 0x0FFF);
var serial = new SerialPortCard(); // 自定义设备

// 全部挂到总线上
var devices = new IS100Device[] { cpu, memory, serial };
var control = new BasicControl(bus, devices);

// 此时 CPU 执行 OUT 01 指令时,会触发 SerialPortCard.WriteIO
control.Run(); 

💡 设计哲学:CPU 本身也只是总线上的一个普通设备(实现了 ICPUIS100Device)。您可以替换成 Z80 核心,或者同时挂载多个内存 Bank,实现 Bank Switching。


📦 核心 API 速览

类型 说明
S100Bus 总线,负责路由 Memory 和 I/O 请求。
BasicControl 核心控制器,管理设备注册、运行/停止、EXAM/DEPOSIT
QuickVM 开箱即用的快捷入口(内含 4KB RAM + 8080)。
ConsoleOut 事件总线,将开关/LED/日志推送给 UI(WinForm/WPF 可订阅事件)。
MemoryRam 基础 RAM 实现,支持 LoadClear
Cpu8080 完整 Intel 8080 指令集实现(含 DAA, DAD, 全部条件跳转/调用)。

📖 许可证

MIT License

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.1 89 8/20/2026