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
30H (0)31H (1)
32H (2)33H (3)
b15 b8b7 b0
34H (4)35H (5)
36H (6)37H (7)
38H (8)00H
+2
+3
+4
"012345678"
+1
41H (A)42H (B)
43H (C)44H (D)
+2 45H (E)46H (F)
"ABCDEFGHI"
47H (G)48H (H)
+3
49H (I)
00H
+4
Before execution
+1
41H (A)42H (B)
43H (C)44H (D)
+2 30H (0)31H (1)
"ABCD01234"
32H (2)33H (3)
+3
34H (4)
00H
+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 b8b7 b0
b15 b8b7 b0
Characters "35H" (5) to "37H" (7)
are not stored.
S1
D
S2
S1 D
+1
30H (0)31H (1)
32H (2)33H (3)
34H (4)35H (5)
00H
+2
+3
"012345"
+1
41H (A)42H (B)
43H (C)44H (D)
+2 45H (E)46H (F)
"ABCDEFGHIJK"
47H (G)
48H (H)
+3
49H (I)
4AH (J)
+4
Before execution
41H (A)30H (0)
31H (1)32H (2)
33H (3)34H (4)
"A012345HIJK"
35H (5)48H (H)
49H (I)
4AH (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
4BH (K)00H
+5
4BH (K)
00H
b15 b8b7 b0
b15 b8b7 b0
S2
D
S2
S1
S
1
S
1
S
1
D
D
D
D
D
b15 b8b7 b0
+1
+2
+3
+4
+5
D
D
D
D
D
D
S1
D
S2
S1
S2
D D
S2
S1
S2
D