Shop OBEX P1 Docs P2 Docs Learn Events
FemtoBASIC for P2 - Page 2 — Parallax Forums

FemtoBASIC for P2

24

Comments

  • Mike Green wrote: »
    Sorry, no. I found that while looking for various P2 resources. Here it is.
    Thanks! I get the same errors as you're seeing. I'm sure Eric will notice this thread and comment. I'm using this command line:
    fastspin -2b FemtoDongle2.spin
    
    I suspect -2 would work as well as -2b.

  • I'm using: fastspin -2b -O2 FemtoDongle2.spin
  • RaymanRayman Posts: 14,646
    Firstly, I'd rename the extension to .spin2

    I'll see if I can compile...
  • RaymanRayman Posts: 14,646
    Eeek.. I'm getting compile errors too...

    Need @ersmith to figure this one out. My guess is that it is something with abort. You have a gazillion in there....
  • Yeah, the expression parser is a recursive descent parser and can go way deep so I use abort statements to carry a string address to the outermost level to display an error message. Works great.
  • Rayman wrote: »
    Firstly, I'd rename the extension to .spin2

    I'll see if I can compile...
    Rayman wrote: »
    Firstly, I'd rename the extension to .spin2

    I'll see if I can compile...
    That was my first thought too but it is a Spin1 program so it should probably be just .spin.

  • Hi @"Mike Green" . Sorry for the trouble you ran into: fastspin got confused by statements like:
    ifnot massOpen
    
    where massOpen is defined with no body:
    pri massOpen
    
    pri massCreate
    
    
    I should have a fix soon, but for now if you add a "return 0" statement to those functions that'll work around the fastspin bug.

  • With Eric's fix it's starting to work. Here is the result of compiling:
    dbetz@Davids-Mac-mini-2 work % fastspin -2 FemtoDongle2.spin 
    Propeller Spin/PASM Compiler 'FastSpin' (c) 2011-2020 Total Spectrum Software Inc.
    Version 4.1.5-beta-3e1ccb6d Compiled on: Apr 15 2020
    FemtoDongle2.spin
    |-SmartSerial.spin
    FemtoDongle2.p2asm
    Done.
    Program size is 28704 bytes
    
    And here is my test run:
    dbetz@Davids-Mac-mini-2 work % loadp2 FemtoDongle2.binary -t
    ( Entering terminal mode.  Press Ctrl-] to exit. )
    FemtoDongle2 Version 1.001
    OK
    PRINT "Hello, world!"
    Hello, world!
    OK
    
    Unfortunately, the editor doesn't seem to work. It hangs after I type one line that starts with a line number.
  • @ersmith is -2 the same as -2b?
  • David Betz wrote: »
    @ersmith is -2 the same as -2b?

    Yes.
  • I've updated github to fix the problem with using empty functions in IF statements, and also another problem I discovered in the preprocessor's handling of end of file.
  • Thanks, David and Eric. I'll get back to it later today
  • RaymanRayman Posts: 14,646
    David Betz wrote: »
    That was my first thought too but it is a Spin1 program so it should probably be just .spin.

    Ok, I guess I assumed P2 since posted here...

    But, I think through the magic of FastSpin, the code should compile for both P1 and P2.
  • Rayman wrote: »
    David Betz wrote: »
    That was my first thought too but it is a Spin1 program so it should probably be just .spin.

    Ok, I guess I assumed P2 since posted here...

    But, I think through the magic of FastSpin, the code should compile for both P1 and P2.
    fastspin can compile Spin programs for either P1 or P2. It can also compile Spin2 programs for either processor. This is different from how Chip's compilers work where his Spin2 compiler can only target P2.

  • RaymanRayman Posts: 14,646
    I'm not sure Eric has implemented Spin2 (like Chip's yet) right? I think it's more or less Spin1 with some extra stuff for P2 at the moment...
  • Rayman wrote: »
    I'm not sure Eric has implemented Spin2 (like Chip's yet) right? I think it's more or less Spin1 with some extra stuff for P2 at the moment...
    I believe that you're correct that Eric hasn't implemented all of Spin2 yet. He's probably waiting for Chip to finalize his implementation of Spin2 before modifying fastspin.

  • RaymanRayman Posts: 14,646
    I'd actually like an option to keep P2 Fastspin as is and another option for Chip style P2...
  • Rayman wrote: »
    I'd actually like an option to keep P2 Fastspin as is and another option for Chip style P2...
    Ugh. Three different versions of Spin? I still think it's a mistake to have Spin2 be incompatible with the original Spin. Better would have been to extend the original Spin that could target both P1 and P2. Spin is an obscure enough language as it is without having several dialects of it.

  • Here's a minimally tested FemtoDongle2. I've been able to enter program lines, delete lines and run a simple FOR / PRINT program. I can't see why backspacing doesn't work properly ... it may have to do with the terminal program in FastSpin.
  • RaymanRayman Posts: 14,646
    You don't have to use the Fastspin terminal... I use Propeller Serial Terminal with it...
  • Mike Green wrote: »
    Here's a minimally tested FemtoDongle2. I've been able to enter program lines, delete lines and run a simple FOR / PRINT program. I can't see why backspacing doesn't work properly ... it may have to do with the terminal program in FastSpin.
    The DELETE key probably generates a DEL character rather than a backspace. I had to write my own line editor for my BASIC interpreter.

  • Here is a version of FemtoDongle2.spin that works with the loadp2 terminal. It treats _BS_ and _DEL_ as synonyms.
  • David BetzDavid Betz Posts: 14,516
    edited 2020-04-15 22:27
    I checked in my slightly modified version of FemtoBASIC here:

    https://github.com/dbetz/femtobasic

    The only thing I changed was adding DEL to delete a character. I've added a simple Makefile that will build and run it with FastSpin.

    Edit: I also added this link to the top post in case we continue this development effort to make easy for people to find the most recent code.

  • Any recommendations for SD card support for P2 in Spin? I suppose I could modify fsrw.spin or use the routines in the P2 debugger. Cluso99, did you ever convert the write routines to work on the P2?
  • Cluso99Cluso99 Posts: 18,069
    Mike,
    I have the SD card support for PASM done - it's just an extension to the ROM SD card boot support with some tweeks.
    I also have Kye's FATEngine spin code converted to compile in spin2 but this is untested.

    Unfortunately I'm stuck (and as frustrated as hell) as I cannot get my ROM Monitor working with spin2 so I am running blind. I just need to see what pnut is putting into hub and where so I can see why it's not working.

    If you are interested, I can post the various pieces of code.
  • Cluso99,
    Please post the SD card support for PASM. I'll see if I can get it to work with FemtoBasic. That would probably be the smallest package. Thanks. Mike
  • Cluso99Cluso99 Posts: 18,069
    Mike,
    Attached is the P2 PASM SD Driver code that resides in a separate cog. I believe it could also be placed in hub and run as hubexec. Please rename as .spin2

    You will note there is a debug routine which copies debug information into a hub buffer at $4000+. These are marked with a line of <<<<<. These can be commented out - there is just a few specific places in the code (_sendrecv) where the hub_log buffer gets filled (and reset) which you can comment out.

    I have also included Kye's FATEngine code which now compiles under spin2 - I have not done any testing of this!
  • Cluso99Cluso99 Posts: 18,069
    edited 2020-04-16 07:18
    And here is a version that runs in the one cog... (rename as .spin2)

    It uses the ROM Monitor to display checkpoints as the SD card is..
    Initialised
    CSD/CID is read
    Read a sector and display (on my SD card sector $4DC1)
    I then modify that sector - it's actually commented out
    Write a sector and display (sector $4DC1)
    Read back the sector and display
    I then fix the sector (note that I know what should be there ie I don't take it from the original read sector!)
    Write back the sector and display.

    This has lots of debug info the PST along the way. And at the end it calls the ROM Monitor so you are left in the monitor with the "*" prompt. Use "nnnn-<cr>" to display cog/lut/hub data.

    I use Eric's Fastspin and LoadP2 to run this from a Windows Command Prompt - it has an inbuilt terminal - Ctl-] returns to command mode from the terminal mode.
  • David BetzDavid Betz Posts: 14,516
    edited 2020-04-16 11:35
    Mike: I see you're now working on porting this to Spin2. Does that mean you won't be doing any more with the FastSpin version? It seems like FastSpin would be a better choice since it compiles to PASM and hence your BASIC interpreter would be a lot faster.
  • David,
    I plan to stick with FastSpin since it's multi-platform and I use a Mac normally. I can run PNut under Windows 10 using Parallels Desktop on the Mac, but it's awkward. I have an old Windows laptop too, but it's unreliable. I just wanted to see if I could move back and forth between FastSpin and PNut. At the moment, that doesn't seem to work.

    Cluso99,
    Thanks
Sign In or Register to comment.