Cluso,
In OpenSpin, I could have an option that would make it have whatever Spin2 features are reasonable on the P1 also. I can't change the built in rom image for the interpreter, but I can change things like keywords and instruction names for Spin/PASM quite easily. I can also add some new stuff, like the ? : operator, and other new things.
Of course, this would largely be up to Parallax/Chip to decide if they want it in the official version of OpenSpin. It would have to be an option, so that all the existing code would still work. It's a little iffy, since it means we'd now have a Spin 1.5 (or whatever). there would be confusion if PropTool didn't get updated to use OpenSpin also, so that it works in official tools.
That sounds like a great idea! Please use whatever influence you have with Parallax to modify PropTool to use OpenSpin. Also, be sure to create a command-line version that can replace Propellent without modifying any of its command-line options. If you then call it Propellent, other tools that rely upon it should work without modification.
Phil,
I have talked with Jeff Martin a couple times about putting OpenSpin into PropTool, and he seemed keen, it's just a matter of work on his part in PropTool now. However, he has been busy will lots of other things. I have made changes to OpenSpin so it will fit the proptool model better (like you give it a function to call when it wants to open/get a file, so it can deliver the data from a in memory tab/window or from disk. However, PropTool needs some other work to support new stuff like larger symbols, unused method elimination, and some other minor stuff. Ken/Jeff need to decide when that is a priority enough for them to do the work.
MINU, MAXU for unsigned version
MINS, MAXS for the signed version
So min and max are no longer reserved words, and the menmonics do not look like min(,) max(,) macros in C.
That would be fine, but PASM1 already defines MAXS (MAX Signed) the backwards way, so instantly there is conflict/confusion.
This fix requires a new name, that aligns with what the operator actually does.
Cryptic operators merely send users straight to the manual (unless there is also a comment explaining what the code does, in which case underlining why cryptic operators are not a good idea, if you need to write things twice: once for the machine, and again for the human reader)
Possible suggestions:
--P1-- -----new suggestions---------------------------------------------------
PASM2:
MAX MIN LOWER LOLIM LIMLO LIMITL LIMITLO LIMMIN CLAMPL CLAMPLE
MAXS MINS LOWERS LOLIMS LIMLOS LIMITLS LIMITLS LIMMINS CLAMPLS CLAMPLS
MIN MAX UPPER HILIM LIMHI LIMITH LIMITHI LIMMAX CLAMPU CLAMPGE
MINS MAXS UPPERS HILIMS LIMHIS LIMITHS LIMITHS LIMMAXS CLAMPUS CLAMPGS
SPIN2:
#> #> LOWERS LOLIMS LIMLOS LIMITLS LIMITLS LIMMINS CLAMPLS CLAMPLS
<# <# UPPERS HILIMS LIMHIS LIMITHS LIMITHS LIMMAXS CLAMPUS CLAMPGS
Once decided, can we back fix (the same into???) P1 PASM1 and SPIN1 ???
Yes, back fix into PASM1 and Spin1 should be simple to do, and deprecate the broken/confusion one.
I prefer names closest to what the operator actually does, so simple LO and HI are out, as are L and H,
Of the above, those with LE, GE meet what the operator does.
There is also the TRIMLE, TRIMGE, TRIMSLE, TRIMSGE I suggested above (Trim Greater or Equal, and Trim Less or Equal), but CLAMPLE, CLAMPGE is equally readable, if one character longer. CLIPLE, CLIPGE is another possible variant, synonym of Trim,Clamp
or LIMLE, LIMGE, LIMSLE, LIMSGE, adding limit to the list, but keeping the important LE (Less or Equal) , GE (Greater or Equal).
For sure they get not reversed, they work like always only that MIN & MAX get an U appended.
On mnemonic level there is no "traditional way" or do you know any other CPU that has such Instructions?
For me they align with what they actually do: Limiting to a min/max value.
You always can read it like that:
MINU = MIN Upside down
MAXS = MAX Swapped
Yes, but for SETMIN, I presume that is the lower bound, so you actually seek >= or GE which is the larger of a pair of values.
Now you have used a MIN root word, to select the largest of two values.
Compare that with the common WEB definitions of MIN ?
Better than SETMIN, would be SETGE, as Greater or Equal is the operation performed in setting the lower-boundary.
Yes, but for SETMIN, I presume that is the lower bound, so you actually seek >= or GE which is the larger of a pair of values.
Now you have used a MIN root word, to select the largest of two values.
Compare that with the common WEB definitions of MIN ?
Better than SETMIN, would be SETGE, as Greater or Equal is the operation performed in setting the lower-boundary.
SETGE
SETLE
SETSGE
SETSLE
Their meaning doesn't pop out, though they are not that bad.
But SETMIN would set D to a minimum value, in case it was under. I think anyone should understand that. I mean, what else could SETMIN be suspected of doing?
Yes, but for SETMIN, I presume that is the lower bound, so you actually seek >= or GE which is the larger of a pair of values.
Now you have used a MIN root word, to select the largest of two values.
Compare that with the common WEB definitions of MIN ?
Better than SETMIN, would be SETGE, as Greater or Equal is the operation performed in setting the lower-boundary.
SETGE
SETLE
SETSGE
SETSLE
Their meaning doesn't pop out, though they are not that bad.
But SETMIN would set D to a minimum value, in case it was under. I think anyone should understand that. I mean, what else could SETMIN be suspected of doing?
SETMIN would set D to a minimum value, in case it was under.
It does that by increasing the value of D, and the root semantics of SETMIN do not hint at any increase, rather the opposite
As an example of code
Thresh=20
eg SETMIN 10,Thresh
without reading a full manual, that includes in case it was under, which of two possible values of 10 & 20 would users expect the SETMIN exit value to be ? Minimum is the root.
compare with
SETGE 10,Thresh
SETGE 25,Thresh
is doing a Greater or Equal test, with a given Threshold. GE is == Not Less Than, so first exit value is 20, and second exit value is 25.
No extra text reading is required.
Cluso,
In OpenSpin, I could have an option that would make it have whatever Spin2 features are reasonable on the P1 also. I can't change the built in rom image for the interpreter, but I can change things like keywords and instruction names for Spin/PASM quite easily. I can also add some new stuff, like the ? : operator, and other new things.
Of course, this would largely be up to Parallax/Chip to decide if they want it in the official version of OpenSpin. It would have to be an option, so that all the existing code would still work. It's a little iffy, since it means we'd now have a Spin 1.5 (or whatever). there would be confusion if PropTool didn't get updated to use OpenSpin also, so that it works in official tools.
Yeah, you have to be careful when using the simple ones. For one thing, they reference one argument twice so any side effects would happen twice. I would only use those for very simple cases. In fact, since the simple macros require such care when used I'm surprised that math.h doesn't include the more complex ones. The ones I showed are easy enough to add yourself but adding the more complex and safer ones is quite cumbersome.
Q: in the forum:
I need the smaller of two values (b,c) in a variable a.
I tried a:=MIN(b,c) but it doesn't work.
A::
you have to use a:=MAX(b,c)
you have to use a:=LOLIM (b,c)
you have to use a:=LIMLO (b,c)
you have to use a:=LIMITL(b,c)
you have to use a:=LIMITLO(b,c)
you have to use a:=LIMMIN(b,c)
you have to use a:=CLAMPL(b,c)
you have to use a:=CLAMPLE (b,c)
Q: oh well
a := b <# c I have no idea what this means. My brain will not memorize this after 10 years of using it. So in every application of using it I put a comment so I can then copy and paste it to new uses.
FLE (force less-than or equal) FGE (force greater-than or equal) FLES, FGES (similarly for signed)
That's fine too, as it has the important LE GE in there.
The Force/Trim/Set/Clip/Clamp prefix is somewhat less important, and FLE will appeal to those who like very compact mnemonics.
Comments
In OpenSpin, I could have an option that would make it have whatever Spin2 features are reasonable on the P1 also. I can't change the built in rom image for the interpreter, but I can change things like keywords and instruction names for Spin/PASM quite easily. I can also add some new stuff, like the ? : operator, and other new things.
Of course, this would largely be up to Parallax/Chip to decide if they want it in the official version of OpenSpin. It would have to be an option, so that all the existing code would still work. It's a little iffy, since it means we'd now have a Spin 1.5 (or whatever). there would be confusion if PropTool didn't get updated to use OpenSpin also, so that it works in official tools.
That sounds like a great idea! Please use whatever influence you have with Parallax to modify PropTool to use OpenSpin. Also, be sure to create a command-line version that can replace Propellent without modifying any of its command-line options. If you then call it Propellent, other tools that rely upon it should work without modification.
Thanks,
-Phil
I have talked with Jeff Martin a couple times about putting OpenSpin into PropTool, and he seemed keen, it's just a matter of work on his part in PropTool now. However, he has been busy will lots of other things. I have made changes to OpenSpin so it will fit the proptool model better (like you give it a function to call when it wants to open/get a file, so it can deliver the data from a in memory tab/window or from disk. However, PropTool needs some other work to support new stuff like larger symbols, unused method elimination, and some other minor stuff. Ken/Jeff need to decide when that is a priority enough for them to do the work.
These are simple, not far from what we've got (except some feel they are backwards), and they free up the names MIN and MAX. I like these.
That would be fine, but PASM1 already defines MAXS (MAX Signed) the backwards way, so instantly there is conflict/confusion.
This fix requires a new name, that aligns with what the operator actually does.
Cryptic operators merely send users straight to the manual (unless there is also a comment explaining what the code does, in which case underlining why cryptic operators are not a good idea, if you need to write things twice: once for the machine, and again for the human reader)
I do too.
I prefer names closest to what the operator actually does, so simple LO and HI are out, as are L and H,
Of the above, those with LE, GE meet what the operator does.
There is also the TRIMLE, TRIMGE, TRIMSLE, TRIMSGE I suggested above (Trim Greater or Equal, and Trim Less or Equal), but CLAMPLE, CLAMPGE is equally readable, if one character longer.
CLIPLE, CLIPGE is another possible variant, synonym of Trim,Clamp
or LIMLE, LIMGE, LIMSLE, LIMSGE, adding limit to the list, but keeping the important LE (Less or Equal) , GE (Greater or Equal).
They are commonly defined as found on the web :
FreePascal
Min : Return smallest of two values.
Max : Return largest of two values
Python:
min(iterable[, key])
min(arg1, arg2, *args[, key])
Return the smallest item in an iterable or the smallest of two or more arguments.
max(iterable[, key])
max(arg1, arg2, *args[, key])
Return the largest item in an iterable or the largest of two or more arguments.
For sure they get not reversed, they work like always only that MIN & MAX get an U appended.
On mnemonic level there is no "traditional way" or do you know any other CPU that has such Instructions?
For me they align with what they actually do: Limiting to a min/max value.
You always can read it like that:
MINU = MIN Upside down
MAXS = MAX Swapped
I'm more comfortable with the MAXS,MAXU etc names.
Not so much pure ASM mnemonic, but certainly the MIN and MAX are very widely used, as found on the web above
Min : Return smallest of two values
Max : Return largest of two values
SETMIN
SETMAX
SETMINS
SETMAXS
Now you have used a MIN root word, to select the largest of two values.
Compare that with the common WEB definitions of MIN ?
Better than SETMIN, would be SETGE, as Greater or Equal is the operation performed in setting the lower-boundary.
SETGE
SETLE
SETSGE
SETSLE
Their meaning doesn't pop out, though they are not that bad.
But SETMIN would set D to a minimum value, in case it was under. I think anyone should understand that. I mean, what else could SETMIN be suspected of doing?
It does that by increasing the value of D, and the root semantics of SETMIN do not hint at any increase, rather the opposite
As an example of code
Thresh=20
eg SETMIN 10,Thresh
without reading a full manual, that includes in case it was under, which of two possible values of 10 & 20 would users expect the SETMIN exit value to be ? Minimum is the root.
compare with
SETGE 10,Thresh
SETGE 25,Thresh
is doing a Greater or Equal test, with a given Threshold. GE is == Not Less Than, so first exit value is 20, and second exit value is 25.
No extra text reading is required.
I need the smaller of two values (b,c) in a variable a.
I tried a:=MIN(b,c) but it doesn't work.
A::
you have to use a:=MAX(b,c)
you have to use a:=LOLIM (b,c)
you have to use a:=LIMLO (b,c)
you have to use a:=LIMITL(b,c)
you have to use a:=LIMITLO(b,c)
you have to use a:=LIMMIN(b,c)
you have to use a:=CLAMPL(b,c)
you have to use a:=CLAMPLE (b,c)
Q: oh well
Ahh! Functions! I'm glad to see we're finally on the same page.
a := b <# c
Seriously though, I agree with T Chap's suggestions: LIMHI LIMLO LIMSHI LIMSLO
X := LIM (expression) 0, 99
FLE (force less-than or equal)
FGE (force greater-than or equal)
FLES, FGES (similarly for signed)
-Phil
That's fine too, as it has the important LE GE in there.
The Force/Trim/Set/Clip/Clamp prefix is somewhat less important, and FLE will appeal to those who like very compact mnemonics.
http://www.sitecrafting.com/blog/modulus-remainder/
-Phil
-Phil