Shop OBEX P1 Docs P2 Docs Learn Events
Spin Tools IDE — Parallax Forums

Spin Tools IDE

maccamacca Posts: 708
edited 2023-09-23 08:58 in Propeller 2

Hello,

Sometimes ago I proposed a new enhanced IDE for spin programs. Despite the low interest, I continued to develop the tool for my own needs, it is still a bit rough on some aspects but I believe it is now ready for an official presentation.

Here is the new Spin Tools IDE:

The interface shows the file browser, the code editor with syntax highlight and the code outline view.

The code is compiled in realtime while it is typed and errors are shown immediately, without the need to push a compile button. The code can be easily navigated by ctrl-clicking on a method to move to its definition.

Hovering on a method name shows the description if available:

Code assist shows the linked object methods and descriptions:

The outline view shows the sections and public labels, PUB/PRI methods are shown with the parameters and return values. Comments on the section keyword line are also displayed for easy navigation.

Compared to Propeller Tools there are some differences:

  • Local variables can have the same name as global variables, there is a warning highlight when a local variable hides a global variable so you know what happens.
  • All constants are calculated as 64 bit integers and masked as 32 bit when the result is used.
  • Integer and floating point values can be used on the same expression.
  • The F8 information window also shows the bytecode listing.
  • Debug statements are not yet supported.

The binary packages for Linux, Windows and MacOS can be downloaded from here (requires the Java SE 17 or later runtime already installed).

The source code is not yet published on GitHub.

Beware that this is a work in progress, while I do my best to make the compiler working, I'm certain that there are still some bugs so if something appears to not work as expected, try with Propeller Tools or PNut. All libraries and examples included in the package are tested to produce byte-exact binaries with Propeller Tools, with some exceptions due to floating point approximations or expression operations sequence that doesn't alter the results.

As usual, use at your own risk!

Hope you enjoy!

«13456714

