Conversion P1 ~>= to P2
kg1
Posts: 164
in Propeller 2
How do I rewrite x ~>= 1 in P2 ?
Comments
I think the PNut download has a file called spin2_operators.txt in it -- I've attached for convenience. I made this cheat sheet for myself.
** --or-- **= Multiply and return upper 32 bits (signed); p 153
Is there anything equivalent in P2 ?
eg from P1 if z ** z > m converted to P2 ?
I'm using SCAS here because the P1 doesn't do unsigned multiplying or dividing.
I need to update my cheat sheet -- ** is not something I ever used.
On P2, SCA is equivalent to **. So "z ** z" would become "z SCA z".
Page 156 in P1 Manual: "When you need to perform further calculations with those byte-sized values, use the Sign-Extend 7 operator to convert the number into the proper 32-bit signed integer form. "
P2 Solution for Pre ~ ?
Spin1: Spin2: The parenthesis may not be needed, but I think they add clarity.
Keep in mind, too, that Chip is updating the initial online documentation -- you may want to bookmark this lin:
https://docs.google.com/document/d/16qVkmA6Co5fUNKJHF6pBfGfDupuRwDtf-wyieh_fbqw/edit
data := ~data ' extend sign
change to:
data := data <- 8 ' puts the 8MSB to the 8LSB
data := data SIGNX 7 ' extend sign
Compiles ok but not tested.
Thanks Jon.
BTW... ...translates to:
This thread is about converting someone else's code from P1 to P2. Thank you for your "Spin Operators" list which is most helpful. I believe this was prepared while converting your own code. With my work I have not used a list of known differences but have simply proceeded by Compile, find error, search for info in P1 Manual, search for info in Chips P2 documents, change syntax, save, compile etc on and on.
The assumptions are that chip's Pnut compiler is 100% perfect. Chip's documents are 100% complete. That if the code compiles it is 100% correct. Although I am always interested in improved code, for the moment I wish to convert from P1 to P2 in the shortest time possible and complete my document of the most used code differences.
Without your help I would be stuck. Many thanks for helping me.
The challenge of this moment is the jmpret. So I will continue searching for info. Hoping that I don't fall asleep sitting upright! Yes I am old...
Kevin.
Chip published the operators list. When I ran into a difference I went through it to make my cheat-sheet so that I could get a handle on what changed, and what's new. Most of my conversions go pretty smoothly now; I know what too look for and to remember the niggly things like () on functions without parameters, and explicitly naming return the return variable for methods that do return a value.
You shouldn't. As bugs are reported Chip is knocking them down. At the same time, he is fleshing out initial documentation. I don't know, but it's likely Jeff Martin will take Chip's documentation and humanize it in the form of a P2 manual (he did a nice job on the P1 manual).
The biggest change from P1 to P2 is on the PASM side. I think the P1 had about 60 instructions -- the P2 has over 350. There has been commentary on JMPRET by some of the advanced members. I've written one program that used it, and that had to do with a specialty UART which is no longer a problem with smart pins.
Remember, the P2 isn't officially released yet. We're all working with engineering samples. Parallax is letting us get a jump on others, and we can help Parallax by pointing out problem spots.