Shop OBEX P1 Docs P2 Docs Learn Events
Pnut/PropTool 2.9.2 Bug? (POLXY) — Parallax Forums

Pnut/PropTool 2.9.2 Bug? (POLXY)

Today I installed the new version 2.9.2 of PropTool (over the 2.7.0) and the following code is giving a different result:

CON
  _clkfreq = 200_000_000

PUB main()|l, x, y, degree
  degree := $80000000 / 180 '32bit degree unit
  l := 1
  x,y := POLXY(l, 45*DEGREE)
  debug(udec(l), sdec(x), sdec(y))

debug shows:

Cog0  l = 1, x = 536_870_880, y = -1_073_741_823

Same code in 2.7.0 gave

Cog0  l = 1, x = 1, y = -1 

Comments

  • @cgracey and @"Jeff Martin" : this appears to be a regression in PNut. The output doesn't change even if the first parameter to POLXY is changed from 1 to 1024. PNut v35q gives sensible answers, but PNut v37 does not. Unfortunately those are the only PNut versions I have to try with.

    (flexspin agrees with the older PNut, for what it's worth.)

  • evanhevanh Posts: 15,697
    edited 2023-01-14 03:15

    Pnut v35v is good.
    Pnut v36 is good.

    There is a discrepancy with the sign of degree in Flexspin. Pnut treats $8000_0000 as a signed negative value while Flexspin is unsigned.

  • @evanh said:
    Pnut v35v is good.
    Pnut v36 is good.

    There is a discrepancy with the sign of degree in Flexspin. Pnut treats $8000_0000 as a signed negative value while Flexspin is unsigned.

    You should probably update your flexspin. From v5.9.22 on FlexSpin agrees with PNut that $8000_0000 is negative.

  • evanhevanh Posts: 15,697

    Right, got it. :)

  • I verified that the POLXY() routine was modified in the v37 Spin2 Compiler, but don't know why. I noted this and tagged Chip in the P2_PNut_Public repo to follow-up.

  • cgraceycgracey Posts: 14,134

    Sorry about this. I had forgotten to use a #immediate in the interpreter when comparing which instruction we were executing. I've fixed this, but need to push it.

    In the spin2_interpreter.spin2 file:

        cmp pa,bc_polxy
    

    ...needs to become...

        cmp pa,#bc_polxy
    

    That will fix this problem.

  • @cgracey said:
    Sorry about this. I had forgotten to use a #immediate in the interpreter when comparing which instruction we were executing. I've fixed this, but need to push it.

    In the spin2_interpreter.spin2 file:

      cmp pa,bc_polxy
    

    ...needs to become...

      cmp pa,#bc_polxy
    

    That will fix this problem.

    @cgracey and @"Jeff Martin"

    Is there an updated version of Propeller Tool that has this fix? Haven't been able to test the new features in my project because of this error.

  • cgraceycgracey Posts: 14,134

    @jrullan said:

    @cgracey said:
    Sorry about this. I had forgotten to use a #immediate in the interpreter when comparing which instruction we were executing. I've fixed this, but need to push it.

    In the spin2_interpreter.spin2 file:

        cmp pa,bc_polxy
    

    ...needs to become...

        cmp pa,#bc_polxy
    

    That will fix this problem.

    @cgracey and @"Jeff Martin"

    Is there an updated version of Propeller Tool that has this fix? Haven't been able to test the new features in my project because of this error.

    Sorry for the delay. I will get a new version out in the next day. It will be v38.

  • @cgracey said:

    @jrullan said:

    @cgracey said:
    Sorry about this. I had forgotten to use a #immediate in the interpreter when comparing which instruction we were executing. I've fixed this, but need to push it.

    In the spin2_interpreter.spin2 file:

      cmp pa,bc_polxy
    

    ...needs to become...

      cmp pa,#bc_polxy
    

    That will fix this problem.

    @cgracey and @"Jeff Martin"

    Is there an updated version of Propeller Tool that has this fix? Haven't been able to test the new features in my project because of this error.

    Sorry for the delay. I will get a new version out in the next day. It will be v38.

    No worries @cgracey I appreciate you taking the time to fix it. Thanks!

  • @cgracey said:

    @jrullan said:

    @cgracey said:
    Sorry about this. I had forgotten to use a #immediate in the interpreter when comparing which instruction we were executing. I've fixed this, but need to push it.

    In the spin2_interpreter.spin2 file:

      cmp pa,bc_polxy
    

    ...needs to become...

      cmp pa,#bc_polxy
    

    That will fix this problem.

    @cgracey and @"Jeff Martin"

    Is there an updated version of Propeller Tool that has this fix? Haven't been able to test the new features in my project because of this error.

    Sorry for the delay. I will get a new version out in the next day. It will be v38.

    Will this also fix the repeat control value issue?

  • cgraceycgracey Posts: 14,134

    @JonnyMac said:

    @cgracey said:

    @jrullan said:

    @cgracey said:
    Sorry about this. I had forgotten to use a #immediate in the interpreter when comparing which instruction we were executing. I've fixed this, but need to push it.

    In the spin2_interpreter.spin2 file:

        cmp pa,bc_polxy
    

    ...needs to become...

        cmp pa,#bc_polxy
    

    That will fix this problem.

    @cgracey and @"Jeff Martin"

    Is there an updated version of Propeller Tool that has this fix? Haven't been able to test the new features in my project because of this error.

    Sorry for the delay. I will get a new version out in the next day. It will be v38.

    Will this also fix the repeat control value issue?

    Yes.

  • cgraceycgracey Posts: 14,134
    edited 2023-02-03 21:08

    I posted a new version (v38) that fixes the POLXY/XYPOL/ROTXY bugs and leaves var = final +/- step after a REPEAT-var.

    https://forums.parallax.com/discussion/171196/pnut-spin2-latest-version-v38-bug-fixes-repeat-var-now-leaves-var-past-final-value/p1

  • @cgracey Could you explain a bit better the change to the REPEAT-var loop? I just noticed that my POLXY code does work as expected with v38, but now another portion of the code is broken and I strongly suspect that the culprit could be the REPEAT-var change, but I don't honestly understand what it is about. Could you provide an example to illustrate the change?

  • evanhevanh Posts: 15,697
    edited 2023-05-03 07:00

    @jrullan said:
    @cgracey Could you explain a bit better the change to the REPEAT-var loop? I just noticed that my POLXY code does work as expected with v38, but now another portion of the code is broken and I strongly suspect that the culprit could be the REPEAT-var change, but I don't honestly understand what it is about. Could you provide an example to illustrate the change?

    A couple of years back there was a request to change it. Chip has just changed it back to original.

    • The nominal and current way is to have the iteration variable at loop exit as a value one greater than the final used value. Ie: It uses a typical post-increment mechanic within the repeat loop.
    • The previous way, as per that request, was to have the completed loop exit value be same as the final used value within the loop.
  • @evanh

    Got it!

    Had to scrub through all my project files to find the three instances where I was adding 1 to the last value of i in the REPEAT i from 0 to some_number-1, to get the total number of executions.

    Thanks!

Sign In or Register to comment.