Skip to content
Lorenzi edited this page Dec 3, 2020 · 5 revisions

So, you want to write programs for that new microprocessor you've built, or that custom virtual machine you've created? We'll take a look at how to define your instruction set and then use it to assemble programs.

Check out the Installation section for instructions on how to get the app.

If you use the online version, you don't need to install anything, but it's less flexible.

Assembling your first program

Let's start off by creating the following file, which we can name main.asm:

#ruledef
{
    nop => 0x00
    hlt => 0xff
}

nop
nop
hlt

If you've installed one of the executable versions, you can assemble our previous example by running:

$ customasm main.asm

The command above will write a binary file to disk. You can also print the output to screen, which might make it easier to understand what is being produced, by running:

$ customasm main.asm -p

After it is assembled, you should see three bytes' worth of code being output! 00 00 ff, corresponding to the three-instruction program given.

You can see that the #ruledef block lives in the same file as the actual program. Later on, you'll probably want to split up the declarations into multiple files for organization, which you can do via #include directives.

You may now want to check out the next page for a description of all the features available for creating mnemonics.