Skip to content

benoitlx/simple-assembler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

simple-assembler

lint-workflow

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 (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] <FILE_PATH>

Arguments:
  <FILE_PATH>  assembly file path

Options:
  -c, --color                 whether to colorize the bit stream output
  -d, --debug                 whether to print debug messages
  -s, --sep <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 <OUTPUT_PATH>  save output in designated file
  -h, --help                  Print help

Example on a simple program

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 :

Errors

Commenting the error and the warning outputs the following :

out

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 for tokenization
  • miette for error report
  • clap for parsing cli arguments
  • colored to colorize the output of the program