https://github.com/kassane/rust-mos-examples
Using rust + llvm-mos-sdk on some examples
https://github.com/kassane/rust-mos-examples
6502 c64 llvm llvm-mos mega65 nesdev rust rust-mos snes
Last synced: 4 days ago
JSON representation
Using rust + llvm-mos-sdk on some examples
- Host: GitHub
- URL: https://github.com/kassane/rust-mos-examples
- Owner: kassane
- License: apache-2.0
- Created: 2026-06-09T19:12:35.000Z (about 1 month ago)
- Default Branch: main
- Last Pushed: 2026-06-30T19:23:13.000Z (14 days ago)
- Last Synced: 2026-06-30T19:23:47.758Z (14 days ago)
- Topics: 6502, c64, llvm, llvm-mos, mega65, nesdev, rust, rust-mos, snes
- Language: Rust
- Homepage: https://llvm-mos.org/wiki/Rust
- Size: 42 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# rust-mos-examples
Rust examples targeting MOS 6502/65816 platforms via [llvm-mos-sdk](https://github.com/llvm-mos/llvm-mos-sdk).
## Requirements
- [rust-mos](https://github.com/kassane/rust-mos-examples/releases) — Rust toolchain with LLVM-MOS backend.
- [llvm-mos-sdk](https://github.com/llvm-mos/llvm-mos-sdk/releases) v23.x
> [!IMPORTANT]
> Both toolchains are LLVM 23 based to LTO.
## Building
Cargo build with `-Zbuild-std -Zunstable-options -Zjson-target-spec` (RUSTC_BOOTSTRAP=1 required).
Output extensions are set per-platform via `exe-suffix` in the target JSON:
| Platform | Extension | Example output |
|----------|-----------|---------------|
| NES | `.nes` | `target/mos-nes-nrom-none/release/nes-nrom-hello.nes` |
| SNES | `.sfc` | `target/mos-snes-none/release/snes-hello.sfc` |
| C64 | `.prg` | `target/mos-c64-none/release/hello.prg` |
| MEGA65 | `.prg` | `target/mos-mega65-none/release/mega65-hello.prg` |
| SIM | (none) | `target/mos-sim-none/release/hello` (host-format ELF) |
#### NES NROM
```console
RUSTFLAGS="-Clink-arg=-flto -Clink-arg=-Wl,-u,main -Clink-arg=-Qunused-arguments -A linker_messages" cargo build \
--target targets/mos-nes-nrom-none.json \
-Zbuild-std -Zunstable-options -Zjson-target-spec \
--release -p demo-nes --bin nes-nrom-hello
```
#### MEGA65
```console
RUSTFLAGS="-Clink-arg=-flto -Clink-arg=-Wl,-u,main -Clink-arg=-Qunused-arguments -A linker_messages" cargo build \
--target targets/mos-mega65-none.json \
-Zbuild-std -Zunstable-options -Zjson-target-spec \
--release -p demo-mega65
```
#### C64
```console
RUSTFLAGS="-Clink-arg=-flto -Clink-arg=-Wl,-u,main -Clink-arg=-Qunused-arguments -A linker_messages" cargo build \
--target targets/mos-c64-none.json \
-Zbuild-std -Zunstable-options -Zjson-target-spec \
--release -p demo-c64
```
#### SNES LoROM
```console
cargo build --target targets/mos-snes-none.json \
-Zbuild-std -Zunstable-options -Zjson-target-spec \
--release -p demo-snes --bin snes-hello
```
## References
- [zig-mos-examples](https://github.com/kassane/zig-mos-examples) - examples based
- [mrk-its/rust-mos](https://github.com/mrk-its/rust-mos) v1.87 [old - no asm-inline support] - this project uses v1.98-dev!