Often I would like to be able to call a function within a lower included object directly (i.e. a lower level nested object). Is this possible?
Is an IncludeSource file option on your list of extras? If so, do you have any idea of timescales?
Is #define, #ifdef, #else, #elseifdef, and #end(if) on your list of extras? If so, do you have any idea of timescales? Will they pass to all lower levels like bst, or only the current level like homespun?
Cluso99,
My plan is to incorporate a full C-style preprocessor (modified to handle Spin comments and possibly other syntax issues).
I'm not sure what you mean by "Often I would like to be able to call a function within a lower included object directly (i.e. a lower level nested object). Is this possible?". Do you mean if ProgramA.spin includes an object called ObjectA.spin and ObjectA.spin includes an object called ObjectB.spin, you want ProgramA.spin to be able to call ObjectB.spin functions? Like in ProgramA have, ObjectA.ObjectB.Func(1). Hmmm, I think it would be possible, but I really don't like it. Why not just include ObjectB in ProgramA? It shouldn't cost any extra memory as duplicate objects are "distilled" (eliminated).
My plan is to incorporate a full C-style pre-processor (modified to handle Spin comments and possibly other syntax issues).
By "incorporate" do you mean "include with" the compiler, or "integrate into" the compiler. The former would be preferable, in case people want to use their own pre-processors. Have you thought about a standard way to annotate preprocessed code so that it can be mapped back to the original source for error reporting? Or should the reverse mapping be the domain of the pre-processor itself?
Phil,
I have been considering both. One issue that I need to resolve is propagation into/out of OBJ section "included" objects. The normal preprocessor setup would not handle this unless I made it follow OBJ section object inclusions. If it's integrated into my compiler wrapper then it's easier to propagate, if it's a separate exe then I need to replicate code and whatnot. If I integrate it into my exe, then it would be trivial to have an option to disable it.
For error reporting and remapping back to original source, I have only done minimal thinking on that topic. I don't have a solution, but I do realize it's needed.
The normal preprocessor setup would not handle this unless I made it follow OBJ section object inclusions.
That's the way I would do it: have the pre-processor gather and process the required objects and copy the processed files to a TEMP directory and hand them off to the compiler that way, rather than making the compiler resolve file and path names. That keeps the compilation more modular. That's the way my CLEAN pre-processor works, and the process is pretty ... well ... clean. Of course, I didn't have a choice.
Cluso99,
My plan is to incorporate a full C-style preprocessor (modified to handle Spin comments and possibly other syntax issues).
I'm not sure what you mean by "Often I would like to be able to call a function within a lower included object directly (i.e. a lower level nested object). Is this possible?". Do you mean if ProgramA.spin includes an object called ObjectA.spin and ObjectA.spin includes an object called ObjectB.spin, you want ProgramA.spin to be able to call ObjectB.spin functions? Like in ProgramA have, ObjectA.ObjectB.Func(1). Hmmm, I think it would be possible, but I really don't like it. Why not just include ObjectB in ProgramA? It shouldn't cost any extra memory as duplicate objects are "distilled" (eliminated).
Roy
Yes, using your example, I would like to just call a function in Object B from Program A as ObjectB.Funct(1) i.e. without the necessity of referring to ObjectA at all.
If I define Object B in both ProgramA and ObjectA, since duplicates are removed, will they work as one. i.e sometimes I call from ObjectA and sometimes from Program A, intermingled.
A specific example is with Kyes SD driver. I thought I had to provide an intermediate call if I included ObjectB (the sd driver) in ObjectA and wanted to call it from Program A also. Anyway, I can certainly try your idea of defining in both and see if it works.
Often I see nested objects where the higher object just calls the lower object and thought this rather a waste.
mpark: Thanks. I was not aware you had implemented this. I am wanting to use your spin compiler from Sphinx shortly, once I have the OS running using Kyes SD object (and perhaps later the fsrw2.6 pasm code to speed it up). Currently splitting up KyeDos into separate commands like you did for Sphinx. (see my OS thread)
That's the way I would do it: have the pre-processor gather and process the required objects and copy the processed files to a TEMP directory and hand them off to the compiler that way, rather than making the compiler resolve file and path names. That keeps the compilation more modular. That's the way my CLEAN pre-processor works, and the process is pretty ... well ... clean. Of course, I didn't have a choice.
-Phil
There is a tricky bit with that. If you have preprocessor stuff in and around the OBJ section(s) then you need to preprocess the "parent" objects then parse them to get the OBJs then process the children. I see this is going to be more involved. at first, I was thinking "I'll just slap a preprocessor in front and be done" but it's never that simple, eh?
If you have preprocessor stuff in and around the OBJ section(s) then you need to preprocess the "parent" objects then parse them to get the OBJs then process the children.
Yup. That's what I had to do. But the "parsing" is pretty light (spelled L-I-T-E).
Roy
I attached a file save from my learning program I have been using to exercise spin.exe and
just general learning what can be done with it.
It is a -v option save of what you send out. Notice on some lines right at the end is a funny char.
Kind of a right angle looking char. The value is either $02 or $03 and is always just before the cr lf $0D$0A at
the end of the line. I do not see it on any other options but -v. I do not know if it is something in my program or
your spin.exe but I am not doing anything different on a line by line basis.
tdlivings,
Those are actually part of the symbol. It's because those symbols are in an OBJ you include in the OBJ section. The compiler appends the index into the OBJ table for those symbols. I can probably change the code to instead print the OBJ name instead of the funky characters.
Phil, say you don't mean it. Case sensitivity should be all or nothing? Even file systems can be made to have optional case sensitivity. You want it, use ext2, don't want it, use hpfs or ext3 with the sensitivity turned off. I don't understand why sighted folks scream about this so much. For me, case snesitivity is a nightmare, especially since screen readers don't always do a good enough job of distinguishing between what's capital and what isn't. Case sensitive file systems are nice in their place, but that place isn't on anything I work on.
Having it as an option makes perfect sense to me, those that like it can have it, and those who don't like it can ignore it, best of both worlds (imo).
I'm doing some integration and would like to report the "program size" for the user.
If bufferSize is used it would be the "code size" - BSTC seems to use this number.
The "code size" is always at least 20 bytes smaller than the program size.
Seems wrong to rely on "code size" when bumping into that SPIN HUB RAM ceiling.
Isn't it more appropriate to report initial dcurr value as the program size?
I ran a few tests, and it seems that bstc always reports a number that is 4 bytes less than VBASE, which is the same as the binary file size. BTW, it prints out the size in units of longs, but it should really be bytes.
EDIT: DBASE or DCURR would be a more useful number, since they include the VAR area and the initial 8-byte stack frame. DCURR also includes 4 bytes for the RESULT variable, and 4 bytes for every local stack variable in the first PUB method.
Landing here at openSpin from the Is bst dead thread.
Looking at the options. There was a lot of talk about the preprocessor, but I'm still in the dark about what it does, and what would comprise a -D<define>. Can you elaborate, an example or two?
$ spin
Propeller Spin/PASM Compiler (c)2012 Parallax Inc. DBA Parallax Semiconductor.
Compiled on Apr 6 2013
usage: spin
[ -I <path> ] add a directory to the include path
[ -o <path> ] output filename
[ -c ] output only DAT sections
[ -d ] dump out doc mode
[ -q ] quiet mode (suppress banner and non-error text)
[ -v ] verbose output
[ -p ] use preprocessor
[ -D <define> ] add a define (must have -p before any of these)
<name.spin> spin file to compile
It should be something easy to type at the prompt. ???-->
$ Spin
$ OpenSpin
$ GoSpin
Just calling it Spin confuses the language as such with its compiler, although not a big deal. It is more an issue of having a good, memorable, marketable, unique search term.
Tracy,
The preprocessor is pretty close to the same as a standard C preprocessor. It allows you to do #define, #ifdef, #include and others. Of course, if you are not familiar with what a C preprocessor is, this doesn't help you.
#define is very similar to the normal CON section in spin code. It allows you to define a label or name to a value. However, the value can be anything including another name. You can also just do "#define something" and that will cause something to be defined for purposes of doing #ifdef and #ifndef. the -D option is a way for you to do this on the command line.
So you could have a block of code in your program wrapped in #ifdef / #endif and enabled it via the command line, like this:
#ifdef SPECIAL_CODE
' some code here
#endif
Now, if you compile that as is it will exclude the code between the #ifdef and #endif by default. However, if you added -D SPECIAL_CODE to the command line it would instead include the code in there. You could also just include the following on a line in your program: #define SPECIAL_CODE
This is a very basic usage. There is a lot more that can be done. #ifndef is if not defined, so has the opposite of #ifdef. You can also do #ifdef / #else / #endif combinations.
Here is the wikipedia page on C preprocessor: http://en.wikipedia.org/wiki/C_preprocessor it goes into more detail and covers more commands. We don't do all of the things in there, but a lot of it is usable.
I'll work on putting up a wiki page on the google code site with what commands are possible in OpenSpin.
Also, next time I update the google code binaries I'll rename the program to be openspin.exe, and probably change some of the source file names and what not.
Thanks Roy. Ah, I'm familiar with using #includes and #defines from within IDEs, for example, bst and even the BASIC Stamp IDE supports a number of options for conditional compilation. I just don't normally run things from a command line. Admittedly there is a certain sense of arcane power in doing so. Thanks for bearing with me. I'm learning. Of course, someday, someone (not necessarily you!) is going to have to write a "for dummies" tutorial about this.
I guess removing unused methods is still to come, right? There was some hot discussion about it earlier in this thread, about a third pass, or other approach. Is that still on the list?
Yeah, OpenSpin is compatible with Chip's x86 code. It doesn't have many of the extra things added in bstc. The removal of unused methods (dead code elimination) is on my list to add after the validator is done.
Yep. OpenSpin compiles easily on the Raspbery Pi.
If I remember correctly that last SimpleIDE package I poseted for the Raspberry Pi already uses OpenSpin on the Pi.
I'm going to try and make an update to that.
Comments
It's just another curse from the Windows world.
Often I would like to be able to call a function within a lower included object directly (i.e. a lower level nested object). Is this possible?
Is an IncludeSource file option on your list of extras? If so, do you have any idea of timescales?
Is #define, #ifdef, #else, #elseifdef, and #end(if) on your list of extras? If so, do you have any idea of timescales? Will they pass to all lower levels like bst, or only the current level like homespun?
I'm pretty sure the later versions of Homespun do pass #defined symbols down.
My plan is to incorporate a full C-style preprocessor (modified to handle Spin comments and possibly other syntax issues).
I'm not sure what you mean by "Often I would like to be able to call a function within a lower included object directly (i.e. a lower level nested object). Is this possible?". Do you mean if ProgramA.spin includes an object called ObjectA.spin and ObjectA.spin includes an object called ObjectB.spin, you want ProgramA.spin to be able to call ObjectB.spin functions? Like in ProgramA have, ObjectA.ObjectB.Func(1). Hmmm, I think it would be possible, but I really don't like it. Why not just include ObjectB in ProgramA? It shouldn't cost any extra memory as duplicate objects are "distilled" (eliminated).
Roy
-Phil
I have been considering both. One issue that I need to resolve is propagation into/out of OBJ section "included" objects. The normal preprocessor setup would not handle this unless I made it follow OBJ section object inclusions. If it's integrated into my compiler wrapper then it's easier to propagate, if it's a separate exe then I need to replicate code and whatnot. If I integrate it into my exe, then it would be trivial to have an option to disable it.
For error reporting and remapping back to original source, I have only done minimal thinking on that topic. I don't have a solution, but I do realize it's needed.
Roy
-Phil
Yes, using your example, I would like to just call a function in Object B from Program A as ObjectB.Funct(1) i.e. without the necessity of referring to ObjectA at all.
If I define Object B in both ProgramA and ObjectA, since duplicates are removed, will they work as one. i.e sometimes I call from ObjectA and sometimes from Program A, intermingled.
A specific example is with Kyes SD driver. I thought I had to provide an intermediate call if I included ObjectB (the sd driver) in ObjectA and wanted to call it from Program A also. Anyway, I can certainly try your idea of defining in both and see if it works.
Often I see nested objects where the higher object just calls the lower object and thought this rather a waste.
mpark: Thanks. I was not aware you had implemented this. I am wanting to use your spin compiler from Sphinx shortly, once I have the OS running using Kyes SD object (and perhaps later the fsrw2.6 pasm code to speed it up). Currently splitting up KyeDos into separate commands like you did for Sphinx. (see my OS thread)
There is a tricky bit with that. If you have preprocessor stuff in and around the OBJ section(s) then you need to preprocess the "parent" objects then parse them to get the OBJs then process the children. I see this is going to be more involved. at first, I was thinking "I'll just slap a preprocessor in front and be done" but it's never that simple, eh?
-Phil
I attached a file save from my learning program I have been using to exercise spin.exe and
just general learning what can be done with it.
It is a -v option save of what you send out. Notice on some lines right at the end is a funny char.
Kind of a right angle looking char. The value is either $02 or $03 and is always just before the cr lf $0D$0A at
the end of the line. I do not see it on any other options but -v. I do not know if it is something in my program or
your spin.exe but I am not doing anything different on a line by line basis.
Tom
Those are actually part of the symbol. It's because those symbols are in an OBJ you include in the OBJ section. The compiler appends the index into the OBJ table for those symbols. I can probably change the code to instead print the OBJ name instead of the funky characters.
What's the status of the compiler port?
I will be starting to use your Spin compiler soon. This is for a GUI project.
One thing I need is a command to list a tree of the object file names the compiler finds.
The compiler doesn’t have to actually compile anything. I’ve looked at the –v and –d output and don’t see any child object references.
Can you provide a tree command option ?
Thanks,
--Steve
It looks like the project source hasn't been updated since March. Is this project still in active development?
Ross.
Having it as an option makes perfect sense to me, those that like it can have it, and those who don't like it can ignore it, best of both worlds (imo).
If bufferSize is used it would be the "code size" - BSTC seems to use this number.
The "code size" is always at least 20 bytes smaller than the program size.
Seems wrong to rely on "code size" when bumping into that SPIN HUB RAM ceiling.
Isn't it more appropriate to report initial dcurr value as the program size?
Thanks.
--Steve
EDIT: DBASE or DCURR would be a more useful number, since they include the VAR area and the initial 8-byte stack frame. DCURR also includes 4 bytes for the RESULT variable, and 4 bytes for every local stack variable in the first PUB method.
Paul
Landing here at openSpin from the Is bst dead thread.
Looking at the options. There was a lot of talk about the preprocessor, but I'm still in the dark about what it does, and what would comprise a -D<define>. Can you elaborate, an example or two?
$ spin
Propeller Spin/PASM Compiler (c)2012 Parallax Inc. DBA Parallax Semiconductor.
Compiled on Apr 6 2013
usage: spin
[ -I <path> ] add a directory to the include path
[ -o <path> ] output filename
[ -c ] output only DAT sections
[ -d ] dump out doc mode
[ -q ] quiet mode (suppress banner and non-error text)
[ -v ] verbose output
[ -p ] use preprocessor
[ -D <define> ] add a define (must have -p before any of these)
<name.spin> spin file to compile
OSSPC probably doesn't get it either.
Maybe marketing should get involved and set a name that should stick.
Contest time?
???-->
$ Spin
$ OpenSpin
$ GoSpin
Just calling it Spin confuses the language as such with its compiler, although not a big deal. It is more an issue of having a good, memorable, marketable, unique search term.
The preprocessor is pretty close to the same as a standard C preprocessor. It allows you to do #define, #ifdef, #include and others. Of course, if you are not familiar with what a C preprocessor is, this doesn't help you.
#define is very similar to the normal CON section in spin code. It allows you to define a label or name to a value. However, the value can be anything including another name. You can also just do "#define something" and that will cause something to be defined for purposes of doing #ifdef and #ifndef. the -D option is a way for you to do this on the command line.
So you could have a block of code in your program wrapped in #ifdef / #endif and enabled it via the command line, like this:
#ifdef SPECIAL_CODE
' some code here
#endif
Now, if you compile that as is it will exclude the code between the #ifdef and #endif by default. However, if you added -D SPECIAL_CODE to the command line it would instead include the code in there. You could also just include the following on a line in your program: #define SPECIAL_CODE
This is a very basic usage. There is a lot more that can be done. #ifndef is if not defined, so has the opposite of #ifdef. You can also do #ifdef / #else / #endif combinations.
Here is the wikipedia page on C preprocessor: http://en.wikipedia.org/wiki/C_preprocessor it goes into more detail and covers more commands. We don't do all of the things in there, but a lot of it is usable.
I'll work on putting up a wiki page on the google code site with what commands are possible in OpenSpin.
Also, next time I update the google code binaries I'll rename the program to be openspin.exe, and probably change some of the source file names and what not.
$ spin /Users/thomasallen/Desktop/PropSpinCode/PS/Director18.spin
Propeller Spin/PASM Compiler (c)2012 Parallax Inc. DBA Parallax Semiconductor.
Compiled on Apr 6 2013
Compiling /Users/thomasallen/Desktop/PropSpinCode/PS/Director18.spin...
/Users/thomasallen/Desktop/PropSpinCode/PS/Director18.spin : error : Object files exceed 64k.
I guess removing unused methods is still to come, right? There was some hot discussion about it earlier in this thread, about a third pass, or other approach. Is that still on the list?
Is OpenSPIN ready to be used on Linux? On RaspberryPi?
I guess its going to be swapped into simpleIDE and BST swapped out, is this the plan?
If I remember correctly that last SimpleIDE package I poseted for the Raspberry Pi already uses OpenSpin on the Pi.
I'm going to try and make an update to that.