RetroSharp.Tool
0.0.69
dotnet tool install --global RetroSharp.Tool --version 0.0.69
dotnet new tool-manifest
dotnet tool install --local RetroSharp.Tool --version 0.0.69
#tool dotnet:?package=RetroSharp.Tool&version=0.0.69
nuke :add-package RetroSharp.Tool --version 0.0.69
RetroSharp
RetroSharp is a modern C#-like language that compiles to 8-bit architectures, created for "The Joy of Learning®".
I'm making this in my free time to learn about compilers and some old-school topics. It combines the familiar syntax of C# with the nostalgic charm of retro computing. It's supposed to make me happier, but more often that not, it's making me get bald faster 🤣
How does it work?
RetroSharp uses a multi-stage compilation pipeline:
- Parser: Uses ANTLR4 to parse RetroSharp source code into an AST
- Semantic Analysis: Validates types, scopes, and semantics
- Intermediate Code Generation: Produces platform-agnostic 3-address code (IL)
- Backend: Translates IL to target architecture (currently Zilog Z80)
The benefit of this architecture is that the IL is generic enough to target virtually any platform by just writing a new backend.
What can it do?
Right now, RetroSharp can compile simple programs with:
- Basic arithmetic and logic operations
- Variables and assignments
- Function calls
- Control flow (if/else, loops)
- Multiple data types (int, char, byte, u8, i8, u16, i16, bool)
- Pointers with
ptr<T>
syntax
Example program:
int main()
{
return 2 * 3 * 4;
}
Which platforms does it compile for?
Currently, RetroSharp targets the Zilog Z80 processor - one of the most iconic 8-bit CPUs of all time! The Z80 powered legendary systems like:
- Nintendo Game Boy
- Amstrad CPC
- MSX computers
- TRS-80
- And many arcade machines
The modular design makes it relatively straightforward to add support for other 8-bit processors like the 6502, 8080, or even modern microcontrollers.
Installation
RetroSharp is distributed as a .NET tool:
dotnet tool install --global RetroSharp
Then use it to compile your programs:
retroSharp myprogram.rs
Product | Versions 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. |
This package has no dependencies.
Align SemanticAnalysis to canonical types and print correct function return types (#26)\n\nChanges\n\- Propagate function return type through semantic model (FunctionNode.ReturnType) and use it in both SemanticSnapshotPrinter and PrintNodeVisitor.\n\- Update SemanticAnalysis samples and verified snapshots to use canonical types: i16 variables and i16 main()/i16 other() headers.\n\- Refresh Verify snapshots (including double-prefixed files) to match canonical output.\n\- Fix Z80 tests to use new FunctionNode constructor signature.\n\nVerification\n\- Full solution tests passing locally: total 76; passed 73; skipped 3; failed 0.