Shop OBEX P1 Docs P2 Docs Learn Events
PreSpin: a Preprocessor for Spin — Parallax Forums

PreSpin: a Preprocessor for Spin

AribaAriba Posts: 2,682
edited 2012-03-16 14:49 in Propeller 1
Hi All

I will present you my PreSpin, a little Windows-application that integrates a Preprocessor and a Context Help into the Spin IDE (Propeller Tool).

I found out that one can control the IDE from a parallel running application by send-key messages. It's like you press a key on the keyboard when the IDE is selected.
So all what you can do by keyboard shortcuts, can also be done by another application.

PreSpin opens a little Window with some icons, that always stays in foreground. This icons control the Preprocessor, the Context Help and also the PropTerminal.
With a single mouseklick the actual code will be preprocessed and the result appears in a new Tab in the IDE. Then you can compile this new file and load it in the Propeller chip.

Preprocessor features:
- Conditional compilation with '#if - '#else - '#endif
- flexible Replace command
- #include command. To include other Files (also conditional)
- Macros for the Assembly section
- 2 output formats: unused lines removed, or disabled by block-comments
- Can run an external Precompiler after Preprocess and before Compile
- Can handle files generated by epmoyer's SCCuM

Context Help features:
- Shows the related page in the PropellerManual.pdf for a selected word in the IDE
- works with Acrobat- and Foxit-Reader
- The Index-file, can be extended by you.

If you use PropTerminal, PreSpin can automatically minimize it before a code-upload, and restore it afterwards. It is like PropTerminal where integrated in the IDE.

Many, many thanks to kaio, for his testing, his suggestions, and the registry and template files. PreSpin would not be on this level without him.

Some words about the attached ZIP: You can unzip it into the Propeller-Tools directory, and you have all files at the right place. If you first want to make a minimal test, copy the PreSpin.exe and the PropManualIndex.txt to the PropellerTools directory (where Propeller.exe resides), and the PreprocTest.pre in a spin working directory. Then start PreSpin.exe, this starts also the Propeller Tool, if necessary.

PreSpin is a very little application (ca. 60 kByte) that needs no additional Runtime !

Have fun

Andy
665 x 376 - 16K

