"data" is the initialized data, variables that have an explicit initial value given to them when they are declared
"bss" is the uninitialized data, variables that are declared but not given any initial value. These all get set to 0 before main starts
For those familiar with DAT syntax, "data" is similar to using "long" to store data with specific values, whereas "bss" is like "res" - it reserves a specific amount of space once loaded, but takes no space in the executable.
I'm getting tired of the language wars. I'm tempted to just use Spin/PASM from any Propeller programming I do in the future.
Spin generally ends up being more compact, but C/C++ is faster, and for certain things can actually end up smaller because of optimization, inlining, etc. I'm not strongly advocating one or the other - I like them both.
I have found there are things that Spin does poorly that are simple in C/C++, like having a single object used in multiple other code classes. I know you can fake it with DAT sections, and parameter passing, but that's kind of a hack, and falls apart the moment you want two of them.
On the other hand, Spin has some very cool built-ins for OUTA and DIRA (the array index and ellipsis operators), and a few other things that are pretty cool too.
I think there's a place for both, so maybe there should be a truce instead of a war.
I think my problem is mainly with the Parallax statement that C is for education and hobbyists and Spin is for professionals.
But I could see GCC easily optimizing mainVar1 and mainVar2 into data and bss, similar to global1 and global2.
Your first guess was correct.
Note that the local variables, like mainVar1 and fooVar1, don't have any space reserved for them at compile time, only at run time (when the function is actually called). And to complicate things a bit, sometimes local variables will live in registers and not need stack space, but that's an implementation detail .
mainVar1 and mainVar2 aren't placed in data or bss because it's at least theoretically possible for main to be called recursively, in which case each iteration of main will need its own copy of the variables.
I think my problem is mainly with the Parallax statement that C is for education and hobbyists and Spin is for professionals.
Sounds like marketing thought they had to say something, but maybe that had a dose of caution in there, when C was in the early days too....
Best to focus on one market, and get that right, than be spread too thin.
I think my problem is mainly with the Parallax statement that C is for education and hobbyists and Spin is for professionals.
I agree that sounds kind of backwards. Spin is generally easier to use, but C has more options for professional programmers. They're both fine languages, and people should use whatever they're comfortable with. It's nice that we have Basic, Forth, and other choices too.
(I would have said Spin is lower performance, but with spin2cpp you can get the same performance range as C. Not many people use spin2cpp though, I guess I need to put a GUI in front of it.)
(I would have said Spin is lower performance, but with spin2cpp you can get the same performance range as C. Not many people use spin2cpp though, I guess I need to put a GUI in front of it.)
That would probably help. There doesn't seem to be much tolerance for command line programs here.
I think my problem is mainly with the Parallax statement that C is for education and hobbyists and Spin is for professionals.
I think that sentiment is changing though. I don't think they understood how powerful it could be. I know Ken was surprised when I told him the ported flight controller ended up being significantly faster, while almost identical in size to the Spin version. The C/C++ toolchain was developed for their educational market, for sure, but it's useful far beyond that. I just don't think they'd seen enough "real world" examples to be comfortable recommending it.
I think my problem is mainly with the Parallax statement that C is for education and hobbyists and Spin is for professionals.
I think that sentiment is changing though. I don't think they understood how powerful it could be. I know Ken was surprised when I told him the ported flight controller ended up being significantly faster, while almost identical in size to the Spin version. The C/C++ toolchain was developed for their educational market, for sure, but it's useful far beyond that. I just don't think they'd seen enough "real world" examples to be comfortable recommending it.
I think my problem is mainly with the Parallax statement that C is for education and hobbyists and Spin is for professionals.
I agree that sounds kind of backwards. Spin is generally easier to use, but C has more options for professional programmers. They're both fine languages, and people should use whatever they're comfortable with. It's nice that we have Basic, Forth, and other choices too.
(I would have said Spin is lower performance, but with spin2cpp you can get the same performance range as C. Not many people use spin2cpp though, I guess I need to put a GUI in front of it.)
I'd love to see PropellerIDE wrap PropWare's build system. That would accomplish your goal without having to write another IDE or rewrite the build system logic again.
Comments
For those familiar with DAT syntax, "data" is similar to using "long" to store data with specific values, whereas "bss" is like "res" - it reserves a specific amount of space once loaded, but takes no space in the executable.
Your first guess was correct.
Note that the local variables, like mainVar1 and fooVar1, don't have any space reserved for them at compile time, only at run time (when the function is actually called). And to complicate things a bit, sometimes local variables will live in registers and not need stack space, but that's an implementation detail .
mainVar1 and mainVar2 aren't placed in data or bss because it's at least theoretically possible for main to be called recursively, in which case each iteration of main will need its own copy of the variables.
Yes, it's long past time for that to be changed. Agreed David.
Best to focus on one market, and get that right, than be spread too thin.
I agree that sounds kind of backwards. Spin is generally easier to use, but C has more options for professional programmers. They're both fine languages, and people should use whatever they're comfortable with. It's nice that we have Basic, Forth, and other choices too.
(I would have said Spin is lower performance, but with spin2cpp you can get the same performance range as C. Not many people use spin2cpp though, I guess I need to put a GUI in front of it.)
I think that sentiment is changing though. I don't think they understood how powerful it could be. I know Ken was surprised when I told him the ported flight controller ended up being significantly faster, while almost identical in size to the Spin version. The C/C++ toolchain was developed for their educational market, for sure, but it's useful far beyond that. I just don't think they'd seen enough "real world" examples to be comfortable recommending it.
I'd love to see PropellerIDE wrap PropWare's build system. That would accomplish your goal without having to write another IDE or rewrite the build system logic again.