Calling PASM programs from C is a subject that has come up several times recently - both in this thread and in various PM's I've received. Since Steve's 'spinc' utility simplifies the whole process dramatically, I've decided I should provide some better examples.
I have added a file called 'Catalina_Using_PASM.zip' to the first post in this thread - it gives working examples of two methods of using PASM in conjunction with Catalina:
starting a PASM program in a cog using _coginit()
calling a function written in PASM directly from C
.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Catalina - a FREE C compiler for the Propeller - see Catalina
I just upgraded to the new version of code::blocks and am receiving an error during build. The build log output is below.
-------------- Clean: Release in Catalina ---------------
Cleaned "Catalina - Release"
-------------- Build: Release in Catalina ---------------
catalina.exe -D HYDRA -x0 -M32k -c "..\..\..\..\..\Program Files (x86)\catalina\demos\hello_world.c" -o "obj\Release\Program Files (x86)\catalina\demos\hello_world.obj"
: Invalid argument
lcc:
Catalina Compiler 2.5
Process terminated with status 1 (0 minutes, 1 seconds)
0 errors, 0 warnings
In the configuration file for Code::Blocks the linker is defined as catalina.exe. Is this correct? There is an "-lc" switch in the command which does not seem to be supported by catalina.exe
Yes, catalina is the name of a "wrapper" program for both the compiler and linker. And the '-lc' option is quite valid - it tells Catalina to include the standard C library when linking.
But the -o "obj\Release\Program Files (x86)\catalina\demos\hello_world.obj" part looks wrong - that doesn't look like the a correct path. Are you sure you copied it correctly?
If so, can you post your default.conf file, and also your hello_world.cbp file? Something in there must have been corrupted.
Ross.
P.S. On 64 bit windows, I generally recommend recompiling Catalina from source (after editing Catalina\source\lcc\etc\catalina_win32.c, Catalina\source\catalina\catalina.c and Catalina\source\catalina\catbind.c to change C:\\Program Files\\Catalina to C:\\Program Files (X86)\\Catalina). Have you tried this?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Catalina - a FREE C compiler for the Propeller - see Catalina
This is kinda embarrassing , but I went back through the catalina_win32.c file and it seems I entered an extra line with the words "program files". It must have happened when I was searching the file for that string. I recompiled without it and now everything works perfect. I'm really stoked to get started on this and a big thumbs up for making it possible.
I have just issued a patch release for Catalina 2.5 (22 Jun 10). It is in the first post of this thread. This patch fixes two problems in Catalina 2.5:
1. The lock functions _lockset() and _lockclr() were not correctly returning the previous state of the lock, and _locknew() now returns the value 8 on error (i.e. if there are no more locks available).
2. All the predefined targets incorrectly gave an error if the combination of HMI options LORES_TV (or just TV), NO_KEYBOARD and NO_MOUSE was specified - even on platforms that support this combination.
This patch release applies to both Windows and Linux versions of Catalina, and should be unzipped in the main Catalina directory. It will overwrite some files in the source, lib and target directories. There is no need to rebuild Catalina.
Ross.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Catalina - a FREE C compiler for the Propeller - see Catalina
The main addition in release 2.6 is support for running C programs on all eight Propeller cogs simultaneously. Programs demonstrating this capability are included in the demos\multicog directory. There are also other minor enhancements - see the README.WhatsNew file attached to the first post in this thread for more details.
Note that from this release onwards, Catalina will be hosted and released via SourceForge - see catalina-c.sourceforge.net. At present you will see only a default sourceforge project page - but you will find a link to the project downloads on that page. Since SourceForge has generous file size limits, each of the Windows and Linux distributions are provided in a single download containing all documentation, source code and binaries - this should simplify the download and installation process.
You will also find a button on the Sourceforge project page that enables you to donate money to support Catalina! All donations will be used to enhance Catalina - in particular, to allow Catalina to be ported to additional Propeller platforms.
Ross.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Catalina - a FREE C compiler for the Propeller - see Catalina
Since posting Catalina on SourceForge (just hours ago) it's had a larger number of downloads than I would see in weeks through these forums. I think the program description is perectly clear and I only notified this forum about the posting, so presumably nobody without a Propeller or who doesn't read these forums would bother downloading it - or would they?
Does anyone have experience with SourceForge? Are there people or companies who just download any new projects posted there for some reason? Or could these be genuine user downloads, and the downloads reported on these pages (which I've always presumed to be accurate) is in fact be a significant underestimate of actual downloads?
If you read about the new release of Catalina here, and have downloaded it in the last few hours from SourceForge, can you please post in this thread? - I would just like to know whether it is actually Propeller owners from these forums who are downloading it.
Thanks,
Ross.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Catalina - a FREE C compiler for the Propeller - see Catalina
I suspect they are real downloads. People outside of the propeller world would not not necessarily know about this forum. But lots of people visit sourceforge.
The next thing you might find is people wanting to buy a propeller!
As an aside, I think this has been true for some time, but Catalina supports the 512k ram chip, does it not?
I was one that visited the SoundForge page. I REALLY like the fact that the download is 1 file. This was a great move!
Still newbie on C, but thanks for the great effort that you have put out. I'm sure I'll appeciate it more as I learn C.
Jim
RossH said...
@All,
Since posting Catalina on SourceForge (just hours ago) it's had a larger number of downloads than I would see in weeks through these forums. I think the program description is perectly clear and I only notified this forum about the posting, so presumably nobody without a Propeller or who doesn't read these forums would bother downloading it - or would they?
Does anyone have experience with SourceForge? Are there people or companies who just download any new projects posted there for some reason? Or could these be genuine user downloads, and the downloads reported on these pages (which I've always presumed to be accurate) is in fact be a significant underestimate of actual downloads?
If you read about the new release of Catalina here, and have downloaded it in the last few hours from SourceForge, can you please post in this thread? - I would just like to know whether it is actually Propeller owners from these forums who are downloading it.
I wonder if sourceforge gets mirrored a lot. I know they have lots of mirrors around the world and presumably moving files among these mirrors does not count as downloads. But what about other people mirroring?
Then there may be a lot of people otherwise not interested in the Propeller as such but perhaps with an interest in what can be done with LCC.
Then there is the name "Catalina C" well it sounds so good you have to check it out[noparse]:)[/noparse]
It's a big world out there !
I have made one download each of the Windows, Linux and doc archives.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.
Maybe there are others that like the description and are downloading to look at it. Maybe that may bring some more people to become propheads. We can only hope.
Anyway, I didn't download.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ Links to other interesting threads:
I've mentioned it in several forum threads, and had a few private enquiries about it, so I figured it was time I officially announced the Catalina Code Optimizer. I hadn't intended to release it just yet (it's still undergoing final testing) but a preliminary release is available for Windows if anyone is interested. A Linux release will follow shortly.
Here is some information about the Optimizer:
The Catalina Code Optimizer is a standalone program that integrates seamlessly with Catalina 2.6 or later. Just copy the optimizer binaries to your existing Catalina binary directory - no need to reinstall or recompile anything.
The Optimizer is invoked by adding -Ox to any existing Catalina command, where x is the desired optimization level. For example:
catalina -lc hello_world.c -O2
Initially, three levels of optimization will be supported:
-O1 : basic optimization (single pass optimization) -O2 : intensive optimization (performs a second optimization pass) -O3 : same as -O2 but with automatic inlining
The single optimization pass (-O1) does most of the work, and typically reduces the size of code segments by 10%. The increase in overall program performance achieved typically ranges from 5% to 15% depending on the program itself (the larger savings are typical for programs that use the XMM memory model). The second optimizer pass (-O2) can save an additional few percent in both space and execution time in larger programs. The third option (-O3) searches for functions where inlining the body of the function would save the overhead of actually performing the function call - provided the inlining does not make the code size any larger (this optimization can make a very large difference in programs that are constructed from many small functions).
A fourth optimization level (-O4) may be added later for more agressive inlining - it would inline functions provided this made the final executable no more than 10% larger. Given that the previous passes typically result in saving of around 10%, the effect of this option would be to optimize speciifcally for performance - the final program size would most likely be about the same size as the original.
Note that the optimizer works on ALL the C code in the program - including library functions (i.e. you don't need to maintain two versions of either the standard C libraries or your own libraries - one compiled with the optimizer and one without).
Optimized code can still be used with either the BlackBox and BlackCat debuggers (except that inlining should not be used when you want to debug functions that may have been inlined!)
Note that the Catalina Optimizer is NOT open source software, and is not included with the free version of Catalina. The optimizer will be licensed and distributed in binary form only. I have not decided on a final price yet, but I am currently thinking of US$25. This price will include the right to updates to the Optimizer for one year.
PM or email me if you are interested.
Ross.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Catalina - a FREE C compiler for the Propeller - see Catalina
And the question? ... "What's the biggest percentage saving the new Code Optimizer can make to the size of a Catalina program?"
Code segment size without any optimization = 284 longs
Code segment size with -O2 optimization = 252 longs (saving 11%)
Code segment size with -O3 optimization = 164 longs (saving 42%)
Ross.
P.S. Okay, I should probably admit that this massive reduction was only achieved on one of the usual Catalina demo programs - and it was one that I already knew was pretty bad in terms of code generation. More typically, the code size saving the Catalina Opimizer makes is around 15%.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Catalina - a FREE C compiler for the Propeller - see Catalina
Fascinating that in other threads that you insist size does not matter, but here
you're suggesting people should pay for a program to optimize code size.
Interesting contradiction, and I'm sure you'll have a good explanation.
Don't get me wrong. I do believe you deserve something for your efforts
from anyone who embraces the solution.
Comments
Thanks for this - I'll try it out tonight. I can also use it in the kernel (which now uses PASM overlays). Currently, I do it manually!
Ross.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Catalina - a FREE C compiler for the Propeller - see Catalina
- In case the array comes up empty.
- So I can visually recognize the end.
- An old habit that's hard to break.
- I forgot.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔Propeller Pages: Propeller JVM
All I get when I try to execute spinc.exe is "This application failed to start because the application configuration is incorrect."
Am I missing something?
Ross.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Catalina - a FREE C compiler for the Propeller - see Catalina
"Either it works or it doesn't ... that's all I can do for you."
The source is on line if you want that, but will fail as is with a 16 bit compiler [noparse]:)[/noparse]
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Propeller Pages: Propeller JVM
Thanks - I found the source, and it now compiles and works ok.
With your permission, I'd like to include it as a utility with Catalina (with due credit of course). Is that ok?
Ross.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Catalina - a FREE C compiler for the Propeller - see Catalina
Cheers,
--Steve
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Propeller Pages: Propeller JVM
Calling PASM programs from C is a subject that has come up several times recently - both in this thread and in various PM's I've received. Since Steve's 'spinc' utility simplifies the whole process dramatically, I've decided I should provide some better examples.
I have added a file called 'Catalina_Using_PASM.zip' to the first post in this thread - it gives working examples of two methods of using PASM in conjunction with Catalina:
- starting a PASM program in a cog using _coginit()
- calling a function written in PASM directly from C
.▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Catalina - a FREE C compiler for the Propeller - see Catalina
Post Edited (RossH) : 6/19/2010 8:00:03 AM GMT
In the configuration file for Code::Blocks the linker is defined as catalina.exe. Is this correct? There is an "-lc" switch in the command which does not seem to be supported by catalina.exe
TIA
Yes, catalina is the name of a "wrapper" program for both the compiler and linker. And the '-lc' option is quite valid - it tells Catalina to include the standard C library when linking.
But the -o "obj\Release\Program Files (x86)\catalina\demos\hello_world.obj" part looks wrong - that doesn't look like the a correct path. Are you sure you copied it correctly?
If so, can you post your default.conf file, and also your hello_world.cbp file? Something in there must have been corrupted.
Ross.
P.S. On 64 bit windows, I generally recommend recompiling Catalina from source (after editing Catalina\source\lcc\etc\catalina_win32.c, Catalina\source\catalina\catalina.c and Catalina\source\catalina\catbind.c to change C:\\Program Files\\Catalina to C:\\Program Files (X86)\\Catalina). Have you tried this?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Catalina - a FREE C compiler for the Propeller - see Catalina
Post Edited (RossH) : 6/21/2010 8:42:07 AM GMT
I edited the three files, makefile and batch file, but still no dice.
Thank You for your help.
It looks like you do not have Bison installed. You need both Flex and Bison. You can download them from http://sourceforge.net/projects/mingw/files/
I still think your problem is probably related to a corruption somewhere in your configuration files. Can you post them?
Ross.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Catalina - a FREE C compiler for the Propeller - see Catalina
No worries - glad you got it working.
Ross.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Catalina - a FREE C compiler for the Propeller - see Catalina
I have just issued a patch release for Catalina 2.5 (22 Jun 10). It is in the first post of this thread. This patch fixes two problems in Catalina 2.5:
1. The lock functions _lockset() and _lockclr() were not correctly returning the previous state of the lock, and _locknew() now returns the value 8 on error (i.e. if there are no more locks available).
2. All the predefined targets incorrectly gave an error if the combination of HMI options LORES_TV (or just TV), NO_KEYBOARD and NO_MOUSE was specified - even on platforms that support this combination.
This patch release applies to both Windows and Linux versions of Catalina, and should be unzipped in the main Catalina directory. It will overwrite some files in the source, lib and target directories. There is no need to rebuild Catalina.
Ross.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Catalina - a FREE C compiler for the Propeller - see Catalina
Catalina 2.6 has been released.
The main addition in release 2.6 is support for running C programs on all eight Propeller cogs simultaneously. Programs demonstrating this capability are included in the demos\multicog directory. There are also other minor enhancements - see the README.WhatsNew file attached to the first post in this thread for more details.
Note that from this release onwards, Catalina will be hosted and released via SourceForge - see catalina-c.sourceforge.net. At present you will see only a default sourceforge project page - but you will find a link to the project downloads on that page. Since SourceForge has generous file size limits, each of the Windows and Linux distributions are provided in a single download containing all documentation, source code and binaries - this should simplify the download and installation process.
You will also find a button on the Sourceforge project page that enables you to donate money to support Catalina! All donations will be used to enhance Catalina - in particular, to allow Catalina to be ported to additional Propeller platforms.
Ross.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Catalina - a FREE C compiler for the Propeller - see Catalina
Since posting Catalina on SourceForge (just hours ago) it's had a larger number of downloads than I would see in weeks through these forums. I think the program description is perectly clear and I only notified this forum about the posting, so presumably nobody without a Propeller or who doesn't read these forums would bother downloading it - or would they?
Does anyone have experience with SourceForge? Are there people or companies who just download any new projects posted there for some reason? Or could these be genuine user downloads, and the downloads reported on these pages (which I've always presumed to be accurate) is in fact be a significant underestimate of actual downloads?
If you read about the new release of Catalina here, and have downloaded it in the last few hours from SourceForge, can you please post in this thread? - I would just like to know whether it is actually Propeller owners from these forums who are downloading it.
Thanks,
Ross.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Catalina - a FREE C compiler for the Propeller - see Catalina
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The next thing you might find is people wanting to buy a propeller!
As an aside, I think this has been true for some time, but Catalina supports the 512k ram chip, does it not?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.smarthome.viviti.com/propeller
Yes - I can't recall what SRAM chip the DracBlade has (I'm at work at present), but I support 512K chips on the TriBlade, RamBlade and Morpheus.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Catalina - a FREE C compiler for the Propeller - see Catalina
I was one that visited the SoundForge page. I REALLY like the fact that the download is 1 file. This was a great move!
Still newbie on C, but thanks for the great effort that you have put out. I'm sure I'll appeciate it more as I learn C.
Jim
Then there may be a lot of people otherwise not interested in the Propeller as such but perhaps with an interest in what can be done with LCC.
Then there is the name "Catalina C" well it sounds so good you have to check it out[noparse]:)[/noparse]
It's a big world out there !
I have made one download each of the Windows, Linux and doc archives.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.
Anyway, I didn't download.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Links to other interesting threads:
· Home of the MultiBladeProps: TriBlade,·RamBlade,·SixBlade, website
· Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator)
· Prop Tools under Development or Completed (Index)
· Emulators: CPUs Z80 etc; Micros Altair etc;· Terminals·VT100 etc; (Index) ZiCog (Z80) , MoCog (6809)·
· Prop OS: SphinxOS·, PropDos , PropCmd··· Search the Propeller forums·(uses advanced Google search)
My cruising website is: ·www.bluemagic.biz·· MultiBlade Props: www.cluso.bluemagic.biz
I think the mirroring idea may be it. After the initial flurry, downloads seem to have calmed down to more normal levels.
Ross.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Catalina - a FREE C compiler for the Propeller - see Catalina
I've mentioned it in several forum threads, and had a few private enquiries about it, so I figured it was time I officially announced the Catalina Code Optimizer. I hadn't intended to release it just yet (it's still undergoing final testing) but a preliminary release is available for Windows if anyone is interested. A Linux release will follow shortly.
Here is some information about the Optimizer:
The Catalina Code Optimizer is a standalone program that integrates seamlessly with Catalina 2.6 or later. Just copy the optimizer binaries to your existing Catalina binary directory - no need to reinstall or recompile anything.
The Optimizer is invoked by adding -Ox to any existing Catalina command, where x is the desired optimization level. For example:
Initially, three levels of optimization will be supported:
-O1 : basic optimization (single pass optimization)
-O2 : intensive optimization (performs a second optimization pass)
-O3 : same as -O2 but with automatic inlining
The single optimization pass (-O1) does most of the work, and typically reduces the size of code segments by 10%. The increase in overall program performance achieved typically ranges from 5% to 15% depending on the program itself (the larger savings are typical for programs that use the XMM memory model). The second optimizer pass (-O2) can save an additional few percent in both space and execution time in larger programs. The third option (-O3) searches for functions where inlining the body of the function would save the overhead of actually performing the function call - provided the inlining does not make the code size any larger (this optimization can make a very large difference in programs that are constructed from many small functions).
A fourth optimization level (-O4) may be added later for more agressive inlining - it would inline functions provided this made the final executable no more than 10% larger. Given that the previous passes typically result in saving of around 10%, the effect of this option would be to optimize speciifcally for performance - the final program size would most likely be about the same size as the original.
Note that the optimizer works on ALL the C code in the program - including library functions (i.e. you don't need to maintain two versions of either the standard C libraries or your own libraries - one compiled with the optimizer and one without).
Optimized code can still be used with either the BlackBox and BlackCat debuggers (except that inlining should not be used when you want to debug functions that may have been inlined!)
Note that the Catalina Optimizer is NOT open source software, and is not included with the free version of Catalina. The optimizer will be licensed and distributed in binary form only. I have not decided on a final price yet, but I am currently thinking of US$25. This price will include the right to updates to the Optimizer for one year.
PM or email me if you are interested.
Ross.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Catalina - a FREE C compiler for the Propeller - see Catalina
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.mikronauts.com E-mail: mikronauts _at_ gmail _dot_ com
My products: Morpheus / Mem+ / PropCade / FlexMem / VMCOG / Propteus / Proteus / SerPlug
and 6.250MHz Crystals to run Propellers at 100MHz & 5.0" OEM TFT VGA LCD modules
Las - Large model assembler Largos - upcoming nano operating system
Well, the answer is in ... it's ... 42!
And the question? ... "What's the biggest percentage saving the new Code Optimizer can make to the size of a Catalina program?"
Code segment size without any optimization = 284 longs
Code segment size with -O2 optimization = 252 longs (saving 11%)
Code segment size with -O3 optimization = 164 longs (saving 42%)
Ross.
P.S. Okay, I should probably admit that this massive reduction was only achieved on one of the usual Catalina demo programs - and it was one that I already knew was pretty bad in terms of code generation. More typically, the code size saving the Catalina Opimizer makes is around 15%.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Catalina - a FREE C compiler for the Propeller - see Catalina
Good that it did not take 7½ million years to get that result[noparse]:)[/noparse]
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.
you're suggesting people should pay for a program to optimize code size.
Interesting contradiction, and I'm sure you'll have a good explanation.
Don't get me wrong. I do believe you deserve something for your efforts
from anyone who embraces the solution.
Cheers,
--Steve
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Propeller Pages: Propeller JVM