2-287

2 Instructions
CP1E CPU Unit Instructions Reference Manual(W483)
Data Control Instructions
2
AVG
AVG
Applicable Program Areas
Operands

N: Number of Cycles

The number of cycles must be between 0001 and 0040 hexadecimal (0 to 64 cycles).

R: Result First Word and R+1: First Work Area Word
Note R to R+N+1 must be in the same area.
Operand Specifications
Flags
Instruction Mnemonic Variations Function
code Function
AVERAGE AVG --- 195 Calculates the average value of an input word for
the specified number of cycles.
Symbol
AVG
Area Step program areas Subroutines Interrupt tasks
Usage OK OK OK
Operand Description Data type Size
S Source word UINT 1
N Number of cycles UINT 1
R Result first word UINT Variable
Area Word addresses Indirect DM addresses Constants CF Pulse bits TR bits
CIO WR HR AR T C DM @DM *DM
S, N OK OK OK OK OK OK OK OK OK OK --- --- ---
R---
Name Label Operation
Error Flag P_ER ON if the contents of N is 0.
OFF in all other cases.
S: Source word
N: Number of cycles
R: Result first word
AVG(195)
S
N
R
R+1
R+2:
15 014
R+N+1:
Used by system.
Previous value #1
Previous value #N
R: Average
R+1: Processing information
Average Valid Flag
OFF: Not valid (AVG(195) has not yet been executed the specified number of cycles.)
ON: Valid.