Publication 1747-RM001G-EN-P - November 2008
4-8 Math Instructions
Multiply (MUL)
Use the MUL instruction to multiply one value (source A) by another (source
B) and place the result in the destination.
Updates to Arithmetic Status Bits
The arithmetic status bits are found in Word 0, bits 0 to 3 in the status file.
After an instruction is executed, the arithmetic status bits in the status file are
updated.
(U)
S:5
0
END
] [
B3
0
[OSR]
B3
1
SUB
SUBTRACT
Source A B3:3
0000000000000011
Source B 1
Dest B3:3
0000000000000011
ADD
ADD
Source A B3:1
0101010110101000
Source B B3:2
0001100101000000
Dest B3:2
0001100101000000
ADD
ADD
Source A 1
Source B B3:3
0000000000000011
Dest B3:3
0000000000000011
] [
S:0
0
] [
B3
31
When rung goes true for a
single scan, B3:1 is added to
B3:2. The result is placed in
B3:2
If a carry is generated (S:0/0
set), 1 is added to B3:3.
If B3:1 is negative (B3/31
set), 1 is subtracted from
B3:3.
Overflow trap bit S:5/0 is
unlatched to prevent a major
error from occurring at the
end of the scan.
TIP
You can use the rung above with a DDV instruction
and a counter to find the average value of B3:1.
MUL
Multiply
Source A N7:20
0<
Source B N7:21
0<
Dest N7:22
0<
MUL
Output Instruction
Fixed SLC
5/01
SLC
5/02
SLC
5/03
SLC
5/04
SLC
5/05
• •••••