Customizable and extendable simple mips assembler
Simple to change or add instructions.
pip install .
masmbl <INPUT_MIPS> -d/--data <OUTPUT_DATA> -i/--instruction <OUTPUT_INSTRUCTIONS>
Optional arguments:
- [-v | --verbose] verbose
- [-c | --config] yaml file that specifies language. Extend default.yaml in masmbl source folder.
- [-b | --binary] output binary instead of hex data and instructions
Changing the yaml file and using it will allow to create custom instructions whose assembly can be specified.
- Use
instruction_input
section to specify what format input this new instruction should expect- Use
special_parsers
to specify capture of regex groups that are for special syntax. An example is the lw/sw instructions in default.yaml
- Use
- Use
instruction_output
to specify how to output assembled instruction should look, using the same tokens as ininstruction_input
- Also possible to directly specify number in a slot using
bXX...
where theX
are binary digits 0 and 1
- Also possible to directly specify number in a slot using
Making new pseudo-instructions is similar
- Use
pseudoinstruction_input
to specify name and expected format of the input for the pseudo-instruction - Use
pseudoinstruction_output
to specify the instruction or instructions the pseudo-instruction should expand into- If a pseudo-instruction takes an input named
one
, to expand it in the output use % signs like so:%one%
- If a pseudo-instruction takes an input named
- This simple assembler expects a
.data
segment if it exists as the very first segment. - You must label
.text
before starting to write code, as it is needed to separate the sections for this simple program - Most all else is robust to code style, though this assembler does not strictly follow any mips specification closely