from Hacker News

.NET for NES Game Console on 6502 Microprocessors

by mtmk on 5/24/24, 9:35 AM with 24 comments

  • by le-mark on 5/25/24, 1:18 AM

        No runtime
        No BCL
        No objects or GC
        No debugger
        Strings are ASCII
    
    I did not see the readme mention anything about bool/byte/char/short/int/long sizes or signed and unsigned. It can be quite a surprise to find yourself with 8 bit long longs! As some found with sdcc for gameboy.
  • by userbinator on 5/25/24, 2:42 AM

    This looks very much like "Hello World" in C, taking advantage of the latest C# features in 2023.

    If you admit that it looks like C(99), what's "C#" about it then? This can probably be done with just about every C-syntax-derived language, which is why I think the title is a bit clickbaity; I was expecting some sort of highly-stripped-down CLR.

  • by DeathArrow on 5/25/24, 8:49 AM

    >For lack of a better word, .NES is a "transpiler" that takes MSIL and transforms it directly into a working 6502 microprocessor binary that can run in your favorite NES emulator.

    >Building a project should produce a *.nes binary, that is byte-for-byte identical to a program written in C.

    What about memory management? Is the garbage collector included in the generated code? If not, any idea on how memory management is done?

  • by noobermin on 5/25/24, 3:26 AM

    Saw this make the runs on twitter a few weeks ago and was confused, I had assumed they had ported a limited run time by making a custom cart with a large prg rom, which seems like an amazing feat actually...whereas this is a 6502 compiler essentially with some limited functionality.

    No shade btw, just seeing the title made me perhaps expect quite the effort while this is still a fun project of sorts.

  • by ladyanita22 on 5/25/24, 8:16 AM

    There's also this https://gergo.erdi.hu/blog/2021-09-18-rust_on_the_mos_6502__... for rust on the 6502.

    I wonder how's the performance vs. C (for both, C# and Rust).

    Edit: It's my understanding that the 6502 is extremely stack-limited, so a well-versed assembler would use the stack very little and allocate mostly on the heap. In C, you can replicate this with global variables, and I believe (and I would be very happy if someone related to the 6502 rust port could chime in here) on Rust you can do the same with `static mut` on Rust 2021 and `Unsafecell` on Rust 2024.

  • by DeathArrow on 5/25/24, 8:53 AM

    How hard would be to add a 6502 backend to the C# AOT compiler?
  • by richardfey on 5/25/24, 7:39 AM

    I'd love something like this for the SNES
  • by codespin on 5/25/24, 12:21 AM

    I love seeing fun little projects like this