Zafiro.Compilers.Z80DotNet 0.0.338

dotnet add package Zafiro.Compilers.Z80DotNet --version 0.0.338
                    
NuGet\Install-Package Zafiro.Compilers.Z80DotNet -Version 0.0.338
                    
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="Zafiro.Compilers.Z80DotNet" Version="0.0.338" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Zafiro.Compilers.Z80DotNet" Version="0.0.338" />
                    
Directory.Packages.props
<PackageReference Include="Zafiro.Compilers.Z80DotNet" />
                    
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 Zafiro.Compilers.Z80DotNet --version 0.0.338
                    
#r "nuget: Zafiro.Compilers.Z80DotNet, 0.0.338"
                    
#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 Zafiro.Compilers.Z80DotNet@0.0.338
                    
#: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=Zafiro.Compilers.Z80DotNet&version=0.0.338
                    
Install as a Cake Addin
#tool nuget:?package=Zafiro.Compilers.Z80DotNet&version=0.0.338
                    
Install as a Cake Tool

Z80.NET

What is this?

Z80.NET is a Z80 processor simulator that can be used as the core component for developing computer emulators (see for example NestorMSX), or to exercise pieces of Z80 code in custom test code. It is written in C# targetting the .NET Framework 4 Client Profile.

If you like Z80.NET you may want to take a look at ZWatcher too.

Hello, world!

var z80 = new Z80Processor();
z80.AutoStopOnRetWithStackEmpty = true;

var program = new byte[] {
    0x3E, 0x07, //LD A,7
    0xC6, 0x04, //ADD A,4
    0x3C,       //INC A
    0xC9        //RET
};
z80.Memory.SetContents(0, program);

z80.Start();

Debug.Assert(z80.Registers.A == 12);
Debug.Assert(z80.TStatesElapsedSinceStart == 28);

How to use

For your convenience, you can add Z80.NET to your project as a NuGet package if you want. In that case you may want to take a look at the release notes.

  1. Create an instance of the Z80Processor class.
  2. Optionally, plug your own implementations of one or more of the dependencies.
  3. Configure your instance as appropriate.
  4. Optionally, register one or more interrupt sources.
  5. Optionally, capture the memory access events and/or the instruction execution events.
  6. Start the simulated processor execution by using one of the execution control methods.
  7. Execution will stop (and the execution method invoked will then return) when one of the execution stop conditions is met. You can then check the processor state and, if desired, resume execution.

Execution is completely synchronous: one single thread is used for everything, including firing events. As seen in the Hello World example, you just invoke one of the starting methods and wait until it returns (there are means to force this to happen, see the execution stop conditions). If you want some kind of multithreading, you'll have to implement it by yourself, I just tried to keep things simple. 😃

Interaction of the processor with the hosting code and the outside world (memory and ports) can be achieved by handling the class events, by plugging custom implementations of the dependencies, or both at the same time. Interrupts can be generated by using interrupt sources.

Compatibility

Z80.NET implements all the documented Z80 behavior, plus all the undocumented instructions and flag effects as per The undocumented Z80 documented except for the following:

  • The bit 3 and 5 flags are not modified by the BIT instruction
  • The H, C and P/V flags are not modified by the INI, INIR, IND, INDR, OUTI, OTIR, OUTD and OTDR instructions

The processor class passes the ZEXDOC test fully, and the ZEXALL test fully except for the BIT instruction. You can try these tests yourself by running the ZexallTest project.

Resources

The following resources have been used to develop this project:

Last but not least...

...if you like this project please consider donating! My kids need moar shoes!

But who am I?

I'm Konamiman, the MSX freak. No more, no less.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Zafiro.Compilers.Z80DotNet:

Package Downloads
TestZ80Assembler

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.0.338 296 7/16/2026
0.0.337 145 7/16/2026
0.0.336 136 7/16/2026
0.0.335 147 7/16/2026
0.0.334 131 7/16/2026
0.0.333 139 7/16/2026
0.0.332 140 7/16/2026
0.0.331 133 7/16/2026
0.0.330 139 7/16/2026
0.0.329 134 7/15/2026
0.0.328 141 7/15/2026
0.0.327 130 7/15/2026
0.0.326 141 7/15/2026
0.0.325 146 7/15/2026
0.0.324 133 7/15/2026
0.0.323 140 7/15/2026
0.0.322 138 7/14/2026
0.0.321 150 7/14/2026
0.0.320 143 7/14/2026
0.0.319 140 7/14/2026
Loading failed

# Changelog 0.0.338

