The Propeller Low-level Assembly Aggregator
Plasma is a small (637 lines of source code) tool for
compiling and concatenating propeller assembly language (PASM) and binary
data. It extends PASM with some new features, most notably ARM-like constant
When I began to work on my Turbulence
demo, I soon realized that I was going to have to write my own assembler.
The one from Parallax was bulky and inflexibly locked to the spin environment
for which it was designed, and had to be run through wine. The open source
alternatives weren't stable enough at the time. Consequently, I hacked
together some prolog code and a bison parser.
I've decided to publish the source code here, as free software, in the hope
that somebody will find it useful and inspiring.
Documentation is scarce, because this tool was developed for my own private
use. The source code is quite readable, though, since it's short and written
in a high level programming language.
Here is an example of plasma source code, illustrating some of the new
features. For the ultimate example, please refer to the turbulence source code.
' Constant declaration. Must begin at start of line, just like labels.
ABC = $1000
' Every label will refer to one cog address and one hub address (accessible with @).
' Consider the following code, for example:
start mov r1, #start ' Place the value 0 in r1.
'mov r1, #@start ' This would cause an error, since $1000 doesn't fit in 9 bits.
mov r1, =@start ' Allocate a register in the constant pool, then refer to it.
mov r1, =ABC ' Plasma will re-use the same constant pool register here.
byte "hello" ' We are no longer aligned on a long boundary.
mylabel ' @mylabel = $1015, mylabel = undefined due to unalignment.
align 4 ' Insert padding bytes until the cog address is long aligned (3 bytes).
pool ' Plasma will put a long here, with the value $1000.
r1 res 1
vfit 496 ' Verbose fit. Like 'fit', but prints how many registers are used.
vhfit $2000 ' Verbose hub fit. Counts bytes rather than registers.
To build, you'll need SWI-prolog, flex, bison and gcc. Edit the makefile to
point out the include directory where your SWI-Prolog.h is located.
You will end up with two files; plasma (the executable) and
native.so. You have to specify the location of native.so when
you run plasma, using the -l flag.
Plasma is invoked like this:
plasma -l native.so -o output.bin input.s