FlexProp: a complete programming system for P2 (and P1)
ersmith
Posts: 6,068
Summary: FlexProp is a GUI and compiler that lets you develop programs in Spin 1, Spin 2, BASIC, and C for the Prop 1 and Prop 2. You can mix objects written in the different languages, and it produces fast assembly code as output. Any combination of languages and processors is OK, e.g. you can compile Spin 1 code for P2 (as long as any assembly in DAT sections is P2 compatible) and Spin 2 code for P1 (again, any user provided assembly language has to be P1 compatible in this case).
The latest version may be found at my patreon page ( https://patreon.com/totalspectrum ) or from github ( https://github.com/totalspectrum/flexprop/releases ). Binaries are provided for both Windows and Mac -- the zip file has both. The program runs on Linux too, but you'll have to build it from source there.
Update December 2023:
The most recent release is 6.8.x, which brings the Spin2 language features up to par with PNut v43. It also has a large number of bug fixes and optimization improvements, some new builtin BASIC functions for date and time, support for the Parallax flash file system, ARGv parameters for loadp2 and CHAIN, and support for more C standard library functions.
Update May 2023:
The most recent release is 6.1.x, which has P1 and P2 bytecode output, improved Spin2 compatibility, support for project files, and support for creating .zip files of the source code.
Update September 2021:
FlexProp is now in the 5.9.x series, which is in some sense a "preview" for version 6.0 which will have support for P1 bytecode and a new P2 bytecode output. That is, you can now compile Spin, C, and BASIC programs to bytecode as well as to assembly. The bytecode binaries will be smaller, but slower, than the default assembly language. Bytecode support isn't complete in 5.9.x, but there are a lot of other new features (such as Spin2 floating point support, and support for P2 BRK debugging) which make it worth upgrading. Many thanks to @Wuerfel_21 for her contributions of BRK debugging and P1 bytecode support!
Update May 2021:
The latest version is 5.5.0, which has a lot of bug fixes and improvements.
Update October 2020:
FlexGUI has been renamed to FlexProp to avoid conflict with another product. The functionality is still the same: it is a simple GUI for programming the P1 and P2 in Spin1, Spin2, PASM, BASIC, and C. The languages may be mixed together, so for example you can call a Spin driver from a C program. Output is fast PASM code.
The latest release is available from https://github.com/totalspectrum/flexprop/releases : download the "flexprop.zip", unzip it in some convenient location (e.g. your desktop), and run the "flexprop.exe" program.
Older information
There is a new release of flexgui, a GUI providing a complete programming system for P2 including PASM, Spin, BASIC, and C, and now including a version of micropython and a simple terminal interface for the P2 ROM. It may be downloaded from https://github.com/totalspectrum/flexgui/releases/latest; look for the "flexgui.zip" file for the Windows binary release.
New in this release are menu options for the ROM monitor and TAQOZ, improved C support, and many bug fixes.
If you haven't used FlexGUI yet, or haven't tried it in a while, here are some of its features:
General
PASM Support
Spin support
Both the original Spin 1 and new Spin 2 languages are supported. The Spin 1 support has a number of enhancements:
BASIC Support
fastspin supports a fairly complete version of BASIC, based on traditional Microsoft BASICs. Please see `doc/basic.md` for details. Notable features are:
C Language Support
fastspin supports a C dialect called FlexC, which is intended to be C99 compatible with some C++ extensions. It is not yet complete. Notable enhancements are:
The latest version may be found at my patreon page ( https://patreon.com/totalspectrum ) or from github ( https://github.com/totalspectrum/flexprop/releases ). Binaries are provided for both Windows and Mac -- the zip file has both. The program runs on Linux too, but you'll have to build it from source there.
Update December 2023:
The most recent release is 6.8.x, which brings the Spin2 language features up to par with PNut v43. It also has a large number of bug fixes and optimization improvements, some new builtin BASIC functions for date and time, support for the Parallax flash file system, ARGv parameters for loadp2 and CHAIN, and support for more C standard library functions.
Update May 2023:
The most recent release is 6.1.x, which has P1 and P2 bytecode output, improved Spin2 compatibility, support for project files, and support for creating .zip files of the source code.
Update September 2021:
FlexProp is now in the 5.9.x series, which is in some sense a "preview" for version 6.0 which will have support for P1 bytecode and a new P2 bytecode output. That is, you can now compile Spin, C, and BASIC programs to bytecode as well as to assembly. The bytecode binaries will be smaller, but slower, than the default assembly language. Bytecode support isn't complete in 5.9.x, but there are a lot of other new features (such as Spin2 floating point support, and support for P2 BRK debugging) which make it worth upgrading. Many thanks to @Wuerfel_21 for her contributions of BRK debugging and P1 bytecode support!
Update May 2021:
The latest version is 5.5.0, which has a lot of bug fixes and improvements.
Update October 2020:
FlexGUI has been renamed to FlexProp to avoid conflict with another product. The functionality is still the same: it is a simple GUI for programming the P1 and P2 in Spin1, Spin2, PASM, BASIC, and C. The languages may be mixed together, so for example you can call a Spin driver from a C program. Output is fast PASM code.
The latest release is available from https://github.com/totalspectrum/flexprop/releases : download the "flexprop.zip", unzip it in some convenient location (e.g. your desktop), and run the "flexprop.exe" program.
Older information
There is a new release of flexgui, a GUI providing a complete programming system for P2 including PASM, Spin, BASIC, and C, and now including a version of micropython and a simple terminal interface for the P2 ROM. It may be downloaded from https://github.com/totalspectrum/flexgui/releases/latest; look for the "flexgui.zip" file for the Windows binary release.
New in this release are menu options for the ROM monitor and TAQOZ, improved C support, and many bug fixes.
If you haven't used FlexGUI yet, or haven't tried it in a while, here are some of its features:
General
* Both Propeller1 and Propeller2 are supported
* Supports PASM, Spin 1, Spin 2, BASIC, and C
* View output PASM code
* Built in terminal emulator
* GUI checks files for external changes, so you may use any editor and compile in FlexGUI
* Options for interacting directly with P2 ROM monitor and ROM TAQOZ
* Micropython for P2 sample included
* Supports PASM, Spin 1, Spin 2, BASIC, and C
* View output PASM code
* Built in terminal emulator
* GUI checks files for external changes, so you may use any editor and compile in FlexGUI
* Options for interacting directly with P2 ROM monitor and ROM TAQOZ
* Micropython for P2 sample included
PASM Support
* Both P1 and P2 assembly language supported
* Preprocessor supporting `#define`, `#ifdef`, and `#include`
* Absolute address operator `@ @ @`
* Warnings for common mistakes like forgetting `#` in a jump
* Can compile assembly-only files (no Spin methods required)
* Preprocessor supporting `#define`, `#ifdef`, and `#include`
* Absolute address operator `@ @ @`
* Warnings for common mistakes like forgetting `#` in a jump
* Can compile assembly-only files (no Spin methods required)
Spin support
Both the original Spin 1 and new Spin 2 languages are supported. The Spin 1 support has a number of enhancements:
* Generates optimized PASM instead of bytecode
* `case_fast` to force `case` to produce a jump table
* Conditional expressions like `(x < y) ? x : y`
* Inline assembly inside PUB and PRI functions
* Object pointers
* `pub file` and `pri file` to include functions from other languages (C, BASIC)
* Multiple return values and assignments, e.g. `x,y := y,x`
* Default parameter values for functions
* Optional type specifiers for function parameters and return values
* Automatic passing of strings as pointers in some cases
* Unsigned operators `+/`, `+//`, `+<`, `+=<`, `+>`, `+=>`
* Spin2 operators `\`, `<=>`
* `case_fast` to force `case` to produce a jump table
* Conditional expressions like `(x < y) ? x : y`
* Inline assembly inside PUB and PRI functions
* Object pointers
* `pub file` and `pri file` to include functions from other languages (C, BASIC)
* Multiple return values and assignments, e.g. `x,y := y,x`
* Default parameter values for functions
* Optional type specifiers for function parameters and return values
* Automatic passing of strings as pointers in some cases
* Unsigned operators `+/`, `+//`, `+<`, `+=<`, `+>`, `+=>`
* Spin2 operators `\`, `<=>`
BASIC Support
fastspin supports a fairly complete version of BASIC, based on traditional Microsoft BASICs. Please see `doc/basic.md` for details. Notable features are:
* Structured programming features
* Line numbers are optional
* Garbage collected memory allocation
* Support for classes, and importing Spin objects as classes
* Function closures and immediate functions
* `try` / `catch`
* Inline assembly
* Generic functions and templates
* Line numbers are optional
* Garbage collected memory allocation
* Support for classes, and importing Spin objects as classes
* Function closures and immediate functions
* `try` / `catch`
* Inline assembly
* Generic functions and templates
C Language Support
fastspin supports a C dialect called FlexC, which is intended to be C99 compatible with some C++ extensions. It is not yet complete. Notable enhancements are:
* Inline assembly (similar to MSVC)
* Simple classes, including using Spin and BASIC objects as C classes
* Reference parameters using `&`
* GCC style statement expressions
* Header files may specify linking information for libraries
* Several useful builtin functions
* Simple classes, including using Spin and BASIC objects as C classes
* Reference parameters using `&`
* GCC style statement expressions
* Header files may specify linking information for libraries
* Several useful builtin functions
Comments
Good job!
Cant wait to see how it does with the incoming P2 boards!
@ersmith You have done an amazing job with the Flex suite.
That's great news! Good job, JRoark and Ersmith.
The default terminal doesn't handle Backspace, nor Ctrl+C like a typical Python terminal (e.g., Idle). Still, it's really cool to have Python on a Propeller!
The availability of uPython for P2 May be what gets me into it!
Congratulations, ersmith on this! This is a very cool IDE!
Thanks Eric. You're doing an amazing job here
I just installed flexgui on my PC under W10. I unzipped and renamed the directory flexgui 4.0.3 and then moved to C:\P2\ where I also have older versions of flexgui similarly named with their versions. When I opened flexgui and looked at the options, I note that when I looked at Commands|Configure Commands and then used the Cancel option, it did in fact create and save a default configuration in the same directory (C:\P2\flexgui 4.0.3) called ".flexgui.config". The config looks fine but I was not expecting the cancel option to do anything. Is this normal?
Of course , now I need to find time to try flexgui. I've been using fastspin from the command line previously, and PropTool to edit P2ASM. I should move to VSCode especially since I did a P1/P2 addon a year ago but don't use it
For the record, I'm just some goober who is using it and loving it. Didn't write a single line of code and I have zero comprehension about the internals. Eric is the guy who gets all the credit.
(I just have a talent for blowing things up).
Thanks,
Roger.
"/Users/roger/Downloads/flexgui-4.0.3/bin/fastspin" -2b -l -O1 -I "/Users/roger/Downloads/flexgui-4.0.3/include" "/Users/roger/Downloads/flexgui-4.0.3/samples/hello.spin"
couldn't execute "/Users/roger/Downloads/flexgui-4.0.3/bin/fastspin": no such file or directory
Finished at Sun Nov 10 09:09:27 2019
Odd, I haven't seen that before. Glad you were able to sort it out though.
Ah, I forgot that I have my cmd.exe set to default to ANSI mode. To do that create a registry key HKEY_CURRENT_USER\Console\VirtualTerminalLevel of type DWORD and value 1.
I'll try to figure out some way to automate that in the next FlexGUI release.
Thanks,
Eric
You'll need to do a "git submodule update --recursive" to grab the spin2cpp and loadp2 subdirectories. I cannot build on Mac myself, not having a Mac machine, but someone supplied a "Makefile.mac" which might do the trick (it may have bit rotted so it may need a bit of tweaking).
I develop flexgui on Linux, so it definitely works there although I build loadp2 and fastspin "by hand".
I actually git clone Spin2Cpp and Loadp2 seperately and put their binaries in a common Propeller tools directory (/opt/parallax/bin). Then I set my $PATH environment in the .profile file within my home directory. Like this: When I launch any terminal (Terminal app or xterm within XQuartz), macOS will look in those directories for tools like: loadp2, fastspin, spin2cpp, propeller-elf-gcc, etc... I set up flexgui's "Configure Commands" Compile command to just exec "fastspin" & the Run command to exec loadp2. It finds them in /opt/parallax/bin (which I copy the tools to whenever they are updated).
dgately
Also: Where do I get propeller-loader.exe? Where do I install it?
No. I'm sorry if I gave the wrong impression -- FlexGUI isn't a uPython IDE. It's an IDE for developing PASM, Spin, BASIC, and C programs on the P2. It's also able to *run* uPython on the P2, and Forth (via the built-in TAQOZ in the ROM) and Lisp (via the proplisp program in the sample directory). But it doesn't really provide any tools to help you develop python, forth, or lisp programs, just the basic ability to run them on the P2.
Sounds like there's something out of date in the documentation. You don't need propeller-loader.exe, you can use the proploader.exe that's already in the bin folder to run programs on P1. Just go to "Commands > Configure Commands..." and press the "P1 defaults" button and you should be all set.
If you have the P2-ES accessory set then there's an alternative to editing the Windows registry to force ANSI support in cmd.exe. Plug the "Serial Host" board in to pin group 16 and the "A/V" board in to pin group 48, hook up a USB keyboard and VGA monitor, and do your typing and display that way. You can also put in an SD card with the pye.py program from samples/upython and use pye as an editor for Python code on the SD card.
I’m not aware of any BASIC-specific benchmarks per se, but I can tell you from personal experience it is entirely possible to toggle an output pin on the FLiP module at 5 mhz without breaking a sweat. Not too shabby!
The BASIC code gets compiled down to PASM. Its pretty efficient. I’ll grant you that its slower than pure assembly, and to some extent C, but the deployment/debug time is so much faster.
You might download this critter and wiggle some bits. I think you’ll be impressed. And if not, change gears and play with PASM, Spin, C or uPython.... without ever leaving the FlexGui editor/compiler/suite. Thats just darned-Skippy impressive... at least to me.
Edited to add: I have not personally called PASM from FlexBASIC, but I’ve got a fiver that says it can be done. And indeed you can put PASM code inline with FlexBASIC. Lets get @ersmith to weigh-in here for a non-fanboy answer.
Here's a bit-banging benchmark; it streams 32 bit words out a pin from HUB memory as quickly as it can. I've provided fastspin basic and generic C versions. I'll also have to confess that this is a benchmark that fastspin is particularly good at, because bit-banging is something I've tried to optimize. If you have some more generic benchmarks I'd be interested in trying those.
The P1 numbers are all in LMM mode; P2 are all in native mode. The command lines used for P2 are:
I haven't got a PropBASIC version of the benchmark. My expectation would be that PropBASIC LMM mode would come in about a third to a quarter of the speed of fastspin LMM (so around 400K cycles). fastspin has FCACHE (and hence avoids LMM overhead completely in the inner loop) and has an optimizer, both of which will improve its performance over PropBASIC, although carefully written code can mitigate the missing optimizer.
P2 results (cycles to send 256 longs, lower is better):
P1 results:
You'll notice that the compilers are much closer together on P2, because hubexec presents a more even target for the compiler (on P1 the performance of the LMM interpreter pretty much dominates things). If you leave the -O2 flag off of fastspin for P2 the performance gets even closer, since it removes the LUT caching that fastspin does in -O2.
The fastspin C version on P2 benefits from the built-in dirh/dirl instructions, which the BASIC version does not, which explains why C is faster there. Conversely, on P1 the BASIC language output() array provides the optimizer with more information than the C based OUTA, so on P1 the BASIC code is a bit faster than C.
It depends on what you mean by calling PASM from FlexBASIC, exactly, but I think that for all practical purposes it can be done. Certainly you can take an existing (or new) Spin+PASM object and call it directly from BASIC. You can also write a BASIC function whose contents are almost entirely PASM, although often it's useful to include some variable declarations and perhaps a return statement outside of the asm block.