## Changes (initial history)

- CSL-6: gate actor and projectile sprite integrity (#382) (`1fba42e`)
- docs: finalize AI-navigability epic closeout (#381) (`99c048a`)
- AIN-12: Make architecture guardrails rename-safe (#378) (#380) (`a55c530`)
- AIN-11: finish SDK lowering test locality (#377) (#379) (`180277a`)
- AIN-9: freeze AI-navigable architecture acceptance (#376) (`f5ee89d`)
- AIN-10: sweep post-refactor architecture debt (#375) (`2b1494d`)
- AIN-8: deepen NES SDK lowering (#374) (`11853c7`)
- AIN-7: deepen Game Boy SDK lowering (#372) (`9c923e3`)
- AIN-6: partition Actor Framework generation by domain (#371) (`164c085`)
- AIN-5: build Actor Framework lowering plan (#361) (#370) (`7f2090d`)
- AIN-3: make NES probes consume the runtime ABI (#369) (`5771501`)
- AIN-4: centralize cross-target frontend preparation (#368) (`3cec52c`)
- AIN-2: centralize NES runtime memory ABI (#358) (#367) (`be73c88`)
- AIN-1: centralize Game Boy runtime memory ownership (#357) (#366) (`e7978e4`)
- runner: adopt SMB3 4.4 jump physics (#355) (`7260e70`)
- RPH-GB: restore packed-collision runner cadence (#354) (`e8b3ab3`)
- feat(runner): add one-way platforms (#352) (`74ec827`)
- fix(nes): stabilize nonzero-Y packed horizontal scrolling (#351) (`f38fd3a`)
- fix(nes): keep fixed camera windows inside safe area (#350) (`dbd9e58`)
- feat(samples): add collision-free Tiled horizontal scroll canaries (#348) (`c59b88b`)
- RPH-3.5: restore packed Tiled production cadence (#347) (`53527a4`)
- CSL-3: validate static and source-camera samples (#346) (`1242dee`)
- test(cli): invoke CLI in-process and drop redundant sample builds (#345) (`83622cf`)
- CSL-1: adopt neutral sample identities (#344) (`c8c384d`)
- CSL-2: add functional ROM acceptance contract (#343) (`f3d48bd`)
- fix(gb): restore packed camera cadence (#332) (#334) (`86acea9`)
- RPH-3.3: keep mapper-0 packed cameras out of the NMI reset loop (#333) (`0223d33`)
- RPH-3.2: prove transient NES frame acceptance (#330) (`9188371`)
- RPH-3.2: restore FCEUmm four-screen streaming parity (#329) (`f1010b6`)
- RPH-3.1: initialize NES packed camera deterministically (#328) (`cd66849`)
- RPH-3: restore NES packed collision cadence (#325) (`a735c85`)
- RPH-2: prevent let from narrowing word expressions (#320) (#324) (`68d08b3`)
- RPH-1: restore word-wide runner landing on GB and NES (#319) (#323) (`8150594`)
- LW-3.5: prove joint full stage1 acceptance (#317) (`ddc4c21`)
- LW-3.4: integrate staged four-screen NES streaming (#316) (`60ec1a9`)
- LW-3.3: implement the fixed-bank NES WorldPack reader (#315) (`c123f98`)
- LW-3.2: place NES WorldPacks and select final profile (#314) (`3229edf`)
- LW-3.1: add MMC3/TVROM fixed-runtime foundation (#313) (`ca19eeb`)
- LW-2.5: prove full stage1 on Game Boy (#312) (`3535bc8`)
- docs: sync Large Worlds production status (#311) (`40d2fda`)
- LW-2.4: integrate staged Game Boy camera edges (#310) (`59f1297`)
- LW-2.3: implement fixed-bank Game Boy WorldPack reader (#309) (`55db0ab`)
- LW-2.2: place Game Boy WorldPacks in MBC1 banks (#308) (`f7bfca5`)
- LW-2.1: add fixed-bank MBC1 world-read foundation (#307) (`bc0afbb`)
- docs: link published Large Worlds target waves (#306) (`f3716ae`)
- docs: make Large Worlds waves 2 and 3 executable (#295) (`0c51a3a`)
- LW-1.5: add deterministic world budget diagnostics (#294) (`47ff91d`)
- LW-1.4: compile Tiled worlds into deterministic WorldPack chunks (#293) (`fd3368d`)
- LW-1.3: add the target-neutral WorldPack model (#292) (`7805406`)
- LW-1.2: implement the widened collision-hit contract (#291) (`d040c54`)