Simple customizible assembler
The CLI can be built with cargo using the following command:
cargo build --target <your-target-triple> --features=cli --bin assemblerIf you dont know what is your target triple, please read this
assembler -i <source file> -s <syntax file> -o <output file>For more information, use assembler -h
The assembler syntaxes are defined in a TOML file containing the following tables:
Defines the syntax symbols
[symbols]
r0 = { value = 0, tags = ["reg"] }
sp = { value = 1, tags = ["sp"] }- value: symbol value
- tags: sumbol tags, used to separate symbols and as instructions argument types
Defines the structure of the syntax instructions
[[instructions.mov]]
value = 0b1100110000000000
length = 16
arguments = [
{ type = "reg", index = 0, offset = 7, length = 3 },
{ type = "reg", index = 1, offset = 4, length = 3 },
]
documentation = "rx = ry"- value: intruction value
- length: length of the instruction, if greater than the length of value, the remaining length will be assumed to be zeros
- arguments: intruction arguments
- type: argument type, can be a data type or a symbol tag
- index: argument index
- offset: argument starting offset, with 0 being the least significant bit
- length: argument length, if greater than the length of argument value, the remaining length will be assumed to be zeros
- documentation: optional key, used for documenting instructions
Optional table, used for storing additional information about the syntax
[metadata]
name = "ICMC"
type = "instruction-set"This project supports packaging for WebAssembly using wasm-pack
wasm-pack build --target web --reference-types --weak-refs --release