FUN 12
D P
(−)
(Performs subtraction of the data specified at Sa and Sb and stores the result in D)
Symbol
WX
Range
WX0
Ope-
∣
rand
WX240
Sa
○
Sb
○
D
Description
●
Performs the subtraction of the data specified at Sa and Sb and writes the results to a specified register D
when the subtract control input "EN" =1 or "EN↑" (
equal to 0 then set FO0 to 1. If carry occurs (subtracting a negative number from a positive number and the
result exceeds 32767 or 2147483647), then set FO1 to 1. If borrow occurs (subtracting a positive number
from a negative number and the resulted difference is less than -32768 or -2147483648), then set FO2 to 1.
All the FO statuses are retained until this instruction is executed again and overwritten by a new result.
Example
16-bit subtraction
Ladder Diagram
12P.(-)
X0
Sa :
EN
Sb :
D :
U/S
WY
WM
WS
TMR CTR
WY0
WM0
WS0
T0
∣
∣
∣
∣
WY240
WM1896
WS984
T255
○
○
○
○
○
○
○
○
○
○
○
○
R
D=0
0
1
R
Y2
R
2
CY
BR
Sa
R0
Sb
R1
32767
D
R2
Y2=1 (borrow 1 represents-32768) Please refer to section 6.5
SUBTRACTION
HR
IR
OR
C0
R0
R3840
R3904
∣
∣
∣
∣
C255
R3839
R3903
R3967
○
○
○
○
○
○
○
○
○
○
○
P
instruction) from 0 to 1. If the result of subtraction is
Key Operations
ORG
OUT
-5
R0-R1=-32772
X0=1
-32768-4=-32772
-4
6-27
Basic Function Instruction
Operand
Sa: Minuend
Sb: Subtrahend
D : Destination register to store the
results of the subtraction
Sa, Sb, D may combine with V, Z, P0~P9
to serve indirect addressing
SR
ROR
DR
K
R3968
R5000
D0
16/32-bit
∣
∣
∣
+/− number
R4167
R8071
D4095
○
○
○
○
○
○
○
○
○*
○*
○
Mnemonic Codes
ORG
FUN
Sa: R
Sb: R
D:
FO
OUT
FUN 12
D P
(−)
XR
V、Z
P0~P9
○
○
○
X
0
12
0
1
R
2
2
Y
2