This repo contains a .NET ahead of time compiler targetting the Z80 8-bit microprocessor. The compiler converts managed .NET assemblies into Z80 assembly language which is subsequently assembled using the zmac assembler. To learn more about CSharp-80, see the intro document. Currently there is support for the Trs-80, ZX Spectrum and CPM platforms.
Install the template:
dotnet new install csharp-80.templatesCreate a project:
dotnet new csharp-80 Or use the project template in Visual Studio:
Build it, if necessary specifying the runtime identifier, if no runtime identifier is specfied it will build for Trs80. Valid runtime identifiers are z80-trs80, z80-zxspectrum and z80-cpm.
dotnet build -r z80-trs80At this point you will be able to see the z80 assembly in the Hello.lst file. The binary file format depends on the target platform, for Trs80 it's a cmd file, for the ZX Spectrum it's a tap file, and for CPM it's a hex file. You will need to use either real hardware or an appropriate emulator to run the binary file. For Trs80 I recommend using trs80gp which you can simply pass the cmd file to as a parameter:
trs80gp.exe hello.cmdYou can try the sample applications out online directly here:
- For Trs-80
- For ZX Spectrum
- SeeSharpSnake written by Michal Strehovský
- CoreRT project from Microsoft
- NativeAOT from Microsoft
- RyuJit just in time compiler from Microsoft
- z88dk z80 development kit
- zmac - Z80 Macro Cross Assembler by George Phillips
- Idea is to support minimal subset of C# with tiny runtime system and target Z80 processor
- Runtime support for a number of computers including
- TRS-80 Model I/III
- ZX Spectrum
- CPM
- Compile the C# Snake game with minimal modifications
- Have a range of sample applications for classic 8-bit computer programs
- Learn more about AOT and the C# runtime
- Compiles a number of sample programs including Snake, Life, Towers of Hanoi, Hunt the Wumpus.
- Bespoke graphics for the TRS-80
- Performance is okay - snake is quite playable. Lots of scope for improvement here
- Allocation on both stack and heap is supported
- No Garbage collection
- Lots of IL opcodes not implemented yet
- Platform support is limited for ZX Spectrum and CPM but text based samples should work fine

