-
-
Notifications
You must be signed in to change notification settings - Fork 56
Getting started
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.
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.
- Getting started
- Defining mnemonics β #ruledef, #subruledef
- Declaring labels and constants
- Setting the minimum addressable unit β #bits
- Outputting data blocks β #d
- Working with banks β #bankdef, #bank
- Address manipulation directives β #addr, #align, #res
- Splitting your code into multiple files β #include, #once
- Advanced mnemonics, cascading, and deferred resolution β assert()
- Available expression operators and functions β incbin(), incbinstr(), inchexstr()
- Functions β #fn
- Conditional Compilation β #if, #elif, #else