Omron CP1E-NA@@D@-@ Computer Hardware User Manual


 
2 Instructions
2-174
CP1E CPU Unit Instructions Reference Manual(W483)
Subtraction at (1)
Subtraction at (2)
Final Subtraction Result
Sample program
If the result of the subtraction is a negative number (Mi<Su or Mi+1, Mi <Su+1, Su), the result is output
as a 10’s complement. The Carry Flag (CY) will turn ON. To convert the 10’s complement to the true
number, a program which subtracts the result from 0 is necessary, as an input condition of the Carry
Flag (CY). The Carry Flag turning ON thus indicates that the result of the subtraction is negative.
0
1
9
7
5
0
8
7
3
2
9
6
6
4
0
1
Mi+1: CIO 201
CY
S1: CIO 200
Su+1: CIO 121 S2: CIO 120
9251 13191
R+1: D101 R+1: D100
09583960+(100000000-17072641)
The Carry Flag (CY) is ON, so the result is subtracted from 0000 0000.
0
0 0 0 0 0 0 0
Su+1: D101 Su: D100
9 2 5 1 1 3 1 9
00000000+(100000000-92511319)
CY
0 7 4 8 8 6 8 11
R+1: D101 R+1: D100
CY
1
R+1: D101 R+1: D100
Mi+1: CIO 201 Mi: CIO 200
Su+1: D101 Su: D100
0 9 5 8 3 9 6 0
1 7 0 7 2 6 4 1
0 7 4 8 8 6 8 1
The Carry Flag (CY) will be turned ON, so the actual number is
– 7,488,681. Because the content of D101 and D100 is negative, CY is
used to turn ON CIO 21.00 to indicate this.
B
D100
D110
D120
0.00
When CIO 0.00 is ON in the following example, D110 is subtracted from
D100 as 4-digit BCD values, and the result will be output to D120.
BL
D100
D110
D120
0.00
When CIO 0.00 is ON in the following example, D111 and D110 will be
subtracted from D101 and D100 as 8-digit BCD values, and the result will
be output to D121 and D120.