Advanced Function Instruction
7-89
FUN105
D
P
R-T_S
REGISTER TO TABLE SEARCH
FUN105
D
P
R-T_S
Rs : Data to search, It can be a constant
or a register
Ts : Starting register of table being
searched
L : Label length
Pr : Pointer of table
Rs, Ts 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
16/32-bit
+/- number
V
、
Z
P0~P9
Rs
○
○
○
○
○
○
○
○
○
○
○
○
○
○
Ts
○
○
○
○
○
○
○
○
○
○
○
○
○
L
○
○
*
○
2~256
Pr
○
○
○
○
○
○
○
○
*
○
*
○
z
When search control "EN" = 1 or "EN
↑
" (
P
instruction) has a transition from 0 to 1, will search from the first
register of Table Ts (when "FHD" = 1 or Pr value has reached L-1), or from the next register (Tspr + 1) pointed
by the pointer within the table ("FHD" = 0, while Pr value is less than L-1) to find the first data different with
Rs(when D/S = 1) or find the first data the same with Rs (when D/S = 0). If it find a data match the condition it
will immediately stop the search action, and the pointer Pr will point to that data and found objective flag "FND"
will set to 1. When the searching has searched to the last register of the table, the execution of the instruction
will stop, whether it was found or not. In that case the search-to-end flag "END" will be set to 1 and the Pr value
will stop at L-1. When this instruction next time is executed, Pr will automatically return to the head of the table
(Pr = 0) before the search begin.
z
The effective range of Pr is 0 to L-1. If the value exceeds this range then the pointer error flag "ERR" will
change to 1, and this instruction will not be carried out.
EN
R
S
:
L :
Pr :
X0
FHD
D/S
105P.R-T_S
T
S
:
10
5555
R 20
R 0
ERR
END
FND
z
The instruction at left is searching the table for a register with the
value 5555 (because D/S = 0, it is searching for same value).
Before execution, the pointer point to R2, but the starting point of
the search is Pr + 1 (i.e. it starts from R3). After X0 has transition
from 0
→
1 3 times, the results of each search may be obtained
as shown in the diagram below.
Pr Ts
Pr
FND END
R20
2
R0
5 5 5 5
R20
6
1 0
R1
0 0 0 0
R2
5 5 5 5
Rs
R3
2 2 2 2
←
c
X0
=
(First)
Pr
FND END
5 5 5 5
R4
3 3 3 3
Start
point
R20
9
0 1
R5
4 4 4 4
R6
5 5 5 5
R7
6 6 6 6
d
X0
=
(Second)
Pr
FND END
R8
7 7 7 7
R20
0
1 0
R9
8 8 8 8
e
X0
=
(Third)
Before execution
After execution