Advanced Function Instruction
7-4
FUN 25 D P
MEAN
MEAN
(Average of the block data)
FUN 25 D P
MEAN
S : Source register number
N : Number of registers to be averaged
(N units of successive registers starting from S)
D : Register number for storing result (mean value)
The S, N, D may combine with V, Z, P0~P9 to
serve indirect address application
WX WY WM WS TMR CTR HR IR OR SR ROR DR K XR
Range
Ope-
rand
WX0
∣
WX240
WY0
∣
WY240
WM0
∣
WM1896
WS0
∣
WS984
T0
∣
T255
C0
∣
C255
R0
∣
R3839
R3840
∣
R3903
R3904
∣
R3967
R3968
∣
R4167
R5000
∣
R8071
D0
∣
D4095
2
∣
256
V、Z
P0~P9
S ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○
N ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○
D ○ ○ ○ ○ ○ ○ ○ ○* ○* ○ ○
z When operation control "EN" = 1 or "EN↑" ( P instruction) from 0 to 1, add the N successive 16-bit or 32-bit
( D instruction) numerical values starting from S, and then divided by N. Store this mean value (rounding off
numbers after the decimal point) in the register specified by D.
z While the N value is derived from the content of the register, if the N value is not between 2 and 256, then the
N range error "ERR" will be set to 1, and do not execute the operation.
S :
N :
D :
3
25P.MEAN
X0
EN
ERR
R 0
R 10
z At left, the example program gets the mean value of the
3 successive 16-bit registers starting from R0, and stores
the results into the 16-bit register R10
R0
123
R1
9
S
(N=3)
R2
788
123+9+788
Ø
X0=
3
=306 (Rouding off the remainder)
D
R10
306