Comments

  • @macca
    Thank you for you efforts! I'm sure this will be useful.

  • Wuerfel_21Wuerfel_21 Posts: 4,374
    edited 2022-03-04 13:03

    Begets this on startup, but seems to work otherwise. There is no log file created, so IDK what it's on about.

    LED blinker works, so, yeah, cool.

    Immediate "criticism" from messing around for 10 minutes:

    • no DEBUG (if you need a reference on how to generate debug bytecode, I've done it before)
    • no Align mode
    • no block-select/multi-cursor
    • no preprocessor (and seems to choke on trying to parse #directives)
    • Spin compiler doesn't take @"string" syntax
    • has the same issue as proptool where it will only compile a P2 program after saving it to a file
    • PTRx/Px use the same highlighting class as instructions. In proptool they're bold black, not red. Perhaps a taste issue.
    • Spin compiler is just as intelligent as PNut (I guess that's a feature-not-a-bug tho). At least there's unused method elimination
  • @Wuerfel_21 said:
    Begets this on startup, but seems to work otherwise. There is no log file created, so IDK what it's on about.

    I should have known, a small first-time use issue. Will fix soon.

    Immediate "criticism" from messing around for 10 minutes:

    Yes, I wrote that, I'll look at your code.

    • no Align mode

    If you mean the alignl/w keywords, they should work. Otherwise what you mean ?

    • no block-select/multi-cursor
    • no preprocessor (and seems to choke on trying to parse #directives)

    Not planned to be added in the near future. Of course unsupported syntax can cause all sort of issues.

    • Spin compiler doesn't take @"string" syntax

    That's a new feature introduced with one of the most recent versions of PNut (does Propeller Tools already supports that ? I don't know), I'll add it when I understand what it is used for.

    • has the same issue as proptool where it will only compile a P2 program after saving it to a file

    Nope, it all depends on the file extension even when not saved. There are 3 new file commands, new P1 template compiles for P1, new P2 template compiles for P2, but if you use the new alone it attempts to create a new file based on the currently opened editor (p1 or p2), of course if there are no open editors it has to select a default which is p1. This may be a selection in the future preferences dialog.

    • Spin compiler is just as intelligent as PNut (I guess that's a feature-not-a-bug tho). At least there's unused method elimination

    Keep in mind that I did that by reverse engineering the generated code, even now that the PNut source is available I find more easy to reverse engineer it rather than looking at the assembler code, so the first goal was to produce the same binaries. Further optimizations may be added in the future if there is enough interest and/or collaboration.

  • @Wuerfel_21 said:

    • Spin compiler doesn't take @"string" syntax

    I found the description of that. With my compiler you don't need the @ just use the string:
    ser.str("Hello, World")

    Should also work for P1 sources.

  • @macca said:

    • no Align mode

    If you mean the alignl/w keywords, they should work. Otherwise what you mean ?

    I mean the "Align" editor mode you can get in proptool by pressing Insert twice. When it is enabled, typing while there are at least two spaces after the cursor will overwrite the first space and when deleting a character, a space is added to the next run of two or more spaces. Invaluable for ASM, I think.

    • Spin compiler doesn't take @"string" syntax

    That's a new feature introduced with one of the most recent versions of PNut (does Propeller Tools already supports that ? I don't know), I'll add it when I understand what it is used for.

    It's been in flexspin for ages, just recently convinced Chip to add it, too. It's basically the same thing as string("string")

    Keep in mind that I did that by reverse engineering the generated code, even now that the PNut source is available I find more easy to reverse engineer it rather than looking at the assembler code, so the first goal was to produce the same binaries. Further optimizations may be added in the future if there is enough interest and/or collaboration.

    Yeah the PNut source is basically indecipherable. I tried to get binary matches with flexspin's P1 bytecode at first, too, but gave up on that because the frontend just isn't built for that. The most obvious/easy-to-implement bytecode optimizations, off the top off my head. They're all really simple no-brainers:

    • On P1, emit the 8 bit constant opcode instead of the bit constant opcode when both are possible (such as with 2,4,8,etc). The former is a few cycles faster.
    • If branch condition is a constant expression (which should be easy to tell if you can fold them), compile to unconditional branch/no branch
    • For REPEAT N on P1 (not sure if it applies to P2, too), omit the TJZ bytecode if the repeat count is constant and not zero.
    • If an unconditional branch goes to a small terminal opcode like a return OR another unconditional branch, replace the branch with that.
    • If a conditional branch jumps over one unconditonal branch, replace with the opposite conditional branch.
    • After the function is compiled, delete all code between a terminal opcode (unconditional branch, return, etc) and a branch target (depending on your IR, you have to remove unused labels first).
    • All bytecode level optimizations should be repeated until nothing changes anymore.
  • @macca said:

    @Wuerfel_21 said:

    • Spin compiler doesn't take @"string" syntax

    I found the description of that. With my compiler you don't need the @ just use the string:
    ser.str("Hello, World")

    Should also work for P1 sources.

    That is very very wrong. An unqualified string literal is supposed to be an integer.

  • @Wuerfel_21 said:

    @macca said:

    @Wuerfel_21 said:

    • Spin compiler doesn't take @"string" syntax

    I found the description of that. With my compiler you don't need the @ just use the string:
    ser.str("Hello, World")

    Should also work for P1 sources.

    That is very very wrong. An unqualified string literal is supposed to be an integer.

    Yes, but it is confusing only when the string is one character.
    Maybe I'll add the @ syntax to cover what I believe is an edge case of a single char string passed as argument.

  • @macca said:
    Yes, but it is confusing only when the string is one character.

    I was about to say that you can actually have constants of up to four characters in an integer, but I guess there's some sort of mandela effect Smile going on, because it doesn't seem to actually work that way in proptool. I remember it working that way, but apparently not.

  • Posted version 0.11:

    • Added support for spin floating point
    • Initial support for debug statements
    • Implemented @"String" for compatibility
    • Command line compiler
    • Some general fixes
  • JonnyMacJonnyMac Posts: 8,912
    edited 2022-08-28 17:02

    I just downloaded and installed version 0.18. I like what you're doing, and will offer you these suggestions (many from my requests to Parallax vis-a-vis Propeller Tool).

    • Implement Preferences (I'm guessing on your To-Do list) and link to F5.

    • Allow user to set indentation size and tab stops for the "Format Source" feature (I prefer two spaces for Spin).

    • Allow user to set P1 and P2 favorite folders in the Preferences dialog. If defined these folders would appear in the Open From list.

    • Add F9 (compile only with status)

    • Add a toolbar
      -- New P1
      -- New P2
      -- Open
      -- Save (SaveAs if unnamed)
      -- Close
      -- Undo
      -- Redo
      -- Cut
      -- Copy
      -- Paste
      -- Find/Replace
      -- Preferences
      -- Debug On/Off
      -- Compile Info (F8)
      -- Compile Status (F9)
      -- Compile Load RAM (F10)
      -- Compile Load EEPROM/Flash (F11)
      -- Terminal (F12)

    • Allow IDE to detect source type based on comment flag: {$P1} or {$P2}. Parallax used this in the BASIC Stamp IDE which was quite helpful for those of use using standard BS2s and BS2p modules. Detection would set the extension in the Save As dialog.

    • Split the left-side folder window into two: the upper portion showing a Propeller-Tool style project tree (parent and objects used), the lower being the folder that holds the file shown in the selected tab.

    I believe when Brad started BST, he targeted matching Propeller Tool (i.e., identical binaries), and then started adding features like dead code removal. For one customer we are forced to use BST because the application is so big that we cannot get it to fit using Propeller Tool which compiles every method, used or not. I'm hoping you go in that direction, too. I will be porting that P1 project to the P2, and would like the smallest possible binary as we allow the customer to update code over XBee radio.

    Thank you for your work on this. Maybe Parallax will have a look and consider getting rid of their old, single-target compiler tool (and source that uses libraries that cannot be shared).

  • JonnyMacJonnyMac Posts: 8,912
    edited 2022-08-28 16:58

    A feature of Propeller Tool that I find quite useful is the Alt-Block select feature.

    Would this be possible in Spin Tools?

  • @JonnyMac said:
    I just downloaded and installed version 0.18. I like what you're doing, and will offer you these suggestions (many from my requests to Parallax vis-a-vis Propeller Tool).

    • Implement Preferences (I'm guessing on your To-Do list) and link to F5.

    • Allow user to set indentation size and tab stops for the "Format Source" feature (I prefer two spaces for Spin).

    • Allow user to set P1 and P2 favorite folders in the Preferences dialog. If defined these folders would appear in the Open From list.

    • Add F9 (compile only with status)

    • Add a toolbar
      -- New P1
      -- New P2
      -- Open
      -- Save (SaveAs if unnamed)
      -- Close
      -- Undo
      -- Redo
      -- Cut
      -- Copy
      -- Paste
      -- Find/Replace
      -- Preferences
      -- Debug On/Off
      -- Compile Info (F8)
      -- Compile Status (F9)
      -- Compile Load RAM (F10)
      -- Compile Load EEPROM/Flash (F11)
      -- Terminal (F12)

    • Allow IDE to detect source type based on comment flag: {$P1} or {$P2}. Parallax used this in the BASIC Stamp IDE which was quite helpful for those of use using standard BS2s and BS2p modules. Detection would set the extension in the Save As dialog.

    • Split the left-side folder window into two: the upper portion showing a Propeller-Tool style project tree (parent and objects used), the lower being the folder that holds the file shown in the selected tab.

    I believe when Brad started BST, he targeted matching Propeller Tool (i.e., identical binaries), and then started adding features like dead code removal. For one customer we are forced to use BST because the application is so big that we cannot get it to fit using Propeller Tool which compiles every method, used or not. I'm hoping you go in that direction, too. I will be porting that P1 project to the P2, and would like the smallest possible binary as we allow the customer to update code over XBee radio.

    Thank you for your work on this. Maybe Parallax will have a look and consider getting rid of their old, single-target compiler tool (and source that uses libraries that cannot be shared).

    This is good summary, couldn't say it better.

    I tried same version on windows 10. Left-side folder windows shows the user-folder for me, which is not of use for me. What was your intention to show here?
    'Code assist with linked object inspection' is really good, that's a feature I always wanted.
    Maybe something could be done based on Chip's new debuggerfeatures (https://forums.parallax.com/discussion/comment/1542058/#Comment_1542058): Named-variables watch-window, maybe even source-level-debugging, at least for assembler.
    Chip's debug window is giving me headaches, no idea where to look for finding, the information I want.

    What can be done to support you?
    Will you publish the source code.?

  • 'Code assist with linked object inspection' is really good, that's a feature I always wanted.

    I like that, too.

  • @JonnyMac said:
    I just downloaded and installed version 0.18. I like what you're doing, and will offer you these suggestions (many from my requests to Parallax vis-a-vis Propeller Tool).

    • Implement Preferences (I'm guessing on your To-Do list) and link to F5.

    Yes, the preferences are on the todo-list, there are a lot to implement, including tab size, highlight colors, etc. as well as the other suggestions.

    • Add F9 (compile only with status)

    Not sure it is needed. As you may have noticed, the source is constantly compiled and errors are shown immediately (you don't need to press any key to compile).

    • Allow IDE to detect source type based on comment flag: {$P1} or {$P2}. Parallax used this in the BASIC Stamp IDE which was quite helpful for those of use using standard BS2s and BS2p modules. Detection would set the extension in the Save As dialog.

    This seems to imply that sources doesn't have .spin or .spin2 extension. What is the use case for that (give than the IDE doesn't support BASIC stamp) ?

    The IDE, like PropellerTools, detects the target based on the extension, however it has those two 'New (from P1/P2 template)' menu items to directly set the target and the file doesn't have to be saved to be compiled.
    The 'New' menu item detects the target using the currently focused source (it actually uses the same extension).
    The only undefined situation is where there aren't opened sources, at this time it opens a .spin (P1) source. This may be a configuration item with default to P1 or P2 or disable.

    I believe when Brad started BST, he targeted matching Propeller Tool (i.e., identical binaries), and then started adding features like dead code removal. For one customer we are forced to use BST because the application is so big that we cannot get it to fit using Propeller Tool which compiles every method, used or not. I'm hoping you go in that direction, too. I will be porting that P1 project to the P2, and would like the smallest possible binary as we allow the customer to update code over XBee radio.

    I did the same.
    The compiler always removes the unused methods, but doesn't have a dead code removal optimization (doesn't have any optimizations, aside from the constants expressions).
    Compiling existing code with this IDE may be a bit weird because chances are that it won't compile due to some constraints, like case sensitive identifiers (sorry but I got tired of having sources with randomly cased identifiers) and some differences on how the expressions are evaluated.

  • @dnalor said:
    I tried same version on windows 10. Left-side folder windows shows the user-folder for me, which is not of use for me. What was your intention to show here?

    The intention is to have a tree focused on folders used for development. Currently it opens on the user home folder and filters all not .spin or .spin2 files, a preference will be used to se the folder or folders to show in this tree. Maybe also an automatic refocus on the folder that contains the currently edited source. In other words, should be a way to quickly locate and open source files of interest.

    'Code assist with linked object inspection' is really good, that's a feature I always wanted.

    The feature list is not updated but there is also code navigation: hold the CTRL key and when you hover on a method identifier it is highlighted, clicking with the mouse opens the editor at the start of that method. Same for the OBJ definitions, CTRL+click on the file name to open it.

    Maybe something could be done based on Chip's new debuggerfeatures (https://forums.parallax.com/discussion/comment/1542058/#Comment_1542058): Named-variables watch-window, maybe even source-level-debugging, at least for assembler.
    Chip's debug window is giving me headaches, no idea where to look for finding, the information I want.

    I haven't yet used the new debugger, I don't think I'll ever implement it unless there is a very detailed documentation on the data it sends (I haven't even implemented the graphical debugger features, mainly because I'm not using them). I had enough headaches implementing the compiler.
    I would like to implement a proper debugger however, with source-based step execution, registers and memory inspection, etc. integrated into the IDE.

    What can be done to support you?
    Will you publish the source code.?

    Not sure about this, will think about it.

  • I can't open it on my mac.
    Version 12.5.1
    MacBook Pro (13-inch, M1, 2020)

  • @frida said:
    I can't open it on my mac.
    Version 12.5.1
    MacBook Pro (13-inch, M1, 2020)

    I think it is because it wasn't downloaded from the app store.
    You should be able to run it by setting a preference from the right-click menu or something (sorry I don't have a mac).
    This may help https://support.apple.com/en-us/HT202491

  • @frida said:
    I can't open it on my mac.
    Version 12.5.1

    On first attempt to launch the app, if you control-click on the application icon (in the Finder), you will be provided with a dialog that allows running the app. After that, the app can be launched in the normal way.

    dgately

  • Hi Macca,

    attached is a screenshot of the issues i mentioned in my other thread post yesterday.

    1) Get the preference window working, 1st start with a font selection, and size, later you can add themes and syntax coloring customisation.
    2) add a toolbar header with all the basic buttons for loading etc
    3) In the preferences, have the user select a HOME FOLDER instead of the whole user directory. and as you mentioned, have the option of highlighting the file in the browser that's selected in the editor.
    4) Allow the user to show or hide the indent lines AND allow the user to choose the colour and width of the indent lines!
    5) I can see you are using drawing function to create the indent lines, a suggestion could be to use a BOX DRAWING FONT instead, but if you only need to tweek the line drawing functions you have already implemented, then it's probably less work to get them displaying properly instead of finding and implementing box drawing fonts ( like the parallax font)

    thanks

    keep up the good work!

  • @DavidM said:
    attached is a screenshot of the issues i mentioned in my other thread post yesterday.

    The issue here is the proportional font, the indent lines assumes the font is fixed width, I guess the generic "mono" name that works for Linux doesn't work on the Mac. I think the blurry appearance is related to that, I'll see if there is a more cross-platform way to get a default font and add the preferences page to change it.

    The error may be becase the symbols are case sensitive (got tired to see the same method called with all sort of upper/lower case combinations, this may be a preference setting).

    5) I can see you are using drawing function to create the indent lines, a suggestion could be to use a BOX DRAWING FONT instead, but if you only need to tweek the line drawing functions you have already implemented, then it's probably less work to get them displaying properly instead of finding and implementing box drawing fonts ( like the parallax font)

    I'll keep the line drawing overlay.

  • DavidMDavidM Posts: 626
    edited 2023-01-29 20:59

    @macca said:

    @DavidM said:
    attached is a screenshot of the issues i mentioned in my other thread post yesterday.

    The issue here is the proportional font, the indent lines assumes the font is fixed width, I guess the generic "mono" name that works for Linux doesn't work on the Mac. I think the blurry appearance is related to that, I'll see if there is a more cross-platform way to get a default font and add the preferences page to change it.

    A font i use on the mac is COURIER, could you not also use the Parallax font? as it has the symbols for drawing?

    The error may be because the symbols are case sensitive (got tired to see the same method called with all sort of upper/lower case combinations, this may be a preference setting).

    I suggest to use NON case sensitive, I am not sure/cant remember what spin prefers. and you probably should make this a preference setting.

    5) I can see you are using drawing function to create the indent lines, a suggestion could be to use a BOX DRAWING FONT instead, but if you only need to tweek the line drawing functions you have already implemented, then it's probably less work to get them displaying properly instead of finding and implementing box drawing fonts ( like the parallax font)

    I'll keep the line drawing overlay.

    Line drawing overlay is better, but please add the ability to set colour and line thickness, also, you could get fancy and have a preference to allow the user to select, left/centre/right justification for vertical indentation lines of either the first character or the whole word its referring to.

    Thanks Macca, for taking time to work on this, cant wait for your next release!

  • JonnyMacJonnyMac Posts: 8,912
    edited 2023-01-29 21:19

    SpinIDE on Windows uses Courier -- the only problem is (for the moment) I can't change the size.

    I suggest to use NON case sensitive, I am not sure/cant remember what spin prefers. and you probably should make this a preference setting.

    Spin is not case sensitive. I use lowercase for everything except user constants (uppercase) and pre-assigned DAT variables (Pascal Case).

  • @JonnyMac said:

    Spin is not case sensitive. I use lowercase for everything except user constants (uppercase) and pre-assigned DAT variables (Pascal Case).

    OK, i thought that was the "case".

    i'm glad spin is NOT case sensitive.

    I hope Macca is working on getting us a preference window working with at least a few options, starting with user selectable font, and size.

    thanks

  • JonnyMacJonnyMac Posts: 8,912
    edited 2023-01-29 21:50

    I hope Macca is working on getting us a preference window working with at least a few options, starting with user selectable font, and size.

    Me, too. I really like what he's doing -- so much that I suggested to @"Jeff Martin" that he consider using it to replace the current Windows-only Spin Tool (once it matches all Spin Tool features).

  • @JonnyMac said:

    I hope Macca is working on getting us a preference window working with at least a few options, starting with user selectable font, and size.

    Me, too. I really like what he's doing -- so much that I suggested to @"Jeff Martin" that he consider using it to replace the current Windows-only Spin Tool (once it matches all Spin Tool features).

    Cool, are there other propeller users that are interesting in Macca's project?

  • I don't know. I think there will be, though, when it's fully fleshed out. ATM, it seems to be a one-man project and that's a lot to ask. Again, this is why I asked Jeff to get involved.

  • I can help with testing on the mac! as I don't have ANY tool i can use!, and i have a BIG DMX project to get started on.

  • JonnyMacJonnyMac Posts: 8,912
    edited 2023-01-30 03:21

    I'm a Windows guy but was recently sent a Mac Mini by the office -- so I can try both (well, when I take the Mac out of the box).

    DMX is pretty easy with the Propeller. You have my drivers, right? My TX driver lets you set the universe size and overall frame timing (in case you want to deal with less. I used a single Propeller to control this display with eight or nine 4-channel DMX bricks. Once cog runs the DMX output, the other cogs are used to create and write animation data (flame and ember effects) directly into the DMX buffer.

    This is in the lobby of Riot Games. Fans of League of Legends will recognize Annie and Tibbers.

  • DavidMDavidM Posts: 626
    edited 2023-01-30 04:53

    @JonnyMac said:
    I'm a Windows guy but was recently sent a Mac Mini by the office -- so I can try both (well, when I take the Mac out of the box).

    "Unboxing video" ?? he he, you should be able to hook up the mac mini to any keyboard, mouse and monitor, its was originally designed for PC users to "SWAP" out their PC and start using a mac with minimal upfront costs. My mac is intel based, I am too planning on getting the new M2 Pro mac mini in the next few weeks and a larger 32 inch display.

    DMX is pretty easy with the Propeller. You have my drivers, right? My TX driver lets you set the universe size and overall frame timing (in case you want to have a buffer for 512 channels plus the start byte). I used a single Propeller to control this display with eight or nine 4-channel DMX bricks. Once cog runs the DMX output, the other cogs are used to create and write animation data directly into the DMX buffer.

    Yes, I have your drivers! Thanks very much. Once i get a working IDE, i should be able to write some test code to get to know the DMX drivers and the protocol. I only know a little about DMX , I have made many DMX cables (Proper ones with 5-pin) but i have done a fair bit of RS485 on previous propeller projects many years ago. In fact i designed my own isolated self terminating board 10 years ago, which i could use for DMX . i cannot wait to get started!, so you may be getting some annoying questions from me about DMX. I did notice that there is not much discussion here on the forums about DMX.

    This is in the lobby of Riot Games. Fans of League of Legends will recognize Annie and Tibbers.

    Cool display!

  • We should probably keep this thread on topic -- sorry that I wandered us off.

Sign In or Register to comment.