PropGCC / PASM question
JasonDorie
Posts: 1,930
in Propeller 1
I have a bunch of code that I've written in Spin / PASM. Most of the code is PASM, but the high-level code is Spin, and I'm thinking that C might be a better choice, because it'll get the benefit of the optimizer and likely gain some speed.
My question: Is it possible to compile a GCC project with my pre-existing PASM functions running in COG mode (not CMM or LMM) but still be able to choose the CMM model for the high-level code?
Are there examples around for setting up something like this? The PropGCC and Learn pages have very little info on using PASM, other than inlining, and that implies that it's being assembled into the same global code model.
My question: Is it possible to compile a GCC project with my pre-existing PASM functions running in COG mode (not CMM or LMM) but still be able to choose the CMM model for the high-level code?
Are there examples around for setting up something like this? The PropGCC and Learn pages have very little info on using PASM, other than inlining, and that implies that it's being assembled into the same global code model.
Comments
While propgcc gas will compile PASM straight from the DAT section of a SPIN file, the extensions available with gcc (macros & conditional compilation, e.g.) are compelling and it's hard to switch back.
I'm pretty sure you can do this with SimpleIDE, but I use Makefiles, which allows me to automate compiling the cog drivers as ECOGs, which loads them directly from the upper 32K of a 64K+ EEPROM, freeing up hub space for more CMM or LMM code.
It is all explained in different places, but I haven't seen a single resource that steps you through it. I've promised more than once to write up a tutorial on how to do this, but it has never gotten done.
I have the code getting through the compiler (first stage), but then when processing the output in the cmm folder it dies.
I've attached a simple test project if anyone's feeling ambitious. The RC_Receiver.sx file gets through the assembler with no issues, and the RC_Receiver.c file compiles fine.
Then I get a bunch of these:
cmm/RC_Receiver.sx:1:8: warning: null character(s) ignored [enabled by default]
cmm/RC_Receiver.sx:12: Error: Unknown instruction 't X X \ '
...and the build fails.
Any help from the PropC gurus who've done this already would be much appreciated.
Jason
https://github.com/libpropeller/libpropeller/tree/master/libpropeller/serial
And here's propware: https://github.com/DavidZemon/PropWare
https://github.com/DavidZemon/PropWare/tree/release-2.0/Examples/Cogc
Jason, I'm downloading your project now...
Second, I strongly dislike assembly files in PropGCC. They cause no end of pain and grief. I had a lot of trouble getting my SPI module to work, because it was written in an assembly file. I haven't seen those preprocessor macros in propeller.h before though - that's pretty neat.
I'm on Windows, and using SimpleIDE. I haven't used command line tools and makefile a for PropGCC before and was hoping I wouldn't have to.
file.s
Assembler code.
file.S
file.sx
Assembler code that must be preprocessed.
However, it looks like you might need to use gcc for this to work. I don't think running propeller-elf-as by itself will honor these rules.
David, this the first I've heard this from you, and I must say I'm a little shocked. Are you *sure* that the problem you were having was *because* it was written in an assembly file ?
With inline assembly, you lose a lot of the preprocessor goodies, and it's hard to edit and visually unappealing, to say the least. I've had nothing but good experiences from using *.S files; it allows much better automation and control than inline assembly or PASM within a SPIN file.
If you have the time, could you summarize or publish what you were having a problem with ? I'd hate for new users that are debating whether to use it to run across this and shy away because of it; it works so well for me that it's the only way I do or will program the prop.
David
(Yes, there might be too many Davids in this thread; "altosack" is fine.)
I had just woken up when I wrote that reply this morning. I will edit it when I get home to be more factual and less ranty
I suspect it's an issue with SimpleIDE. I have two files, both called "RC_Receiver" but with different extensions. The .c file compiles to cmm/RC_Receiver.o, and the .sx file compiles to cmm/RC_Receiver.sx. It looks like that output should *also* be a .o file, but then the files would collide. If PropGCC uses the extension to decide what to do with the file, it'd mean that it's trying to compile the already processed object output again. I'll try to spend some time on it tonight.
I was hoping that SimpleIDE would handle this more cleanly for a few reasons:
1) I'd love to be able to port a few projects from Spin/PASM to C/C++/PASM easily, because I think faster in C/C++ than in Spin.
2) This specific project is being written with an educational market in mind, so "ease of setup" is high on my list of goals. Having to install a command-line toolchain and learn it, in addition to learning the code, is extra overhead.
3) I suspect general adoption of PropGCC would be higher if using it was no more effort than using the Prop tool.
Thanks for all the help - I appreciate it. I really want to see how this project compares in size and speed between the Spin/PASM version and a CMM/PASM version.
cmm/RC_Receiver.o: In function `_RC_Receiver_Start':
(.text+0x10): undefined reference to `_binary_RC_Receiver_dat_start'
collect2: ld returned 1 exit status
The RC_Receiver_Start() function looks like this:
How do I label the entry point in the PASM code and the load_cog_driver() call so the linkage works?
This is the issue I was going detail out when I got home. See my workaround in spi_as.S from PropWare (note that the link is to a specific commit, because I have recently deleted that file and it is no longer available in the default branch)
So do I have to run propeller-elf-objcopy on the output of the assembler before I can link it?
Does the load_cog_driver() macro basically resolve to the same thing as this? :
It feels like there should be a simpler way to do this - I can't be the first person trying to port a bunch of existing PASM cogs to PropGCC. If the use_cog_driver / load_cog_driver macros worked, that'd be a lot easier than having to know the GCC token asm blob above.
Edit: By the way, I agree that this should be documented better.
I'm not sure where the most current sources are. Possibly, only on jazzed's hard drive.
Nope. It actually expands to two different things depending on whether you're using an XMM mode or not. If not, it's this:
The XMM version is longer, but you can find it on line 285 in <install dir>/propeller-elf/include/propeller.h