314
Special Math Instructions Section 5-22
Cosine Function The following example demonstrates the use of the APR(––) cosine function
to calculate the cosine of 30
°. The cosine function is specified when C is
#0001.
Linear Approximation APR(––) linear approximation is specified when C is a memory address. Word
C is the first word of the continuous block of memory containing the linear
approximation data.
The content of word C specifies the number of line segments in the approxi-
mation, and whether the input and output are in BCD or BIN form. Bits 00 to
07 contain the number of line segments less 1, m–1, as binary data. Bits 14
and 15 determine, respectively, the output and input forms: 0 specifies BCD
and 1 specifies BIN.
Enter the coordinates of the m+1 end-points, which define the m line seg-
ments, as shown in the following table. Enter all coordinates in BIN form.
Always enter the coordinates from the lowest X value (X
1
) to the highest (X
m
).
X
0
is 0000, and does not have to be entered.
Input data, x Result data
S: DM 0010 D: DM 0110
010
1
10
0
10
–1
10
–1
10
–2
10
–3
10
–4
0300 86 60
APR(––)
#0001
DM 0010
DM 0110
00000
Enter input data not exceed-
ing #0900 in BCD.
Result data has four significant
digits, fifth and higher digits are
ignored. The result for cos(0) will
be 0.9999, not 1.
Address Instruction Operands
00000 LD 00000
00001 APR(––)
# 0001
DM 0010
DM 0110
Word Coordinate
C+1 X
m
(max. X value)
C+2 Y
0
C+3 X
1
C+4 Y
1
C+5 X
2
C+6 Y
2
φ φ
C+(2m+1) X
m
C+(2m+2) Y
m
15 14 13 Not used. 07 06 05 04 03 02 01 00
Source data form
1 (ON): f(x)=f(X
m
–S)
0 (OFF): f(x)=f(S)
Output form
Input form
Number of coordinates
minus one (m–1)
C:
Y
0
X
0
X
1
X
2
X
3
X
4
X
m
X
Y
Y
m
Y
4
Y
3
Y
1
Y
2