Plasma
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 pools.
Background
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
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: org 0 horg $1000 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. jmp #start 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.
Download
- plasma-1.0 (Source code, 6.9 kB)
Install
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.
Run
Plasma is invoked like this:
plasma -l native.so -o output.bin input.s
Posted Monday 11-May-2009 16:47
Discuss this page
Disclaimer: I am not responsible for what people (other than myself) write in the forums. Please report any abuse, such as insults, slander, spam and illegal material, and I will take appropriate actions. Don't feed the trolls.
Jag tar inget ansvar för det som skrivs i forumet, förutom mina egna inlägg. Vänligen rapportera alla inlägg som bryter mot reglerna, så ska jag se vad jag kan göra. Som regelbrott räknas till exempel förolämpningar, förtal, spam och olagligt material. Mata inte trålarna.
Thu 14-Aug-2014 06:20
pl -g true -t main -o plasma -c main.pl
make: pl: Command not found
make: *** [plasma] Error 127
What's pl? Where do I get it? Is there a Gentoo package for it?
Thanks,
electrodude
Linus Åkesson
Sun 17-Aug-2014 21:26
pl -g true -t main -o plasma -c main.pl
make: pl: Command not found
make: *** [plasma] Error 127
What's pl? Where do I get it? Is there a Gentoo package for it?
Thanks,
electrodude
Hi! It's apparently called swipl now. I don't know about Gentoo, but in debian the package is called swi-prolog.
Mon 18-Aug-2014 17:01
lft wrote:
Hi! It's apparently called swipl now. I don't know about Gentoo, but in debian the package is called swi-prolog.I got an account for your website.
Thanks, I eventually figured out that it was renamed to swipl. Yeah, it's called swi-prolog on gentoo. I had installed swi-prolog before trying to compile plasma, but I didn't realize they had changed the name.
Now I've successfully built Plasma, but it won't compile Turbulence. Make gives up because plasma is returning 1 instead of 0 for some reason. I did tell it where native.so is. The error is:
make: *** [ztunnel.bin] Error 1
ztunnel is the first thing make feeds to plasma. I tried running plasma manually and it still returned 1.
Mon 8-Jul-2019 22:10