Well, yes, signed can show variances, and what is actually done 'in the wild' seems somewhat loose (as in your link)
There is also this, for FreePascal "Mod (modulus) divides two numbers and returns only the remainder. For instance, the expression "a:= 13 mod 4;" would evaluate to 1 (a=1), while "b := 12 mod 4;" would evaluate to 0 (b=0).
From the language reference:
"The sign of the result of a Mod operator is the same as the sign of the left side operand of the Mod operator. In fact, the Mod operator is equivalent to the following operation :"
I mod J = I - (I div J) * J
For example "c:= -13 mod 4;" results in c = -1 and "c:= 10 mod -3;" results in c = 1.
This is also what most other languages like C++ and Java do
From version 3.1.1 FreePascal also supports the mod operator for floating point values when you include the math unit.
"
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?
@Chip,
with SET I have the perception that I am preparing (parametrizing) the environment for an other instruction.
I suppose someone could think that !< means >=. Kind of like !=. Too bad we have to resort to a NOT (!) character when all we really need is some kind of verb and a > or <. If there was something that meant the opposite of !, we could use it with the opposite >, <.
I think !< and !> make some immediate sense to the reader, though. #> and <# looked quite ambiguous.
Is that correct? That syntax is so simple and nice! We still need to decide on the PASM instructions.
some P1 code like this (from earlier) should ideally be simple-translatable to P2....
Elev := 1000 #> Elev <# 2000
can be
Elev := 1000 FGE Elev FLE 2000
or
Elev := Elev FGE 1000 FLE 2000
all are bound 1000..Elev..2000 (which is another syntax candidate )
x := x !< 5 !> 10
simple swap gives
x := 5 !< x !> 10
is this last one still 5..10 ?
FGE allows operand reversal, but does !< ?
I think it needs to become instead
x := 5 !> x !> 10
I think !< and !> make some immediate sense to the reader, though. #> and <# looked quite ambiguous.
#> and #< have no obvious decode, you have to go to the manual.
!< are more decodable, but it saysnot-less-than, which I think now makes operand order matter to the reader.
Actual field Spin usage seems to be a mix of both ways above (ie order agnostic) ?
Err, has everyone fully grasped this new !< !> syntax now imposes restrictions on the operator order ?
That restriction was not there on the old syntax.
If you say 'Hey, let's allow either order', in one case the opcode does not do what it literally says.
Which repeats the problem of backwards MIN, where what happens is not what the code says..
Err, has everyone fully grasped this new !< !> syntax now imposes restrictions on the operator order ?
That restriction was not there on the old syntax.
If you say 'Hey, let's allow either order', in one case the opcode does not do what it literally says.
Which repeats the problem of backwards MIN, where what happens is not what the code says..
Err, has everyone fully grasped this new !< !> syntax now imposes restrictions on the operator order ?
That restriction was not there on the old syntax.
If you say 'Hey, let's allow either order', in one case the opcode does not do what it literally says.
Which repeats the problem of backwards MIN, where what happens is not what the code says..
Please explain?
Already did above...
This is OK
Elev := 1000 #> Elev <# 2000
Which is equivalent to
Elev := 1000 FGE Elev FLE 2000
or, this can be re-ordered as
Elev := Elev FGE 1000 FLE 2000
all are bound 1000..Elev..2000 (which is another syntax candidate )
This is ok
x := x !< 5 !> 10
simple order swap gives
x := 5 !< x !> 10
but what does that now say ? 5 is NOT less Than X, which means 5 is >= X, and X=1 will output 1.
It is ok to re-code like this
x := 5 !> x !> 10
.. but here the operator flips when the order flips, which the old opcode did not require (nor does FGE).
Comments
Why not something that actually makes sense at quick glance
Well, yes, signed can show variances, and what is actually done 'in the wild' seems somewhat loose (as in your link)
There is also this, for FreePascal
"Mod (modulus) divides two numbers and returns only the remainder. For instance, the expression "a:= 13 mod 4;" would evaluate to 1 (a=1), while "b := 12 mod 4;" would evaluate to 0 (b=0).
From the language reference:
"The sign of the result of a Mod operator is the same as the sign of the left side operand of the Mod operator. In fact, the Mod operator is equivalent to the following operation :"
I mod J = I - (I div J) * J
For example "c:= -13 mod 4;" results in c = -1 and "c:= 10 mod -3;" results in c = 1.
This is also what most other languages like C++ and Java do
From version 3.1.1 FreePascal also supports the mod operator for floating point values when you include the math unit.
"
with SET I have the perception that I am preparing (parametrizing) the environment for an other instruction.
LIMGE/LE/SGE/SLE is more clear to me.
if you dislike LIM also CLIP/CLAMP is fine.
I like these, too, and they cover both signed and unsigned. Now, does FLE replace MIN or MAX? Just kidding about that part.
MIN becomes FGE
MAX becomes FLE
MINS becomes FGES
MAXS becomes FLES
#> is really FGES (FGES would be an ugly spin operator)
<# is really FLES (FLES would be an ugly spin operator)
One other thing is that GE and LE are nomenclature used on signed comparisons. Unsigned often uses AE and BE, right? What about:
MIN becomes FAE
MAX becomes FBE
MINS becomes FGE
MAXS becomes FLE
We can avoid using 4-letter words, then.
-Phil
The only thing I can think of that would make sense, at first glace, for a Spin operator would be:
x AT_LEAST 5 AT_MOST 10
but you could do this in PASM
MIN becomes FGEU
MAX becomes FLEU
MINS becomes FGE
MAXS becomes FLE
(ie make signed the default)
and now FGE, FLE can become (less ugly) aliases to the spin signed operators
what about the clarity of these ?
or:
I could live with that, or perhaps better: x !< 5 !> 10. Still like <# and #> better.
-Phil
I think this looks great.
Andy
Okay. This will be the Spin syntax, then:
#> becomes !<
<# becomes !>
Is that correct? That syntax is so simple and nice! We still need to decide on the PASM instructions.
I think !< and !> make some immediate sense to the reader, though. #> and <# looked quite ambiguous.
if !< means "clamp to" ("lower limit is") a given number, than the result will be => of the specified number
some P1 code like this (from earlier) should ideally be simple-translatable to P2....
Elev := 1000 #> Elev <# 2000
can be
Elev := 1000 FGE Elev FLE 2000
or
Elev := Elev FGE 1000 FLE 2000
all are bound 1000..Elev..2000 (which is another syntax candidate )
x := x !< 5 !> 10
simple swap gives
x := 5 !< x !> 10
is this last one still 5..10 ?
FGE allows operand reversal, but does !< ?
I think it needs to become instead
x := 5 !> x !> 10
For me MIN,MAX work a bit like CMPSUB , only that it does not Subtract but Move.
So maybe: Just brainstorming...
CMPFLT, CMPSFLT, CMPFGT, CMPSFGT are alternatives (F = Force as Phil suggested)
!< are more decodable, but it says not-less-than, which I think now makes operand order matter to the reader.
Actual field Spin usage seems to be a mix of both ways above (ie order agnostic) ?
Much better than#
+1
Excellent. (I was going to put Excellent! but that could be misinterpreted;) )
NOTLT D,#S
NOTGT D,#S
NOTLTS D,#S
NOTGTS D,#S
Otherwise FLE, FGE, FLES, FGES are fine.
That restriction was not there on the old syntax.
If you say 'Hey, let's allow either order', in one case the opcode does not do what it literally says.
Which repeats the problem of backwards MIN, where what happens is not what the code says..
This is OK
Elev := 1000 #> Elev <# 2000
Which is equivalent to
Elev := 1000 FGE Elev FLE 2000
or, this can be re-ordered as
Elev := Elev FGE 1000 FLE 2000
all are bound 1000..Elev..2000 (which is another syntax candidate )
This is ok
x := x !< 5 !> 10
simple order swap gives
x := 5 !< x !> 10
but what does that now say ? 5 is NOT less Than X, which means 5 is >= X, and X=1 will output 1.
It is ok to re-code like this
x := 5 !> x !> 10
.. but here the operator flips when the order flips, which the old opcode did not require (nor does FGE).