Chapter 6 Applied Instructions 
6-481 
API    Instruction code
Operand 
Function 
2114    $MIDW  P 
S
1
, S
2
, D 
Replacing a part of the string 
Device
X  Y  M  S  T  C  HC  D  L  SM  SR  E  PR  K  16#
“$”  DF 
16-bit instruction (7-13 steps) 
Symbol: 
S
1 
: 
String  Word 
S
2 
: 
Part of the string which is 
replaced 
Word 
D 
: 
String which is replaced  Word 
Explanation: 
1.  S
2
: The initial character in D which is replaced 
S
2
+1: The number of characters which are retrieved from S
1
 
2.  The retrieve of the characters in the string in S
1
 begins from the first character, and the value in 
S
2
+1 indicates the number of characters which are retrieved from the string in S
1
. The 
characters which are retrieved from the string in S
1
 replace the characters in D starting from 
the character indicated by the value in S
2
. 
 b15
 b0
 b7 b8
 0016#
 S1
16#31(1) 16#32(2)
 33(3)16# 34(4)16#
 36(6)16#
 35(5)16#
 37(7)16#
 38(8)16#
 39(9)16#
 b15
 b0
 b7 b8
 D
 +1 D
 +2 D
16#45(E) 46(F)16#
 47(G)16# 48(H)16#
 49(I)16#
 4A(J)16#
 +1
 S1
 +2
 S1
 +3
 S1
 +4
 S1
 S2
 +1
 S2
 3
 6
 4C(L)16#
 4B(K)16#
 +3
 D
 0016#
 4D(M)16#
 +4 D
 b15
 b0
 b7 b8
 D
 +1 D
 +2 D
16#45(E) 46(F)16#
 +3
 D
 0016#
 4D(M)16#
 +4 D
Initial character in D which is replaced
Number of characters which 
are retrieved from S1
16#31(1) 32(2)16#
 33(3)16# 34(4)16#
 36(6)16#
 35(5)16#
After the instruction is executed
 
3.  If the value in S
2
+1 is 0, the instruction is not executed. 
4.  If the value in S
2
+1 is larger than the length of the string in D, the characters in D which are 
replaced start from the character indicated by the value in S
2
 to the last character in D.