Chapter 6 Applied Instructions API 2113 Symbol: S 2 : Part of the string which is retrieved Word S 1 : String 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 . S1 b15 b0 b7 b8 b15 b0 b7 b8 D +1 S1 ..................... ~ ~ ~ +1 D ........... ~ 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.
S1 b15 b0 b7 b8 b15 b0 b7 b8 D +1 S1 D+1 +2 S1 +3 S1 D+3 D+2 +4 S1 +5 S1 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.
6-484 Instruction code Operand Function $MIDR P S , S , D 1 2 Retrieving a part of the string Device X Y M S T C HC D L SM SR E PR K 16# “$” DF S 1 S 2 D Pulse instruction 16-bit instruction (7-13 steps) 32-bit instruction AH AH - Second ASCII code First ASCII code Fourth ASCII code Third ASCII code n+1 th ASCII code from the last n th ASCII code from the last n+3 th ASCII code from the last n+2 th ASCII co de from the last n+1 th ASCII code from the last n th ASCII code from the last n+3 th ASCII code from the last n+2 th ASCII code from the last n+m-2 th ASCII code from the last n+m-3 th ASCII code from the last 16#00 n+m-1 th ASCII co de from the last n+m th ASCII code from the last n+m-1 th ASCII code from the last 16#00 Last ASCII code 16#42(B) 16#41(A) S2 Third character Seventh charact 16#44(D) 16#43(C) 16#46(F) 16#45(E) 16#48(H) 16#47(G) 16#4A(J) 16#49(I) 16#00 16#4B(K) 16#44(D) 16#43(C) 16#46(F) 16#45(E) 16#48(H) 16#47(G) 16#00 16#49(I)