Advanced Function Instruction
7-92
FUN108 D P
T_SHF
TABLE SHIFT
FUN108 D P
T_SHF
IW :
Td :
EN
Shift control
Ladder symbol
108DP.T_SF
Ts :
L :
OW :
Left/Right direction L/R
IW : Data to fill the room after shift operation, can be a
constant or a register
Ts : Source table
Td : Destination table storing shift results
L : Lengths of tables Ts and Td
OW : Register to accept the shifted out data
Ts, Td 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~P0
IW ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○
Ts ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○
Td ○ ○ ○ ○ ○ ○ ○ ○* ○* ○ ○
L ○ ○* ○ 2~256
OW ○ ○ ○ ○ ○ ○ ○ ○* ○* ○
z When shift control "EN" = 1 or "EN↑" ( P instruction) has a transition from 0 to 1, all the data from table Ts will
be taken out and shifted one position to the left (when "L/R" = 1) or to the right (when "L/R" = 0). The room
created by the shift operation will be filled by IW and the results will be written into table Td. The data shifted
out will be written into OW.
X0
EN
T
S :
Td :
R 11
L :
OW :
L/R
10
R 10
R 0
IW :
R 0
X1
108P.T_SHF
z In the program at left, Ts and Td is the same table.
Therefore, the table shifts itself and then writes back to
itself (the table must be writ able). It first perform a shift left
operation (let X1 = 1, and X0 go from 0
→1) then perform a
shift to right operation (let X1 = 0, and makes X0 go from 0
→1). The result are shown at right in the diagram below.
Ts ( T d )
(Shift left)
(Shift right)
Td(Ts) Td(Ts)
R0 0000 R0
1234
R0
0000
(Shift left) R1 1111 R1
0000
R1
1111
R2 2222 R2
1111
R2
2222
R3 3333
OW
R3
2222
R3
3333
R10 1234 R4 4444
R11
××××
R4
3333
R4
4444
R5 5555 R5
4444
R5
5555
R6 6666 R6
5555
R6
6666
R7 7777 R7
6666
R7
7777
R8 8888 R8
7777
R8
8888
R9 9 9 9 9 (Shift left) R9
8888
R9
1234
OW OW
Dotted line is the path for shift right R11 9999 R11 1234
Before execution
cFirst time dSecond time