Chapter 6 Applied Instructions 
6-475 
API    Instruction code  Operand 
Function 
2111    $RIGHT  P 
S, n, D 
The retrieve of the characters in the 
string begins from the right. 
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
:
String  Word 
n
:
Number of characters which are 
retrieved 
Word 
D
:
Device in which the characters 
retrieved are stored 
Word 
Explanation: 
1.  The instruction is used to retrieve n characters in the string in S from the right, and the 
characters which are retrieved are stored in D. 
2.  If n is 0, the value in D is 0. 
 b15
 b0
 b7
 b8
 16#00
 S
 +1
 S
Second ASCII code from the last
First ASCII code from the last
.....................
 ~
 ~
Third ASCII code from the last
n-2   ASCII code from the last
th
n-3   ASCII code from the last
th
 16#00
 ~
 D
 +1
 D
.....................
First ASCII code
Second ASCII code
T
hird ASCII code
Fourth ASCII code
n-1   ASCII code from the last
th
n   ASCII code from the last
th
n-1   ASCII code from the last
th
n   ASCII code from the last
th
n-2   ASCII code from the last
th
n-3   ASCII code from the last
th
Third ASCII code from the last
First ASCII code from the last
Second ASCII code from the last
 
If the data in S is ABCDEF12345 and n is 5, five characters in the string in S are retrieved from 
the right. The conversion result is as follows.   
 b15
 b0
 b7 b8
 0016#
 S
 +1
 S
 +2
 S
 +3
 S
16#41(A) 16#42(B)
 43(C)16# 44(D)16#
 46(F)16#
 45(E)16#
 31(1)16#
 32(2)16#
 34(4)16#
 33(3)16#
 +4
 S
 +5 S
 35(5)16#
 b15
 b0
 b7 b8
 D
 +1 D
 +2 D
16#31(1) 32(2)16#
 33(3)16# 34(4)16#
 16#00
 35(5)16#
 The fifth character from the last
 ABCDEF12345