Pnut/PropTool 2.9.2 Bug? (POLXY)
in Propeller 2
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.)
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.
Right, got it.![:) :)](https://forums.parallax.com/resources/emoji/smile.png)
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.
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:
...needs to become...
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!
Will this also fix the repeat control value issue?
Yes.
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?
A couple of years back there was a request to change it. Chip has just changed it back to original.
@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 theREPEAT i from 0 to some_number-1
, to get the total number of executions.Thanks!