Mixing C and PASM
nyholku
Posts: 14
in Propeller 1
Hi,
I know, I know. This must have been asked like a gazillion times but google was not my friend. Or actually I found the questions but not a lot of clear answers.
I have a nice little project where I think Propeller is a good match. I've sketched the functionality I want to implement with cogs in PASM(*) but I don't fancy writing the 'main' program in Spin, I want to write it in C.
I have a couple of .spin files with the PASM code in the DAT section.
But how can I launch in C the PASM code in the .spin files? How do I tie all the parts together? What tool chain should use?
I've so far dabbled with PropellerIDE and SimpleIDE. In SimpleIDE I can write, compile, load and execute C code on a Propeller board. But using Spin/Pasm fails on macOS.
PropellerIDE 'works' with Spin/Pasm but does not allow C.
(Or somewhere it said it allows that but I cannot get that to work on macOS, does not allow opening/saving .c or .h files, in fact it does not even allow creating .spin files but is happy to edit them.)
I'd be most happy with command line compiler/linker and a Makefile, then I could integrate the stuff to real professional IDE like Eclipse or something or use vim,emacs, anything that really does what it says on the tin.
As IDEs all the Propeller IDEs I've used (or tried to use) are sub par. Why is the wheel always re-invented...
Ok, sorry about the rant, that was not the the point, just please somebody point me to documentation on how to mix Pasm and C, I don't need Spin.
(*) Writing PASM is what a Propeller is all about. If what I want to do could be done in Spin then it should be doable in C and if it can be done in C why do it in Propeller when there so many other MCU at better prices, better IO, better suited to C (for some definition of 'better'). IMO writing medium complexity medium speed timing critical/deterministic stuff is where you want to use Propeller. Something where you would use a small FPGA but cannot because you don't have the skills or resources.
I know, I know. This must have been asked like a gazillion times but google was not my friend. Or actually I found the questions but not a lot of clear answers.
I have a nice little project where I think Propeller is a good match. I've sketched the functionality I want to implement with cogs in PASM(*) but I don't fancy writing the 'main' program in Spin, I want to write it in C.
I have a couple of .spin files with the PASM code in the DAT section.
But how can I launch in C the PASM code in the .spin files? How do I tie all the parts together? What tool chain should use?
I've so far dabbled with PropellerIDE and SimpleIDE. In SimpleIDE I can write, compile, load and execute C code on a Propeller board. But using Spin/Pasm fails on macOS.
PropellerIDE 'works' with Spin/Pasm but does not allow C.
(Or somewhere it said it allows that but I cannot get that to work on macOS, does not allow opening/saving .c or .h files, in fact it does not even allow creating .spin files but is happy to edit them.)
I'd be most happy with command line compiler/linker and a Makefile, then I could integrate the stuff to real professional IDE like Eclipse or something or use vim,emacs, anything that really does what it says on the tin.
As IDEs all the Propeller IDEs I've used (or tried to use) are sub par. Why is the wheel always re-invented...
Ok, sorry about the rant, that was not the the point, just please somebody point me to documentation on how to mix Pasm and C, I don't need Spin.
(*) Writing PASM is what a Propeller is all about. If what I want to do could be done in Spin then it should be doable in C and if it can be done in C why do it in Propeller when there so many other MCU at better prices, better IO, better suited to C (for some definition of 'better'). IMO writing medium complexity medium speed timing critical/deterministic stuff is where you want to use Propeller. Something where you would use a small FPGA but cannot because you don't have the skills or resources.
Comments
As an example, my “goto” language for rapid dev on the P1/P2 is BASIC. But when BASIC pulls-up lame, I can inline assembly. Or I can write a set of functions in PASM and call them as a class with one line of code. Same goes for Spin, etc. Its like having a Swiss army knife in software.
You can get it here: https://github.com/totalspectrum/flexgui Eric Smith is the author and he is as close as this forum: @ersmith
Here's the link:
https://forums.parallax.com/discussion/157441/can-spi-in-simple-libraries-be-speeded-up
Additionally, I also took a Spin+PASM for controlling the 17 segment display on the Propeller Professional Development Board (PPDB) written by @Tonyp12, and converted that to call the PASM from C (SimpleIDE). It is a much shorter discussion (2 posts). The link is here:
https://forums.parallax.com/discussion/comment/1319703/#Comment_1319703
Hope this helps.
Tom
Ross has numerous examples that come with his download. Not sure if it runs on a Mac (or Unix) tho. He recently revised Catalina as it now does P2 as well. see the Catalina thread (might be under P2)
In most cases I avoid assembly because C generate as close to assembly as possible and I make sure I set my Memory Model to LMM Main Ram.
Here is a sample program for you to look at to get the idea of how assembly is done.
Also if you look at the Help menu item and pick PropGCC reference you can get to the documentation on in line assemble shown here Inline Assembly
Also I have not been able to build a pure assembly cog. There must be some C code and then you can put the inline assembly.
In most cases I was able to use C macros that use assembly code to get around using assembly when possible.
Hope this helps.
Mike
If you want mainly PASM, have a look at naken_asm and its Propeller examples.
I think I have managed to do what I want.
I've settled on SimpleIDE which seems to work once I understood some of the <epithet suppressed> user interface.
I can write the main program in C and launch pasm code to run on the cogs and write the cog code as pasm in .spin files.
Pretty simple but the details were difficult to find among all the noise in the internet.
Not run any code yet but it all compiles.