Shop OBEX P1 Docs P2 Docs Learn Events
spin2cpp introduction tutorial posted — Parallax Forums

spin2cpp introduction tutorial posted

SRLMSRLM Posts: 5,045
edited 2013-05-23 00:17 in Propeller 1
Hi everyone: I've developed a tutorial that provides a simple introduction to the spin2cpp utility. If you have any feedback, be sure to let me know:

[size=+2]Tutorial
https://sites.google.com/site/propellergcc/documentation/tutorials/spin2cpp[/size]

Thanks to all the sources of the material (mainly ersmith!) and the forums for asking all the questions.

Questions/Feature requests:
Can spin2cpp add the reference to ASM blocks for garbage collection options?
Basically, the PASM sections need a reference to prevent linker garbage collection. I came up with the following:
volatile void * reference;
    __asm__ volatile (
        "mov %[reference], #cogtoggleMain \n\t"
    :
        [reference] "+r" (reference)
    );
Source: http://forums.parallax.com/showthread.php/147068-solved-Garbage-Collection-again

spin2cpp doesn't do well with converting files with spaces in them. Would it be possible to have spin2cpp automatically rename the output to not use spaces?
user@desktop:~/Downloads/spin2cpp_demo$ spin2cpp --elf -Os -o quickstart.elf Touch\ Buttons\ LED\ Demo\ v1.0.spin 
propeller-elf-gcc: error: Touch: No such file or directory
propeller-elf-gcc: error: Buttons: No such file or directory
propeller-elf-gcc: error: LED: No such file or directory
propeller-elf-gcc: error: Demo: No such file or directory
propeller-elf-gcc: error: v1.0.cpp: No such file or directory
propeller-elf-gcc: error: Touch: No such file or directory
propeller-elf-gcc: error: Buttons.cpp: No such file or directory
propeller-elf-gcc: fatal error: no input files
compilation terminated.

Can constant conversion be complete (put into GAS assembly, and keep the format (hex, binary, or decimal) of original)?
I've noticed that when generating GAS assembly, the constant is specified twice: once in the GAS, and once in the .h file. Also, in the .h file, the constant is converted to decimal. Could we have a single declaration and in the same base as the original?

Comments

  • Heater.Heater. Posts: 21,230
    edited 2013-05-22 15:40
    Spaces in file names are a real pain and should basically be banned.

    For example if under Unix/Linux/Mac I list the files in a directory and I get this:
    $ ls
    how many files are here
    $
    Well, how many files are there?

    Also it makes tab completion n the command line more awkward to use.
  • ersmithersmith Posts: 6,054
    edited 2013-05-22 18:57
    That's a fantastic tutorial. Thank you very much for posting it!

    Some responses to your questions:

    (1) I've just pushed a binutils change so that sections named .cog* or *.cog are always marked KEEP during garbage collection. That, together with your recent linker script fixes, should make gc-sections a lot easier to use.

    (2) I hadn't noticed the space issue, thanks for pointing it out. I don't think changing the file name automatically is a good idea, but spin2cpp should escape the spaces or quote the name. I'll look into it.

    (3) The constant handling is a bit awkward. There was some reason I wanted to avoid #define (I think there may have been a namespace issue with Spin objects) but unfortunately the assembly language can't directly access const variables. Maybe passing them in as parameters would help, but that's kind of ugly too. I'm open to suggestions!

    Thanks,
    Eric
  • SRLMSRLM Posts: 5,045
    edited 2013-05-23 00:17
    1) It looks like you're talking about the 8bce5f076c18c5924096b3fccd8e55b82b1208fd revision to /binutils/bfd/elf32-propeller.c? I don't understand at all what the code is doing or how it does it, but if it means that we don't have to manually provide a reference then I'm happy. I'll test it out in the next few days and see what happens with my code.
    2) I was thinking of changing the name on the output files, but however you can get it to work would be great. I agree that spaces in filenames are terrible, but Parallax seems to like them.
    3) I doubt I have anything better, but if I can think of something I'll post it.
Sign In or Register to comment.