Comments

  • JoannaKJoannaK Posts: 44
    edited 2007-06-11 14:04
    Wow..
  • codemonkeycodemonkey Posts: 38
    edited 2007-06-11 16:50
    Now we're cookin' with gas! Thanks Andy.
  • Paul BakerPaul Baker Posts: 6,351
    edited 2007-06-11 17:24
    Hi Andy, looks like another useful tool from you. Have you been working with Eric Moyer at all on this project? I haven't done a full comparison yet, but if the two of you can agree on the same syntax, people can use either of your utilities interchangably for preprocessing thier code.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
  • KaioKaio Posts: 253
    edited 2007-06-11 17:34
    Hi all,

    I have found a problem with the registration file which provides not the right values for users using an english version of Windows. Maybe also other languages could be involved.

    If your programs are stored in "C:\Program Files" then please use the attached registration file. Copy the file in your preferred directory and perform the registration by double click.

    The file delivered in the PreSpin archive works fine for german speaking countries. wink.gif

    Thomas
  • AribaAriba Posts: 2,682
    edited 2007-06-11 22:45
    Hello Paul

    I use the syntax suggested by epmoyer, but I have it fairly extended. So it's no problem to preprocess a file, that is intended for SCCuM also with PreSpin. And also files that are already preprocessed by SCCuM, can still be used with PreSpin.

    In the other direction, it's also compatible if you only use #DEFINE, #IF and #ENDIF (in capitals).

    The big difference is, that PreSpin generates an intermediate file (preprocessed.spin) that will be compiled. After compile, this file is no longer needed. Nothing has to be changed in the original source file. Includes and macros are possible with this approach, and it's the same as a C preprocessor works.

    More, with the ability to run another command-line program between the preprocess and the compiler, it should be possible to make things like a C to Spin converter, or a Basic to Large-Assembly-model compiler. And this all in the existing IDE, with a single mouseclick.

    Andy
  • RinksCustomsRinksCustoms Posts: 531
    edited 2007-07-01 04:29
    Dude! It rocks, and the IDE needed a context help "thingy". The prop terminal is friggin awesome too!! I can prototype code with the prop terminal twice as fast, even generate quick simulator programs to test my proto-codes. Kudos squared to you my friend!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Definetly a E3 (Electronics Engineer Extrodinare!)
    "I laugh in the face of imposible,... not because i know it all, ... but because I don't know well enough!"
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2008-01-15 08:41
    Andy,

    Have you thought about adding a condition code facility to the macros? You could use \0 as the parameter for any condition code that's used with the macro invocation. That way \0 could be used only in those lines of the macro definition where it's appropriate. If you really wanted to get fancy, the term !\0 could be used to insert the opposite condition from \0, allowing an if...then...else construct within the macro.

    -Phil
  • AribaAriba Posts: 2,682
    edited 2008-01-15 11:08
    Phil,

    you can do this also with the existing version, you simply add the condition as a parameter:

    '#macro writeArr  arrptr,offs,cond
        \3        wrlong    temp,\1
        \3        add       \1,\2
    '#end_macro
    
    ....  use the Macro:
    
              writeArr  LongPntr,#4,if_z 
    
    
    



    with two parameter-conditions, you can alse realize a if/else.
    But I agree, that this is not so well readable, as if the condition stays before the macro instruction.
    Perhaps I add this, when I touch the PreSpin code next time.

    Andy
  • Bob AndersonBob Anderson Posts: 122
    edited 2008-01-15 17:51
    This utility is so useful that it should be added to Graham Stabler's "Good Thread Index".· Is there a way to make that happen?

    A question: I got the impression that context help would open to the proper page when an index entry is double-clicked.· That does not happen for me.· Acrobat opens, but always at page 1.· (I am using Adobe Reader 8.1.1) Is there an explanation?
  • AribaAriba Posts: 2,682
    edited 2008-01-15 23:59
    Bob

    I recommend to use the FoxitReader, it's a free PFD Reader that is not so big as the Acrobat and therefore much faster.
    The context help was tested with Acrobat 6 and worked with that version.
    Because PreSpin gets no feedback from the started PDF-Reader, I analyse the Titel Bar of all Open Windows, and perhaps the Text in TitelBar has changed significantly to previous versions in Acrobat 8 ?
    Can you give me the exact Text in the Titel Bar of an open AcrobatReader 8.1.1 with an open Propeller Manual.
    Does it also not work when the Reader is still open?
    And BTW you know ?: the normal use of the context help is to select a word in the source and click then on the icon, the index list opens then only if the word is not found.

    Andy

    Post Edited (Ariba) : 1/16/2008 12:40:59 AM GMT
  • Bob AndersonBob Anderson Posts: 122
    edited 2008-01-16 01:29
    Andy:

    I attached a snapshot that may be helpful.

    I do know that the normal use of context help is to highlight a term and then click the context help icon.· In my case, that always brought up page 1 of the manual.

    I'm not familiar with the FoxitReader, but I'll give it a try.

    Thanks.
    686 x 365 - 50K
  • Bob AndersonBob Anderson Posts: 122
    edited 2008-01-16 01:37
    Andy:

    I loaded up Foxit Reader. Everything works as expected. And it is much faster than Adobe.

    Thanks again.

    Bob
  • AribaAriba Posts: 2,682
    edited 2008-01-16 06:30
    I see the problem: they have eliminated the brackets around "Propeller Manual v1.01.pdf", and I test exactly for this.
    Another change for the next version...

    But I'm glad that it works for you now [noparse]:)[/noparse]

    Andy
  • Cluso99Cluso99 Posts: 18,069
    edited 2012-03-10 13:48
    How have I missed gem?
  • RoadsterRoadster Posts: 209
    edited 2012-03-10 16:55
    This is cool, I don't know how I missed this project, I use both PASD (Debugger) and Prop Terminal
  • turbosupraturbosupra Posts: 1,088
    edited 2012-03-11 06:25
    This looks quite promising, I don't have a prop here to test with. Do you have something where we can highlight and comment out, like Visual Studio has? (thanks for the bump Cluso)

    I would pay for a version that would allow me to compile and run (to a virtual prop) with break points. It is so much more difficult without being able to step through the code in real time.
  • AribaAriba Posts: 2,682
    edited 2012-03-11 11:51
    Thanks Cluso99 for bumping it.

    It's a long time since I've done this, but I use it every time when I start the PropTool (mainly to auto-control the PropTerminal).

    @Roadster
    If you use PropTerminal, then PreSpin gives you an Icon to Compile and Run a Spin file, but also minimizes first PropTerminal and restores it right after the download has finished.

    @turbosupra
    Nothing to higlight and comment out, but in Spin you have the { } curly brackets for that.
    ViewPort has a Debugger with Breakpoints and Single-Step for Spin, and you even can pay for it ;-)

    Andy
  • turbosupraturbosupra Posts: 1,088
    edited 2012-03-11 12:02
    I own viewport, I just haven't ever had much success in working with it, maybe I should try again?


    Ariba wrote: »
    @turbosupra
    Nothing to higlight and comment out, but in Spin you have the { } curly brackets for that.
    ViewPort has a Debugger with Breakpoints and Single-Step for Spin, and you even can pay for it ;-)

    Andy
  • Cluso99Cluso99 Posts: 18,069
    edited 2012-03-11 17:16
    turbosupra: I did a debugger that can step both pasm and spin, you can say run 100 instructions. There is no breakpoints included. I had tried to link it to a homespun listing but it was too complex on the pc side. IIRC its called Zero Footprint Debugger (see the tools link in my signature). Jazzed also did a debugger and I think it has a better windoze interface.

    andy: I presume this does not work with bst, which is what I use for complex programs now. For simple ones, I stick to PropTool only because I can publish the code and anyone can use it.

    The INCLUDE feature is one that I really require when doing code modules for the OS I am working on. Most of the code is identical, so it makes it easy for anyone to write OS extensions, like a better DIR command, etc. Shortly I will give your prespin a try at this as I think this will be one of the solutions I have been looking for.

    Thanks again Andy. It is amazing of how much has been done in the past and is burried in these forums.
  • Cluso99Cluso99 Posts: 18,069
    edited 2012-03-15 23:12
    Andy: I tried PreSpin but it did not process the #include directive. I tried different extensions and names. I downloaded v0.3 from your website, but still does not work.
    I think it probably isnt finding the file to include because it does copy the file to the new tab in proptool.

    I am using PropTool 1.30 located in C:\PropTool130 and my spin file and include file are both in C:\Propeller\RamBladeOS\PropOS_002
    I am running Windows XP SP3 English

    I have attached the two programs in question in case you can see something silly.

    Postedit: Solved. Andy's program requires a preceeding apostrophe making the include directive a comment.
    '#include "file.spin"
    

    _FREE2.spin_inc.spin
  • AribaAriba Posts: 2,682
    edited 2012-03-16 03:08
    Hi Cluso99

    Yes, all the preprocessor directives are written as special comments.
    If PreSpin has not the right path for the incude file, or the objects, then it helps to load the Spin file over the Load icon of PreSpin.

    Andy
  • Cluso99Cluso99 Posts: 18,069
    edited 2012-03-16 05:11
    Thanks Andy. That is what I did - load the spin file using PreSpin. I then clicked the prespin and it loaded the file with the included file contents into a new proptool window. I then compiled with proptool and it compiled nicely.

    Works great! Some nice gems like this are so easily overlooked.
  • cavelambcavelamb Posts: 720
    edited 2012-03-16 14:49
    ANYthing that doesn't depend on indentation for program structure and you'll be my hero forever!
Sign In or Register to comment.