Você está na página 1de 2

Average.

rss
LAD 3 - --- Total Rungs in File = 5
This routine averages the integers in registers N12:0 to N12:[C10:0.PRE]. A maximum of 255 values can be averaged.
The number of values to be averaged must be loaded into C10:0.PRE before calling this subroutine. Dont load a value larger than the
number of elements in N12 or you'll get a run time fault.
First we need to reset our iteration counter and our summing register.
Averaging Routine
Iteration Counter
C10:0
RES

SBR
Subroutine

0000

Average Routine
Summer
CLR
Clear
Dest

F11:0
0.0<

Use indirect addressing to sum the integers in N12:0 to N12:[C10:0.PRE].

0001

Averaging Routine
Iteration Counter
Count Up Enable Bit
C10:0
U
CU

Q3:0
LBL
Average Routine
Summer
ADD
Add
Source A

F11:0
0.0<
Source B N12:[C10:0.ACC]
0<
Dest
F11:0
0.0<

Averaging Routine
Iteration Counter
CTU
Count Up
Counter
C10:0
Preset
20<
Accum
20<
Averaging Routine
Iteration Counter
Done Bit
C10:0

CU
DN

Q3:0
JMP

DN

Page 1

Wednesday, February 14, 2001 - 13:33:41

Average.rss
LAD 3 - --- Total Rungs in File = 5
Divde the sum in F11:0 by C10:0.PRE to compute the average.
Average of N12:0 to
N12:[C10:0.PRE]
DIV
Divide
Source A
F11:0
0.0<
Source B C10:0.PRE
20<
Dest
F13:0
0.0<

0002

All Done
0003

0004

Page 2

RET
Return

END

Wednesday, February 14, 2001 - 13:33:42

Você também pode gostar