Advanced Function Instruction
7-108
FUN125 P
MCMP
MATRIX COMPARE
FUN125 P
MCMP
Md : Starting register of matrix a
Mb : Starting register of matrix b
L : Length of matrix (Ma, Mb)
Pr : Pointer register
Ma, Mb may combine with V, Z, P0~P9 to
serve indirect address application
WX WY WM WS TMR CTR HR IR OR SR ROR DR K XR
Range
Ope-
rand
WX0
∣
WX240
WY0
∣
WY240
WM0
∣
WM1896
WS0
∣
WS984
T0
∣
T255
C0
∣
C255
R0
∣
R3839
R3840
∣
R3903
R3904
∣
R3967
R3968
∣
R4167
R5000
∣
R8071
D0
∣
D4095
2
∣
256
V、Z
P0~P9
Ma ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○
Mb ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○
L ○ ○* ○ ○
Pr ○ ○ ○ ○ ○ ○ ○ ○* ○* ○
z When comparison control "EN" = 1 or "EN↑" ( P instruction) has a
transition from 0 to 1, then beginning from the top pair of bits (Ma
0
and Mb
0
) within the 2 matrixes Ma and Mb (when "FHD" = 1 or Pr
value is equal to 16L-1), or beginning from the next pair of bits (Mapr
+ 1 and Mbpr + 1) pointed by pointer Pr (when "FHD" = 0 and Pr
value is less than L-1), this instruction will compare and search for
pairs of bits with different value (when D/S = 1) or the same value
(when D/S = 0). Once match found, pointer Pr will point to the bit
number in the matrix met the search condition. The found objective
flag "FND" will be set to 1. When it has searched to the final pair of
bits in the matrix (Ma
16L-1
, Mb
16L-1
), this execution of the instruction
will finish, no matter it has found or not. If this happen then The
compare-to-end flag "END" will be set as 1, and the Pr value will set
to 16L-1 and the next time that this instruction is executed, Pr will
automatically return to the starting point of the matrix (Pr = 0) to begin
the comparison search.
L
Ma Mb
Mapr : Mbpr
Pr
z The range for the pointer value is 0 to 16L-1. The Pr value should not be changed by other instructions, as this will
affect the result of search. If the Pr value exceeds its range, then the pointer error flag "ERR" will be set to 1, and
this instruction will not be carried out.
X0
EN
END
L :
Pr :
FHD
D/S
ERR
R 20
FND
Ma :
Mb : R 10
R 0
125P.MCMP
5
z In the program at left, the "FHD" input is 0, so starting from a
position 1 greater than the pointer value at that time (marked
by *), the instruction will do a search for bits with different
status (because D/S = 1). When X0 has a transition from 0→
1 three times, the results are shown at right in the diagram
below.
P
4
R20
Ma15
↓
Ma *
Ma0
↓
Mb15
↓
Mb *
Mb0
↓
R0 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 R10 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1
R1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 R11 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
R2 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 R12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
R3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 R13 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
R4 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 R14 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
↑
Ma79
↑
Ma64
↑
Mb79
↑
Mb64
Before execution
Pr
FND END
c
R20 39
1 0
Pr
FND END
d
R20 79
0 1
Pr
FND END
e
R20 2
1 0
Execution result