|
1 | 1 | # simple-assembler |
2 | | -Simple assembler for my custom cpu |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | +Simple assembler for my custom cpu. |
| 6 | + |
| 7 | +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). |
| 8 | + |
| 9 | +## Installation |
| 10 | + |
| 11 | +It's only possible to install it from source for now. |
| 12 | + |
| 13 | +Clone this repository and `cd` into it. Then run `cargo build --release` to build the binary. |
| 14 | +You can place the binary `simple-assembler` located in `target/release` in your `PATH` in order to access it from everywhere. |
| 15 | + |
| 16 | +## Usage |
| 17 | + |
| 18 | +``` |
| 19 | +Usage: simple-assembler [OPTIONS] <FILE_PATH> |
| 20 | +
|
| 21 | +Arguments: |
| 22 | + <FILE_PATH> assembly file path |
| 23 | +
|
| 24 | +Options: |
| 25 | + -c, --color whether to colorize the bit stream output |
| 26 | + -d, --debug whether to print debug messages |
| 27 | + -s, --sep <SEP> separator between each words in the bit stream [default: ] |
| 28 | + --w-off whether to turn off warnings |
| 29 | + -W, --Warn whether to output the bit stream if warnings are encountered |
| 30 | + -o, --output <OUTPUT_PATH> save output in designated file |
| 31 | + -h, --help Print help |
| 32 | +``` |
| 33 | + |
| 34 | +## Example on a simple program |
| 35 | + |
| 36 | +```asm |
| 37 | +DEFINE foo 0x7fff |
| 38 | +DEFINE unused_var 42 ; warning here |
| 39 | +
|
| 40 | +main: |
| 41 | +A = foo |
| 42 | +D = *A |
| 43 | +A = 5 |
| 44 | +D = D & A |
| 45 | +
|
| 46 | +A = A ~ A ; error here |
| 47 | +
|
| 48 | +A = main |
| 49 | +JMP |
| 50 | +``` |
| 51 | + |
| 52 | +Running `simple-assembler prog.asm -c` on the code above gives us this output : |
| 53 | + |
| 54 | + |
| 55 | + |
| 56 | +Commenting the error and the warning outputs the following : |
| 57 | + |
| 58 | + |
| 59 | + |
| 60 | + |
| 61 | + |
| 62 | +## TODO |
| 63 | + |
| 64 | +- [ ] Handle more error with miette (tokenization errors, ...) |
| 65 | +- [ ] Integration test for parser |
| 66 | +- [ ] Benchmark |
| 67 | + |
| 68 | +## Acknowledgments |
| 69 | + |
| 70 | +Here are the amazing crates I used to make this small project : |
| 71 | +- [logos](https://github.com/maciejhirsz/logos) for tokenization |
| 72 | +- [miette](https://github.com/zkat/miette) for error report |
| 73 | +- [clap](https://github.com/clap-rs/clap) for parsing cli arguments |
| 74 | +- [colored](https://github.com/colored-rs/colored) to colorize the output of the program |
0 commit comments