Parallax Propeller Java
Posted: January 31, 2016
I had one of these Parallax P8X32A Propeller QuickStart boards laying around (got it at RadioShack for $8 while they were failing) and thought it might be cool to make a way to program it with Java. I started by adding Propeller support to naken_asm. Actually, that might have been totally pointless since Parallax has their own assembler than can be embedded in .spin code, but it was a really easy platform to support, so it's not like it took much time. On the plus side, the disassembler (and .lst file support on the assembler) provide cycle counts for all the instructions, which could be quite useful. I then added support to Java Grinder.
I have just enough code to blink LED's and do other interesting things, but it's definitely not complete. I have a vision of how this could actually be a really neat programming platform. Something like adding support so every Java method runs on its own cog and having main() just tell which cogs to start, but I'm not sure how much more I'll work on this. This was more of just a Saturday project.
Update (July 7, 2017): I added more code to Java Grinder and got it generating Mandelbrots. It's actually pretty quick. I added the video below but for a full explanation visit: mandelbrots_simd.php.
Related Projects @mikekohn.net
Full video: https://youtu.be/QEONRKvCaoc
After compiling the Java code and running it through Java Grinder, the code needs to be turned into a DAT section of a .spin file. I wrote a program called bin2spin.go to do this. In the future, I could just spit out .spin code, but for now this works. The Makefile in samples/propeller shows how to use Parallax's tools to compile spin and upload to a board.
The current Java API for this chip looks like this: Propeller.java. One of these days I'll get around to making JavaDocs for this project.
This chip has been pretty interesting since it doesn't have a stack or registers. Registers are kind of "emulated" by using 32 bits of memory inside the cog (1 memory address). I had to make some decisions on things like static variables and local variables. I ended up putting the static variables inside of the cog. When I do local variables (and function calling and such) I'll put them in the shared main memory. Because of this, static variables are currently pretty fast, but waste code space while local variables (when I implement them) will be something like 4 times slower to access. It's also interesting the chip doesn't have branch instructions except for "zero" and "not zero". Still trying to figure this one out, notice in the sample source demo, the loops countdown to 0.
Copyright 1997-2018 - Michael Kohn