Shop OBEX P1 Docs P2 Docs Learn Events
Need help adding P2 support to PropBASIC — Parallax Forums

Need help adding P2 support to PropBASIC

BeanBean Posts: 8,129
edited 2020-03-16 15:29 in Propeller 2
Hey everyone, I finally have some time to start adding Propeller 2 support to PropBASIC.
This is going to be a huge undertaken because I haven't been able to follow the P2 development.

I will have many questions as I proceed with this, so please be patient with me.

My first problem is how do I convert WAITPE and WAITPNE commands ?

Also, how do I set RCFAST clock mode ? _ClkMode = RCFAST gives "RCFAST" is "Undefined symbol" ?

Thanks, Bean

Comments

  • cgraceycgracey Posts: 14,155
    edited 2020-03-16 18:34
    Bean, look at the documentation in the "Latest PNut Version" thread. It's all in there.
  • BeanBean Posts: 8,129
    Okay, Thanks Chip. I'll look at it.

    Bean
  • Hi Bean
    Sorry I cant help its all smoke and mirrors to me- even the 'brains' on the forum seem to be scratching their heads. But the news that you are considering producing a prop2basic is really exciting and I cant wait to help testing it out.
    Dave
  • cgraceycgracey Posts: 14,155
    tritonium wrote: »
    Hi Bean
    Sorry I cant help its all smoke and mirrors to me- even the 'brains' on the forum seem to be scratching their heads. But the news that you are considering producing a prop2basic is really exciting and I cant wait to help testing it out.
    Dave

    I think the biggest mysteries surround the inner workings of the HyperRAM chips.
  • Have you tried FlexBasic for the P2? It may be able to do much of what you want.
  • RaymanRayman Posts: 14,646
    ersmith: You're back! Was getting worried about you there...
  • RaymanRayman Posts: 14,646
    FWIW: Spinedit supports FlexBasic: https://forums.parallax.com/discussion/169259/spinedit-editor-for-spin-spin2-and-fastbasic/p1

    I'm sure I could add PropBasic too, if you go that route...
  • RaymanRayman Posts: 14,646
    edited 2020-03-17 00:14
    Bean: be sure to visit propeller.parallax.com for instruction spreadsheet and documentation
  • My first problem is how do I convert WAITPE and WAITPNE commands ?
    I solved my problem another way because it was just a single bit, but the SETPAT and WAITPAT instructions may be what you need.
  • BeanBean Posts: 8,129
    Jon, Thanks. Yes that is what I was looking for.

    Bean
  • BeanBean Posts: 8,129
    edited 2020-03-17 13:37
    This line is giving me the error "Expected end of line" at the second comma or the "and" instruction.
                      and           p_LED57,inb WZ, NR           '    p_LED56 = p_LED57
                      muxnz         outb,p_LED56                
    
    

    p_LED57 and p_LED56 are mask values with only 1 bit set.

    I am wanting to set pin p_LED56 to the same state as pin p_LED57.

    Bean
  • The NR bit got axed, TEST is now a separate instruction instead of an alias for AND NR
  • cgraceycgracey Posts: 14,155
    Bean wrote: »
    This line is giving me the error "Expected end of line" at the second comma or the "and" instruction.
                      and           p_LED57,inb WZ, NR           '    p_LED56 = p_LED57
                      muxnz         outb,p_LED56                
    
    

    p_LED57 and p_LED56 are mask values with only 1 bit set.

    I am wanting to set pin p_LED56 to the same state as pin p_LED57.

    Bean

    Like this:
           test    inb,p_LED57     wz    '    p_LED56 = p_LED57
           muxnz   outb,p_LED56
    
    ...or...
    
           testp   #57             wz
           drvz    #56
    
  • BeanBean Posts: 8,129
    Ok. Thanks.

    I am first just trying to get it to work the easiest way possible.
    Later I will go back and optimize for the P2 instructions.

    Bean
  • BeanBean Posts: 8,129
    Okay, how about this one...
      subs count,#1  WC, NR  ' Set C if count is zero
    

    Bean
  • Bean wrote: »
    Okay, how about this one...
      subs count,#1  WC, NR  ' Set C if count is zero
    

    Bean

    It appears there are a few options, but
    CMPS count, #1 WC 'Set C if count is less than one
    
    is probably the simplest, but also sets the carry if count was already negative.

    Out of interest, should count ever intentionally be negative, and if so should it be handled differently than zero?
  • Wuerfel_21Wuerfel_21 Posts: 5,053
    edited 2020-03-17 22:50
    Wait, SUBS doesn't even work that way. SUBS sets carry on signed underflow ($8000_0000 minus 1) (unless you're using the top bit of count for something?)
    (on P1, CMP is the same as SUB NR, but CMPS is NOT SUBS NR)

    To actually set C if x is zero, use CMP x,#1 WC (on both P1 and P2)
  • BeanBean Posts: 8,129
    Duh, yeah I forgot about cmps. That works.

    But now I ran into a real problem...
    PNut does not seem to support the @@@ operator. Is there any assembler for the P2 that supports @@@ ?

    Bean
  • Wuerfel_21 wrote: »
    Wait, SUBS doesn't even work that way. SUBS sets carry on signed underflow ($8000_0000 minus 1) (unless you're using the top bit of count for something?)
    (on P1, CMP is the same as SUB NR, but CMPS is NOT SUBS NR)

    To actually set C if x is zero, use CMP x,#1 WC (on both P1 and P2)

    Agreed. It makes one wonder whether the code or the comment is correct. More context (and maybe more coffee before posting ;-) is needed.
  • cgraceycgracey Posts: 14,155
    Bean wrote: »
    Duh, yeah I forgot about cmps. That works.

    But now I ran into a real problem...
    PNut does not seem to support the @@@ operator. Is there any assembler for the P2 that supports @@@ ?

    Bean

    Bean, can you show an example of your code that uses @@@. There may be a simple work-around.
  • Bean wrote: »
    Duh, yeah I forgot about cmps. That works.

    But now I ran into a real problem...
    PNut does not seem to support the @@@ operator. Is there any assembler for the P2 that supports @@@ ?

    Bean
    I'm pretty sure that FastSpin supports @@@.

  • BeanBean Posts: 8,129
    To wait for a pin to go high on the P1 I would do:
    waitpeq pinmask,pinmask
    

    On the P2 is there a shorter method than
    modcz 0,1
    setpat pinmask,pinmask
    waitpat
    

    Thanks, Bean.
  • Bean wrote: »
    On the P2 is there a shorter method than
    modcz 0,1
    setpat pinmask,pinmask
    waitpat
    

    I think, no. This isn't even enough. There is an issue that waitpat will not stop waiting if the condition (pattern match) is already met before waitpat is started. So you have to check the condition and skip the waitpat if it's true. :neutral: This is one of the few things that were solved better on the P1.

  • BeanBean Posts: 8,129
    Okay, thanks. For now I guess I'll just use a test/jmp loop.

    Bean
  • JonnyMacJonnyMac Posts: 9,104
    edited 2020-03-18 16:24
    It you're only looking for a single pin to change, what about this?
                            testp   pin                     wc
            if_nc           jmp     $-1
    
    Simple, but perhaps not as fast as waitpat.
  • ersmith wrote: »
    Have you tried FlexBasic for the P2? It may be able to do much of what you want.

    Forgive me if I misunderstood but doesn't FlexBasic still need to perform GC?

    What I love about PropBasic is that it translates directly to PASM.
  • So if PropBasic translates directly to PASM, I don't think it needs @@@ for the P2. For pure P2 assembly the @ operator will give you the absolute hub address. I thinks it's only when you include assembly with Spin2 code that @ will give an object offset. I haven't written any Spin2 code using PNut, so I'm not sure about this. Can someone familiar with Spin2 using PNut confirm this?
  • FlexBasic translates directly to pasm too, and you can open the listing file in the gui.

    @Bean, fastspin does support @@@ and Ive used it in the past to compile propbasic code for p1, so it should work well for you as a p2 assembler. I would be grateful if you could give its basic dialect a try too, if only so that we could discuss ways of making p2 basics more compatible with each other. The gui for fastspin (FlexGui) is linked to in my sig, but the fastspin assembler/compiler can be used on its own without the gui.
Sign In or Register to comment.