Chapter 6 Applied Instructions 
6-479 
API    Instruction code  Operand 
Function 
2113    $MIDR  P 
S
1
, S
2
, D 
Retrieving a part of the string 
Device
X  Y  M  S  T  C  HC  D  L  SM  SR  E  PR  K  16#
“$”  DF 
2 
16-bit instruction (7-13 steps) 
Symbol: 
S
1
: 
String  Word 
S
2
: 
Part of the string which is 
retrieved   
Word 
D 
: 
Device in which the characters 
retrieved are stored 
Word 
Explanation: 
1.  Suppose the values in S
2
 and S
2
+1 are n and m respectively. The m characters starting from 
the n
th
 character in the string in S
1
 are retrieved, and stored in D. 
 b15
 b0
 b7
 b8
 16#00
 ~
 ~
 D
 +1
 D
...........
 b15
 b0
 b7
 b8
 ~
First ASCII code
Second ASCII code
Third ASCII code
Fourth ASCII code
Last ASCII code
n   ASCII code from the last
th
n+1   ASCII code from the last
th
n+m-1   ASCII code from the last
th
n+m-3   ASCII code from the last
th
n+m-2   ASCII code from the last
th
 16#00
 S1
 +1
 S1
.....................
n+2   ASCII code from the last
th
n+3   ASCII code from the last
th
 n+m   ASCII code from the last
th
n+m-1   ASCII code from the last
th
 ~
n+1   ASCII code from the last
th
n   ASCII code from the last
th
n+3   ASCII code from the last
th
n+2   ASCII code from the last
th
 
2.  If the data in S
1
 is ABCDEFGHIJK, the value in S
2
 is 3, and the value in S
2
+1 is 7, the seven 
characters starting from the third characters in the string are retrieved from the left. The 
conversion result is as follows. 
 b15
 b0
 b7 b8
 0016#
 S1
16#41(A) 16#42(B)
 43(C)16# 44(D)16#
 46(F)16#
 45(E)16#
 47(G)16#
 48(H)16#
 4A(J)16#
 49(I)16#
 4B(K)16#
 b15
 b0
 b7 b8
 D
16#45(E)
 46(F)16#
 47(G)16# 48(H)16#
 49(I)16#
 Third character
 0016#
 +1
 S1
 +2
 S1
 +3
 S1
 +4
 S1
 +5 S1
 S2
 Seventh character
 43(C)16#
 44(D)16#
 D+3
 D+1
 D+2
 
3.  If the value in S
2
+1 is 0, the instruction is not executed. 
4.  If the value in S
2
+1 is -1, the characters in S
1
 starting from the character indicated by the value 
in S
2
 to the last character in S
1
 are retrieved. 
5.  If the data in S
1
 is ABCDEFGHIJK, the value in S
2
 is 5, and the value in S
2
+1 is -1, the 
conversion result is as follows.