Motorola HC12 Refrence Manual page 274

Table of Contents

Advertisement

WAV
Operation:
Do until B = 0, leave SOP in Y : D, SOW in X
Description:
Performs weighted average calculations on values stored in memory.
Uses indexed (X) addressing mode to reference one source operand list,
and indexed (Y) addressing mode to reference a second source operand
list. Accumulator B is used as a counter to control the number of ele-
ments to be included in the weighted average.
For each pair of data points, a 24-bit sum of products (SOP) and a 16-
bit sum of weights (SOW) is accumulated in temporary registers. When
B reaches zero (no more data pairs), the SOP is placed in Y : D. The
SOW is placed in X. To arrive at the final weighted average, divide the
content of Y : D by X by executing an EDIV after the WAV.
This instruction can be interrupted. If an interrupt occurs during WAV ex-
ecution, the intermediate results (six bytes) are stacked in the order
SOW
The wavr pseudo-instruction is used to resume execution after an inter-
rupt. The mechanism is re-entrant. New WAV instructions can be started
and interrupted while a previous WAV instruction is interrupted.
This instruction is often used in fuzzy logic rule evaluation. Refer to
TION 9 FUZZY LOGIC SUPPORT
Condition Codes and Boolean Formulas:
S
Z:
H, N, V and C may be altered by this instruction.
Addressing Modes, Machine Code, and Execution Times:
Source Form
WAV
(add if interrupted)
Notes:
1. The 8-cycle sequence in parentheses represents the loop for one iteration of SOP and SOW accumulation.
MOTOROLA
6-214
Weighted Average
Partial Product = (M pointed to by X) × (M pointed to by Y)
Sum-of-Products (24-bit SOP) = Previous SOP + Partial Product
Sum-of-Weights (16-bit SOW) = Previous SOW + (M pointed to by Y)
(X) + $0001 ⇒ X; (Y) + $0001 ⇒ Y
(B) – $01 ⇒ B
, SOP
, $00:SOP
[15:0]
[15:0]
X
H
I
N
Z
?
?
1
1; Set.
Address Mode
Object Code
Special
18 3C
INSTRUCTION GLOSSARY
before the interrupt is processed.
[23:16]
for more information.
V
C
?
?
Cycles
1
See note
WAV
SEC-
Access Detail
Off(frrfffff)O
SSSUUUrr
CPU12
REFERENCE MANUAL

Advertisement

Table of Contents
loading

This manual is also suitable for:

Cpu12

Table of Contents