Software & Apps

GitHub – hlorenzi/customasm: πŸ’» An assembler for custom, user-defined instruction sets! https://hlorenzi.github.io/customasm/web/

customasm an assembler that allows you to provide your own custom instruction set to assemble your source files! This can be useful, for example, if you are trying to test bytecode in a new virtual machine, or if you want to write programs for a new microprocessor architecture that you have just implemented on an FPGA chip. !

crates.io
Latest Release
Releases

Discord
GitHub Sponsor

πŸ–₯️ Try it now in your web browser!

πŸ•ΉοΈ See an example project NES target!

⌨️ Install the VSCode syntax highlighting extension!

❀️ Support the author!

πŸ“š See the wiki
for the changelog, documentation, and how-to guide!

πŸ’² Check out the command-line help! (Preferably formatted on the command-line itself)

You can install directly from crates.io by running cargo install customasm. Then the customasm The application should automatically run in your command-line environment.

You can also download pre-built executables from
Release section.

You can compile yourself from source by first cloning the repository and then running cargo build. There is also a battery of tests available to cargo test.

The following file is provided:

#ruledef
{
    load r1, {value: i8} => 0x11 @ value
    load r2, {value: i8} => 0x12 @ value
    load r3, {value: i8} => 0x13 @ value
    add  r1, r2          => 0x21
    sub  r3, {value: i8} => 0x33 @ value
    jnz  {address: u16}  => 0x40 @ address
    ret                  => 0x50
}

multiply3x4:
    load r1, 0
    load r2, 3
    load r3, 4
    
    .loop:
        add r1, r2
        sub r3, 1
        jnz .loop
    
    ret

…the assembler will use the #ruledef directive to convert instructions to binary code:

 outp | addr | data (base 16)

  0:0 |    0 |          ; multiply3x4:
  0:0 |    0 | 11 00    ; load r1, 0
  2:0 |    2 | 12 03    ; load r2, 3
  4:0 |    4 | 13 04    ; load r3, 4
  6:0 |    6 |          ; .loop:
  6:0 |    6 | 21       ; add r1, r2
  7:0 |    7 | 33 01    ; sub r3, 1
  9:0 |    9 | 40 00 06 ; jnz .loop
  c:0 |    c | 50       ; ret

https://opengraph.githubassets.com/a82dca6560598328b479fdcb84c092f9b15394f71a870ef0c46a5d4ac1ec7e9a/hlorenzi/customasm

2025-01-12 19:42:00

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button