Shop OBEX P1 Docs P2 Docs Learn Events
OpenSpin Spin/PASM compiler in C/C++ - Page 7 — Parallax Forums

OpenSpin Spin/PASM compiler in C/C++

145791013

Comments

  • Heater.Heater. Posts: 21,230
    edited 2012-03-05 11:00
    File names and paths should never have spaces in them.
    It's just another curse from the Windows world.
  • Cluso99Cluso99 Posts: 18,069
    edited 2012-03-05 13:22
    Roy: Sorry if I have missed these answers.

    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?
  • mparkmpark Posts: 1,305
    edited 2012-03-05 13:51
    Cluso99 wrote: »
    ...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.
  • Roy ElthamRoy Eltham Posts: 3,000
    edited 2012-03-05 14:28
    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
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-03-05 14:37
    Roy Eltham wrote:
    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
  • Roy ElthamRoy Eltham Posts: 3,000
    edited 2012-03-05 15:27
    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 Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-03-05 16:14
    Roy Eltham wrote:
    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. :)

    -Phil
  • Cluso99Cluso99 Posts: 18,069
    edited 2012-03-05 17:43
    Roy Eltham wrote: »
    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)
  • Roy ElthamRoy Eltham Posts: 3,000
    edited 2012-03-05 18:03
    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? :)
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-03-05 18:08
    Roy Eltham wrote:
    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).

    -Phil
  • tdlivingstdlivings Posts: 437
    edited 2012-03-05 20:33
    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.

    Tom
  • Roy ElthamRoy Eltham Posts: 3,000
    edited 2012-03-05 23:57
    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.
  • BatangBatang Posts: 234
    edited 2012-05-03 21:51
    Hi Roy,

    What's the status of the compiler port?
  • jazzedjazzed Posts: 11,803
    edited 2012-05-18 17:11
    Hi Roy,

    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
  • RossHRossH Posts: 5,462
    edited 2012-05-31 02:59
    Hi Roy,

    It looks like the project source hasn't been updated since March. Is this project still in active development?

    Ross.
  • softconsoftcon Posts: 217
    edited 2012-05-31 08:14
    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).
  • jazzedjazzed Posts: 11,803
    edited 2012-06-23 08:10
    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?

    Thanks.
    --Steve
  • Dave HeinDave Hein Posts: 6,347
    edited 2012-06-23 09:09
    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.
  • Roy ElthamRoy Eltham Posts: 3,000
    edited 2013-04-08 01:44
    Updated first post.
  • jazzedjazzed Posts: 11,803
    edited 2013-04-08 09:29
    Thanks for the update Roy.
  • doggiedocdoggiedoc Posts: 2,241
    edited 2013-04-08 09:45
    Yes. Thanks Roy. I've gotten it installed on Mac OSX 1.6.8 and Unbuntu 12.04. No problems noted thus far!

    Paul
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2013-04-08 10:52
    Thanks Roy.

    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
  • jazzedjazzed Posts: 11,803
    edited 2013-04-08 11:04
    OpenSpin seems to be a nicer name than SpinRoy.
    OSSPC probably doesn't get it either.

    Maybe marketing should get involved and set a name that should stick.
    Contest time?
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2013-04-08 11:43
    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.
  • Roy ElthamRoy Eltham Posts: 3,000
    edited 2013-04-08 12:12
    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.
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2013-04-08 14:23
    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.
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2013-04-08 14:27
    A largish program that compiles under bst but not under the Prop Tool:

    $ 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?
  • Roy ElthamRoy Eltham Posts: 3,000
    edited 2013-04-08 14:48
    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.
  • prof_brainoprof_braino Posts: 4,313
    edited 2013-04-09 07:27
    Hey Guys!

    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?
  • Heater.Heater. Posts: 21,230
    edited 2013-04-09 07:35
    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.
Sign In or Register to comment.