fastspin compiler for P2: Assembly, Spin, BASIC, and C in one compiler

13637394142

Comments

  • ersmith wrote: »
    It does parse all of the source code and creates an abstract syntax tree for all methods, so syntax errors are definitely caught.
    That's probably good enough.

  • roglohrogloh Posts: 1,988
    edited 2020-02-14 - 06:21:43
    @ersmith I found an issue with the Fastspin v4.1.2 listing file not showing the LUT addresses correctly next to the PASM code output. Seems to show LUT code starting at $080 instead of $200 in my example below.

    I also tried to org this LUT code at $220 as well and the listing file start address then changed to 088, so its base value appears to be off by a factor of 4. It does increment by one at least after that, but this offset makes checking/debugging LUT address contents hard. Hopefully a simple fix.
    0409c                 | hyperflash_service
    0409c     2D 02 00 00 |                             long    read_byte
    040a0     2F 02 00 00 |                             long    read_word
    040a4     32 02 00 00 |                             long    read_long
    040a8     35 02 00 00 |                             long    read_burst
    040ac     15 01 00 00 |                             long    unsupported
    040b0     B1 02 00 00 |                             long    write_word_flash
    040b4     15 01 00 00 |                             long    unsupported
    040b8     15 01 00 00 |                             long    write_burst_flash ' TODO
    040bc                 | 
    040bc                 | ' add further memory types here, eg spi flash
    040bc                 | '..................................................................................................
    040bc                 | 
    040bc                 | lut_code
    040bc                 | '..................................................................................................
    040bc                 |                             org     $200
    040bc 080             | savestate
    040bc 080 B3 F1 03 F1 |                             add     ptra, limit             'increase hub address
    040c0 081 04 66 47 F0 |                             shr     limit, #4
    040c4 082 B3 59 03 F1 |                             add     addrhi, limit           'increase addrhi by limit/16
    040c8 083 10 62 8F F9 |                             altd    id, #savehubaddr        'preserve read state for next time
    
  • Here's something that I think should maybe work... I think this works in Spin...

    Want to enumerate a list of colors like this:
    CON 'colors
    #0,Black, Maroon, Green, Olive, Navy, Purple, Teal, Silver
    

    But, I get an "warning" ignoring unknow preprocessor directive 0 message.
    Guessing that means it is not working...

    Way around this?
  • Rayman wrote: »
    ...
    Way around this?

    Insert some spaces before the #0.
  • Tried that... Gives a different syntax error
  • try
    CON 'colors
    unused,Black, Maroon, Green, Olive, Navy, Purple, Teal, Silver
    

    Mike
  • Rayman wrote: »
    Tried that... Gives a different syntax error

    Inserting spaces before the "#0" works for me; in fact one of the standard tests that I run before releasing fastspin is this code:
    con
      TEST_ROW_RESULTS = 5
      TEST_ROW_BUTTON = TEST_ROW_RESULTS + TEST_LED
      #0,TEST_ELECTRICAL,TEST_LIGHT,TEST_LED
      
    dat
      long TEST_ROW_BUTTON '' should be 7
    

    Also, if you don't put the space before the "#" then you'll get a warning but everything should still work. The preprocessor will ignore the "#0" and pass it through to the compiler, which will compile it normally.
  • @rogloh : Thanks for the bug report about LUT addresses in listings. I'll look into it.
  • Ok, inserted the spaces does actually make it work, although it gives a warning message.
  • RaymanRayman Posts: 10,424
    edited 2020-02-15 - 21:34:18
    Actually, it gives an error message
    Never mind, seems I can't have this on multiple lines by ending line with a comma

    I thought I could do this:
    CON 'colors
    
      #0, Black, Maroon, Green, Olive, Navy, Purple, Teal, Silver, Grey, Red, Lime, Yellow, Blue, Fuchsia, Aqua, White, Grey0, 
      NavyBlue, DarkBlue, Blue3, Blue3, Blue1, DarkGreen, DeepSkyBlue4, DeepSkyBlue4, DeepSkyBlue4, DodgerBlue3, DodgerBlue2, 
      Green4, SpringGreen4, Turquoise4, DeepSkyBlue3, DeepSkyBlue3, DodgerBlue1, Green3, SpringGreen3, DarkCyan, LightSeaGreen, 
      DeepSkyBlue2, DeepSkyBlue1, Green3, SpringGreen3, SpringGreen2, Cyan3, DarkTurquoise, Turquoise2, Green1, SpringGreen2, 
      SpringGreen1, MediumSpringGreen, Cyan2, Cyan1, DarkRed, DeepPink4, Purple4, Purple4, Purple3, BlueViolet, Orange4, Grey37, 
      MediumPurple4, SlateBlue3, SlateBlue3, RoyalBlue1, Chartreuse4, DarkSeaGreen4, PaleTurquoise4, SteelBlue, SteelBlue3, 
      CornflowerBlue, Chartreuse3, DarkSeaGreen4, CadetBlue, CadetBlue, SkyBlue3, SteelBlue1, Chartreuse3, PaleGreen3, SeaGreen3, 
      Aquamarine3, MediumTurquoise, SteelBlue1, Chartreuse2, SeaGreen2, SeaGreen1, SeaGreen1, Aquamarine1, DarkSlateGray2, DarkRed, 
      DeepPink4, DarkMagenta, DarkMagenta, DarkViolet, Purple, Orange4, LightPink4, Plum4, MediumPurple3, MediumPurple3, SlateBlue1, 
      Yellow4, Wheat4, Grey53, LightSlateGrey, MediumPurple, LightSlateBlue, Yellow4, DarkOliveGreen3, DarkSeaGreen, LightSkyBlue3, 
      LightSkyBlue3, SkyBlue2, Chartreuse2, DarkOliveGreen3, PaleGreen3, DarkSeaGreen3, DarkSlateGray3, SkyBlue1, Chartreuse1, 
      LightGreen, LightGreen, PaleGreen1, Aquamarine1, DarkSlateGray1, Red3, DeepPink4, MediumVioletRed, Magenta3, DarkViolet, 
      Purple, DarkOrange3, IndianRed, HotPink3, MediumOrchid3, MediumOrchid, MediumPurple2, DarkGoldenrod, LightSalmon3, RosyBrown, 
      Grey63, MediumPurple2, MediumPurple1, Gold3, DarkKhaki, NavajoWhite3, Grey69, LightSteelBlue3, LightSteelBlue, Yellow3, 
      DarkOliveGreen3, DarkSeaGreen3, DarkSeaGreen2, LightCyan3, LightSkyBlue1, GreenYellow, DarkOliveGreen2, PaleGreen1, DarkSeaGreen2, 
      DarkSeaGreen1, PaleTurquoise1, Red3, DeepPink3, DeepPink3, Magenta3, Magenta3, Magenta2, DarkOrange3, IndianRed, HotPink3, HotPink2, 
      Orchid, MediumOrchid1, Orange3, LightSalmon3, LightPink3, Pink3, Plum3, Violet, Gold3, LightGoldenrod3, Tan, MistyRose3, Thistle3, 
      Plum2, Yellow3, Khaki3, LightGoldenrod2, LightYellow3, Grey84, LightSteelBlue1, Yellow2, DarkOliveGreen1, DarkOliveGreen1, DarkSeaGreen1, 
      Honeydew2, LightCyan1, Red1, DeepPink2, DeepPink1, DeepPink1, Magenta2, Magenta1, OrangeRed1, IndianRed1, IndianRed1, HotPink, HotPink, 
      MediumOrchid1, DarkOrange, Salmon1, LightCoral, PaleVioletRed1, Orchid2, Orchid1, Orange1, SandyBrown, LightSalmon1, LightPink1, Pink1, 
      Plum1, Gold1, LightGoldenrod2, LightGoldenrod2, NavajoWhite1, MistyRose1, Thistle1, Yellow1, LightGoldenrod1, Khaki1, Wheat1, Cornsilk1, 
      Grey100, Grey3, Grey7, Grey11, Grey15, Grey19, Grey23, Grey27, Grey30, Grey35, Grey39, Grey42, Grey46, Grey50, Grey54, Grey58, Grey62, 
      Grey66, Grey70, Grey74, Grey78, Grey82, Grey85, Grey89, Grey93
    

    But, I guess it was just a warning when it was all on one line...
  • Shoot, never mind. I just noticed that too many of these colors have the same name... That's too much work...

    I'll just keep this:
      #0,Black, Maroon, Green, Olive, Navy, Purple, Teal, Silver, Grey, Red, Lime, Yellow, Blue, Fuchsia, Aqua, White
    

    It compiles without error or warning... Thanks.
  • You can be evil and do multi-line with brackets { }:
    CON
      #0, Black, Maroon, Green, Olive, Navy, Purple, Teal, Silver, Grey, Red, Lime, Yellow, Blue, Fuchsia, {
      }Aqua, White, Grey0, NavyBlue, DarkBlue, Blue3, Blue1, DarkGreen, DeepSkyBlue4, DodgerBlue3, DodgerBlue2, {
      }Green4, SpringGreen4, Turquoise4, DeepSkyBlue3, DodgerBlue1, Green3, SpringGreen3, DarkCyan, LightSeaGreen
    
  • Thanks, I might need that...
  • Eric,
    Cannot find the posts (and replies) where I said fastspin.zip and flexgui-master.zip are inconsistent so here goes again...

    Previously I have downloaded flexgui.zip (eg 4.1.2) which contains
    flexgui.exe
    \bin\fastspin.exe
    \bin\loadp2.exe

    When I went to download v4.1.3
    flexgui.zip now appears to be flexgui-master.zip but it does not contain the \bin\ files
    fastspin.zip does not contain the \bin\ directory with loadp2.exe but fastspin.exe is in the root.

    Please, could you make it so that each release there is a consistent download where all files are contained (flexgui.exe, fastspin.exe and loadp2.exe), even if no changes have been done for some of the files. This just makes it easy for everyone. You've done a great job, tho' this would make it easy for all of us thanks :)


  • I just downloaded 4.1.3 from here: https://github.com/totalspectrum/flexgui/releases
    The flexgui.zip downloaded from there contained all the proper files including the bin folder with all the exe files. Just the same as previous releases.

  • This is really weird. That is the link I followed (its on the first post in this thread).

    When I did it the other day, and confirmed earlier this afternoon, under the Flexgui version 4.1.3 heading there was a link to download flexgui (within the text) and there was no flexgui.zip under the Assets 3 heading below. IIRC there was a fastspin.exe download (which I had downloaded) under the Assets 3 heading. Thinks there may have been more options. Anyway, that link (which is not there now) lead to a page in git where I could download flexgui-master.zip (which I also downloaded)

    Now I find the same page is different (basically same text from what I recall but missing the link described above), and flexgui.zip is available to download and I just did that and it does indeed have the bin subdirectory. But I've just looked and the bin is empty :(
    FWIW in the root is flexgui.exe and README.md, and directories bin, board, doc, flexgui, include, samples, src. Of these, bin, board with subdirectory sdcard, and flexgui are all empty. fastspin.exe and loadp2.exe are no where to be found :(

    What's happening???
  • Is windows blocking a file?
  • Cluso99Cluso99 Posts: 15,811
    edited 2020-02-16 - 09:15:54
    Don’t think so as the website was showing something else. There should be other files in the bin directory IIRC (not at computer atm).
    Giving up for tonight.

    Previous releases worked fine once I understood what zip file i needed. I have them all in their own directories.
  • I wonder if the other exe files are not signed, but flexgui.exe is? If so then perhaps your antivirus software is quarantining the exe's or even just deleting them?
    Others were having that issue in the past with the main exe, but ersmith got support to sign the exe and that helped then, maybe?

  • I would expect to get a warning. Sometimes i get a warning when i download a zip file, but ive never seen them not being shown for download. At home i just use MS Defender but im super careful not to open unknown emails or click unknown links. At work we use Norton professional or similar.
  • Cluso99Cluso99 Posts: 15,811
    edited 2020-02-16 - 09:57:07
    OK, just retried this and here is what is happening...

    The link on the first post in this thread has a link to spin2cpp

    https://github.com/totalspectrum/spin2cpp/releases
    This has the fastspin.zip download

    and a link to flexgui
    https://github.com/totalspectrum/flexgui/releases
    This has the flexgui.zip download

    Now, if you follow the first link above (has the fastspin.zip file) there is a link
    https://github.com/totalspectrum/flexgui
    that goes to a page that is different to the second link above and has a large list of files. Here there is a button to clone or download a zip file
    This downloads the file flexgui-master.zip

    So this explains the different pages/links that i've seen.

    I have just downloaded flexgui.zip again, and this time I get a size of 8,996KB wheras the flexgui.zip I downloaded earlier (an hour ago) has 4,948KB. The larger flexgui.zip file contains the \bin\ subdirectory with the expected files :)
    But clearly something is wrong :(

    Anyway I have the 4.1.3 files now. Perhaps Eric can shed some light on this.
  • Cluso99 wrote: »
    Now, if you follow the first link above (has the fastspin.zip file) there is a link
    https://github.com/totalspectrum/flexgui
    that goes to a page that is different to the second link above and has a large list of files. Here there is a button to clone or download a zip file
    This downloads the file flexgui-master.zip

    That's the source code, and that's almost certainly what you downloaded. Which is fine, if you want to build from source, but binaries are not included.

    The default github page is always the source, that's just the way github works. To get to binary releases you have to click on the "Releases" button (which is a bit tricky to find on the page) or just start directly with the release URL https://github.com/totalspectrum/flexgui/releases
  • I just tried using "numbers.spin", but it doesn't appear to work...

    Tried this:
    OBJ
        ...
        num:  "numbers"
        
        
    PUB Main()|i,j,k,x,y
       ... 
       'Numbers for turning numbers into strings
        num.init
        j:=23432
        i:=num#DEC
        i+=(10+1)<<5'(digits+1)<<5
        vga.print_string(num.ToStr(j,i))
    

    Seems to return just a space character.
    Is there some other way to in Fastspin to turn a number into a string?
    Or, any idea why "numbers.spin" doesn't work? Should it?
  • I noticed something that now strikes me a bit strange...
    DAT
                  long      sTitleForm1    '6 title string
          
    
    DAT ''Form1 String Resources
    sTitleForm1   byte  "Test Form",0
    

    The long "sTitleForm1" becomes a pointer to the string of the same name.
    But, I think in Spin and maybe PNut that it should be:
                  long      @sTitleForm1    '6 title string
    

    With the "@" symbol in front.
  • Hey @ersmith
    Any ETA on when this error will be resolved? "error: Symbol _pinr is of a type not handled by PASM output yet"

    I have ported simplei2c over to FlexC, and trying to make it work on P2 & P1. Using the _pin*()/_dir*() stuff since that will work on all 64 pins for P2 and still work for P1, except _pinr() isn't implemented yet for P1 compiles. :(

    I guess I can work around it for now with an #ifdef __propeller2__, but it would be cleaner if _pinr() for P1 worked.
  • Roy ElthamRoy Eltham Posts: 2,788
    edited 2020-02-18 - 04:49:43
    ersmith,
    I did the work around for now, and submitted a pull request.
    I think I got it right, let me know if I need to do it another way.

    FYI, I tested it on P1 with code to read/write the eeprom, and on P1 & P2 (p2es rev b chip) with code to read the parallax HMC5883L compass module.
  • Thanks Roy. The _pinr was a silly oversight, and the I2C code you wrote looks nice. I came down with the flu and have been flat on my back for the last few days, so I have a lot of work to catch up. Before that happened I started overhauling the file I/O code and my local repository is a horrible mess :(.
  • @Rayman: Not sure why numbers.spin would have problems. It was working at one point, I think. Could you send me the exact version you're using and some kind of repro case? Maybe we have a different "numbers.spin" file.
  • ersmith: Glad you're back! Was wondering why you stopped posting...

    Here's an example that I think should work, but doesn't.
    I think I'm using it correctly...
  • ersmith,
    Just to be clear, the i2c code wasn't originally written by me, I just modified the existing Simple Libraries version of it to work in FlexC and for P2 as well as P1.

    I saw that you had a lot of stuff in the works in the spin2cpp repository, particularly a bunch of C library additions. Hopefully, as I get more familiar with the codebase, I can help with some of that too.
Sign In or Register to comment.