|
| 1 | +# ksmc |
| 2 | +An assembler and disassembler for kRISC, plus a compiler for a language intended to replace Kerboscript — implemented in Rust. |
| 3 | + |
| 4 | +[](https://crates.io) |
| 5 | +[](https://github.com/DigitalCodeCrafter/ksmc/actions) |
| 6 | +[](LICENSE) |
| 7 | + |
| 8 | +Table of contents |
| 9 | +- Features |
| 10 | +- Quick start |
| 11 | +- Installation |
| 12 | +- Usage |
| 13 | + - Assembler |
| 14 | + - Disassembler |
| 15 | + - Compiler |
| 16 | +- Examples |
| 17 | +- Contributing |
| 18 | +- License |
| 19 | +- Contact |
| 20 | + |
| 21 | +Features |
| 22 | +- Assemble kRISC assembly into binary machine code. |
| 23 | +- Disassemble kRISC binaries back to human-readable assembly. |
| 24 | +- Compile a higher-level Kerboscript-like language to kRISC assembly/binary. |
| 25 | +- Single Rust-based CLI (ksmc) with subcommands for each tool. |
| 26 | +- Designed for correctness, readability of output, and developer ergonomics. |
| 27 | + |
| 28 | +Quick start |
| 29 | +1. Build from source: |
| 30 | + cargo build --release |
| 31 | +2. Run the assembler on an assembly file: |
| 32 | + ./target/release/ksmc assemble examples/hello.krisc -o hello.bin |
| 33 | +3. Disassemble a binary: |
| 34 | + ./target/release/ksmc disassemble hello.bin -o out.asm |
| 35 | +4. Compile a Kerboscript-replacement script: |
| 36 | + ./target/release/ksmc compile scripts/example.ks -o program.bin |
| 37 | + |
| 38 | +Installation |
| 39 | +- From source: |
| 40 | + git clone https://github.com/DigitalCodeCrafter/ksmc.git |
| 41 | + cd ksmc |
| 42 | + cargo build --release |
| 43 | + # binary will be in target/release/ksmc |
| 44 | + |
| 45 | +- Install locally (if published as a crate or for local path): |
| 46 | + cargo install --path . |
| 47 | + |
| 48 | +- Prebuilt releases: |
| 49 | + Check the Releases page for platform builds (if available). |
| 50 | + |
| 51 | +Usage |
| 52 | +Note: The exact flags and subcommand names in your repo may differ — adjust these examples to match the CLI implemented in ksmc. |
| 53 | + |
| 54 | +Assembler |
| 55 | +- Basic: |
| 56 | + ksmc assemble input.krisc -o output.bin |
| 57 | +- Read from stdin and write to stdout: |
| 58 | + cat input.krisc | ksmc assemble - > output.bin |
| 59 | +- Verbose / debug output (example): |
| 60 | + ksmc assemble input.krisc -o output.bin --verbose |
| 61 | + |
| 62 | +Disassembler |
| 63 | +- Basic: |
| 64 | + ksmc disassemble input.bin -o output.krisc |
| 65 | +- Show raw bytes alongside instructions: |
| 66 | + ksmc disassemble input.bin --hex |
| 67 | + |
| 68 | +Compiler (Kerboscript replacement -> kRISC) |
| 69 | +- Compile a script to binary: |
| 70 | + ksmc compile script.ks -o program.bin |
| 71 | +- Compile and emit assembly: |
| 72 | + ksmc compile script.ks --emit-asm -o program.krisc |
| 73 | + |
| 74 | +Global help |
| 75 | +- Show top-level help and subcommand docs: |
| 76 | + ksmc --help |
| 77 | + ksmc assemble --help |
| 78 | + ksmc disassemble --help |
| 79 | + ksmc compile --help |
| 80 | + |
| 81 | +Examples |
| 82 | +Example kRISC assembly (examples/hello.krisc) |
| 83 | +; comments start with semicolon |
| 84 | +LOAD R0, 0x100 |
| 85 | +ADD R1, R0, #5 |
| 86 | +STORE R1, 0x200 |
| 87 | +HALT |
| 88 | + |
| 89 | +Assemble: |
| 90 | +ksmc assemble examples/hello.krisc -o examples/hello.bin |
| 91 | + |
| 92 | +Disassemble: |
| 93 | +ksmc disassemble examples/hello.bin -o examples/hello_out.krisc |
| 94 | + |
| 95 | +Example high-level script (scripts/example.ks) |
| 96 | +print("Hello, kRISC!") |
| 97 | +set throttle 0.5 |
| 98 | +stage |
| 99 | + |
| 100 | +Compile: |
| 101 | +ksmc compile scripts/example.ks -o scripts/example.bin |
| 102 | +ksmc compile scripts/example.ks --emit-asm -o scripts/example.krisc |
| 103 | + |
| 104 | +Output locations and formats |
| 105 | +- The assembler produces raw kRISC binary files by default. |
| 106 | +- The disassembler emits plain-text assembly that should re-assemble to the same binary (modulo assembler formatting and labels). |
| 107 | +- The compiler can emit either assembly (for inspection) or binary (for running on kRISC). |
| 108 | + |
| 109 | +Project layout (suggested) |
| 110 | +- src/ — Rust source |
| 111 | +- examples/ — example assembly and binaries |
| 112 | +- scripts/ — high-level scripts to compile |
| 113 | +- tests/ — integration tests and sample programs |
| 114 | +- docs/ — design notes and ISA reference |
| 115 | + |
| 116 | +Contributing |
| 117 | +- Issues: open issues for bugs, feature requests, and questions. |
| 118 | +- Pull requests: |
| 119 | + - Fork the repo and create a feature branch. |
| 120 | + - Run cargo fmt and cargo clippy; include tests when applicable. |
| 121 | + - Describe changes, motivation, and any backward-incompatible effects in the PR. |
| 122 | +- Code style: follow Rust idioms; keep public APIs documented with rustdoc. |
| 123 | +- Tests: include unit tests and, when possible, integration tests that confirm assembled binaries round-trip with the disassembler. |
| 124 | + |
| 125 | +Development tips |
| 126 | +- Use cargo test to run tests. |
| 127 | +- Use cargo fmt and cargo clippy for formatting and linting. |
| 128 | +- Add example files to examples/ and test them in CI to prevent regressions. |
| 129 | + |
| 130 | +License |
| 131 | +- Add your chosen license to the repository (LICENSE file). Common choices: |
| 132 | + - MIT |
| 133 | + - Apache-2.0 |
| 134 | + - MIT OR Apache-2.0 |
| 135 | +Replace the license badge above and the LICENSE file accordingly. |
| 136 | + |
| 137 | +Changelog |
| 138 | +- Keep a concise changelog or use GitHub Releases to summarize notable changes per release. |
| 139 | + |
| 140 | +Contact & support |
| 141 | +- Open an issue for bug reports and feature requests. |
| 142 | +- For questions, contact the maintainers via GitHub (open an issue or discussion). |
| 143 | + |
| 144 | +Notes / TODO |
| 145 | +- Add an ISA reference and encoding table to docs/. |
| 146 | +- Add CI that runs tests, examples, and builds release artifacts. |
| 147 | +- Add example programs and an emulator harness (if desired) for easier testing. |
0 commit comments