Host Engineering Forum
General Category => Do-more CPUs and Do-more Designer Software => Topic started by: RBPLC on October 27, 2019, 08:48:01 AM
-
Is there an equivalent command in Do-More to the CMPV command in Productivity Suite? This command basically performs: if x<y set c0=1 c1=0 c2=0, if x=y set c0=0 c1=1 c2=0, if x>y set c0=0 c1=0 c2=1. This would also be equivalent to CMP in Mitsubishi. I couldn't find an equivalent instruction in Do-More but assume is can be done with the MATH instruction possibly.
-
Oddly, I haven't missed this from the DirectLogic series. I prefer the direct comparison instructions >,<,= myself since they are all available in the Do-more vs just a subset in DL.
You might look at ALHILO and ALDEV, but neither is a direct replacement. You could do a MATH, but it wouldn't be straightforward either since it can only affect a single address. You could write an entire byte with 1,2,4 but lose the other bits being useful, unless you can further manipulate by masking or something.
-
This seems to work, but I wouldn't want to use it myself. It doesn't affect the states of C3-C7. You could use other bits by changing the 0xF8 (1111_1000) and the the result values 1, 2 & 4.
Still, it's a kludge. (And those == get me every, single time!)
-
There is something like that for Strings (STRCMP), since you can't do string comparisons in relational contacts.
I know some people like to do their ladder logic in MATH instructions:
MATH C0 "(X0 && X1) || !C2"
is the same as
.
X0 X1 C0
-] [---] [-+--------------(OUT)
|
C2 |
-]/[-------+
so I understand why some would like CMPV.
-
A call to a subroutine works as well. I'm recreating code where this was used multiple times.
-
A call to a subroutine works as well. I'm recreating code where this was used multiple times.
SWEET! If you utilize the CALL Input and Output parameters, Designer pre-fills the subroutine side INPUT and OUTPUT parameters, then you only have to fill in the client side of the IN and OUT.
I've attached a screen shot where I already have one CALL to the CMPV subroutine with one set of the two INPUT compare values and one set of the three OUTPUT bits, and then when I do another CALL to the CMPV subroutine, it asks me if I want to re-use the "function signature" where it fills in the SUBROUTINE side's input and output parameters (first screen attachment), and then I only have to fill in the CALLer side of the input and output parameters (second attachment).
-
For my usage, it looks like a call to a subroutine is the easiest and cleanest method.