https://github.com/benoitlx/simple-assembler
Simple assembler for my custom cpu
https://github.com/benoitlx/simple-assembler
assembly bitstream-generation parser tokenizer
Last synced: about 2 months ago
JSON representation
Simple assembler for my custom cpu
- Host: GitHub
- URL: https://github.com/benoitlx/simple-assembler
- Owner: benoitlx
- License: mit
- Created: 2025-01-26T22:58:55.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-05T09:48:13.000Z (over 1 year ago)
- Last Synced: 2025-06-24T04:07:39.845Z (about 1 year ago)
- Topics: assembly, bitstream-generation, parser, tokenizer
- Language: Rust
- Homepage:
- Size: 134 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# simple-assembler

Simple assembler for my custom cpu.
You should not be interested in this project unless you're curious about making your own assembler or you want to test out my [cpu](https://benoitlx.github.io/simple-cpu-wiki/Assembler/Assembler) (wip).
## Installation
It's only possible to install it from source for now.
Clone this repository and `cd` into it. Then run `cargo build --release` to build the binary.
You can place the binary `simple-assembler` located in `target/release` in your `PATH` in order to access it from everywhere.
## Usage
```
Usage: simple-assembler [OPTIONS]
Arguments:
assembly file path
Options:
-c, --color whether to colorize the bit stream output
-d, --debug whether to print debug messages
-s, --sep separator between each words in the bit stream [default: ]
--w-off whether to turn off warnings
-W, --Warn whether to output the bit stream if warnings are encountered
-o, --output save output in designated file
-h, --help Print help
```
## Example on a simple program
```asm
DEFINE foo 0x7fff
DEFINE unused_var 42 ; warning here
main:
A = foo
D = *A
A = 5
D = D & A
A = A ~ A ; error here
A = main
JMP
```
Running `simple-assembler prog.asm -c` on the code above gives us this output :

Commenting the error and the warning outputs the following :

## TODO
- [ ] Handle more error with miette (tokenization errors, ...)
- [ ] Integration test for parser
- [ ] Benchmark
## Acknowledgments
Here are the amazing crates I used to make this small project :
- [logos](https://github.com/maciejhirsz/logos) for tokenization
- [miette](https://github.com/zkat/miette) for error report
- [clap](https://github.com/clap-rs/clap) for parsing cli arguments
- [colored](https://github.com/colored-rs/colored) to colorize the output of the program