7-237
MIDR(P),MIDW(P)
1
2
3
4
6
6
7
8
7.11 Character string processing instructions
7.11.16
Random selection from and replacement in character strings (MIDR(P),MIDW(P))
(4) If the number of characters designated by +1 exceeds the final character from the
character string data designated by , data will be stored up to the final character.
(5) If the number of characters designated by +1 is " 1", stores the data up to the final
character designated by to the area starting from the device designated by .
Operation Error
(1) In any of the following cases, an operation error occurs, the error flag (SM0) turns ON, and
an error code is stored into SD0.
For MIDR instruction
• The value of exceeds the number of characters designated by . (Error code: 4101)
• The +1 number of characters from position exceeds the device range.
(Error code: 4101)
• The + 0 value is 0. (Error code: 4101)
•"00
H
" does not exist in the specified devices that follow the device specified for .
(Error code: 4101)
For MIDW instruction
• The value of exceeds the number of characters designated by . (Error code: 4101)
S2
D
+1
30
H
(0)31
H
(1)
32
H
(2)33
H
(3)
b15 b8b7
b0
34
H
(4)35
H
(5)
36
H
(6)37
H
(7)
38
H
(8)00
H
+2
+3
+4
"012345678"
+1
41
H
(A)42
H
(B)
43
H
(C)44
H
(D)
+2
45
H
(E)46
H
(F)
"ABCDEFGHI"
47
H
(G)48
H
(H)
+3
49
H
(I)
00
H
+4
Before execution
+1
41
H
(A)42
H
(B)
43
H
(C)44
H
(D)
+2
30
H
(0)31
H
(1)
"ABCD01234"
32
H
(2)33
H
(3)
+3
34
H
(4)
00
H
+4
After execution
5
8
+1
Number of characters counted
from the left end of character
string data designated by
Position counted from the left
end of character string data
designated by
S1
D
D
D
D
D
S2
S1
S
1
S
1
S
1
S2
D
D
D
D
D
b15 b8
b7
b0
b15 b8
b7
b0
Characters "35H" (5) to "37H" (7)
are not stored.
S1
D
S2
S1
D
+1
30
H
(0)31
H
(1)
32
H
(2)33
H
(3)
34
H
(4)35
H
(5)
00
H
+2
+3
"012345"
+1
41
H
(A)42
H
(B)
43
H
(C)44
H
(D)
+2
45
H
(E)46
H
(F)
"ABCDEFGHIJK"
47
H
(G)
48
H
(H)
+3
49
H
(I)
4A
H
(J)
+4
Before execution
41
H
(A)30
H
(0)
31
H
(1)32
H
(2)
33
H
(3)34
H
(4)
"A012345HIJK"
35
H
(5)48
H
(H)
49
H
(I)
4A
H
(J)
After execution
2
1
+1
Number of characters counted
from the left end of character
string data designated by
Position counted from the left
end of character string data
designated by
4B
H
(K)00
H
+5
4B
H
(K)
00
H
b15 b8b7 b0
b15 b8
b7
b0
S2
D
S2
S1
S
1
S
1
S
1
D
D
D
D
D
b15 b8
b7
b0
+1
+2
+3
+4
+5
D
D
D
D
D
D
S1
D
S2
S1
S2
D D
S2
S1
S2
D