spin2cpp version 1.03 uploaded
ersmith
Posts: 6,054
I've uploaded version 1.03 of spin2cpp, a tool for converting Spin to C++ (and in some cases plain C). This version has quite a few bug fixes relative to version 1.02, so I recommend getting it if you use spin2cpp much.
The adventurous will note that version 1.03 has a -p2 flag for Propeller2 support, thanks to work contributed by David Betz (thanks!). This is still quite incomplete -- the spin2cpp assembler doesn't yet have all the P2 opcodes, and there are a lot of missing features, not to mention that the hardware differences between P1 and P2 mean that many Spin programs would need changes to work on P2.
(Downloads are available from the spin2cpp web page at http://code.google.com/p/spin2cpp/.)
Eric
The adventurous will note that version 1.03 has a -p2 flag for Propeller2 support, thanks to work contributed by David Betz (thanks!). This is still quite incomplete -- the spin2cpp assembler doesn't yet have all the P2 opcodes, and there are a lot of missing features, not to mention that the hardware differences between P1 and P2 mean that many Spin programs would need changes to work on P2.
(Downloads are available from the spin2cpp web page at http://code.google.com/p/spin2cpp/.)
Eric
Comments
(Actually, I think I did this already, without the -p2 flag... I remember now, had to change INA to PINA and OUTA to PINA...)
I'm still trying to break your program (in the nicest possible way), and it is getting harder as you keep squashing the bugs, but would you be able to run this little spin program through and see what it produces
The reboot instruction creates this line
which the GCC compiler does not seem to like.
Any help here would be most appreciated.
Yes, but if the P1 Spin code uses any register accesses then it'll probably need changing. So in practice the -p2 flag is useful only for higher level functions; low level drivers will probably need to be ported by hand.
Eric
The constant _clkmode in the Spin source is conflicting with a built in constant in PropGCC. The _clkmode and _xinfreq constants will not have any effect on the compiled program anyway, so for now I would comment them out for use with spin2cpp. I will change spin2cpp so that variables like that are renamed. Thanks for the bug report!
Eric
I'm getting errors on all my OUTA lines that use a range, like this:
outa[0..7]:=-1
Doesn't complain in P1 mode or other outa statements...
I think the OUTA translation uses the P2 setp() function, which only allows for 1 pin to be set at a time. As I mentioned, the P2 support is still *very* experimental at this stage :-). Probably we should have it use PINA instead, but with anything touching hardware there are likely to be changes required between P1 and P2.
Thanks for the bug report,
Eric
Function and variable names are preserved. The case is normalized, since C is case sensitive and Spin isn't, so foo, Foo, and FOO are all the same variable in Spin and all come out as Foo in C. Comments are not preserved. The overall intent is actually to use spin2cpp in Makefiles or as part of work-flow to compile Spin files into linkable .o files, so generally you'd probably keep the original source code in Spin (perhaps marked up with some spin2cpp comments, which start with "{++") and convert after edits automatically. The IDE doesn't yet support that though.
Eric
No, that's not it at all... there's no OUTA translation at all, and OUTA is not recognized as a special symbol in P2 mode (since there is no OUTA register there). I'm surprised you're not getting errors on OUTA statements without ranges; for me I get "error:Unknown symbol Outa" when I try to use it.
OUTA ranges usually won't work on P2 anyway, because the compiler will generally create read-modify-write sequences to manipulate subsets of bits, and in P2 reading PINA is very different from reading OUTA in P1 (it actually acts like reading INA instead)!
Eric
But, it sounds like you might have a P2 Spin compiler...
Thanks ++