Omron CJ - REFERENCE MANUAL 02-2010 Reference Manual page 403

Table of Contents

Advertisement

Function
–BC
–BC(416) subtracts BCD values in Su and CY from Mi and outputs the result to R. If the result is
negative, it is output to R as a 10's complement.
–BCL
–BCL(417)subtracts the BCD values in Su, Su+1, and CY from Mi and Mi+1 and outputs the result to R,
R+1. If the result is negative, it is output to R, R+1 as a 10's complement.
Hint
• To clear the Carry Flay (CY), execute the Clear Carry (CLC(041)) instruction.
• 10's Complement
A 10's complement is the value obtained by subtracting each digit from 9 and adding one to the
result. For example, the 10's complement for 7556 is calculated as follows: 9999 - 7556 + 1 = 2444.
For a four digit number, the 10's complement of A is 9999 – A + 1 = B. To obtain the true number from
the 10's complement B: A = 10000 – B. For example, to obtain the true number from the 10's
complement 2444: 10000 – 2444 = 7556.
Example Programming
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.
CS/CJ/NSJ Series Instructions Reference Manual (W474)
Mi
Su
CY
CY will turn ON
CY
R
when there is a
borrow.
Mi+1
Su+1
CY will turn ON
CY
R+1
when there is a
borrow.
0.00
-BC
When CIO 0.00 is ON in the following example, D110 and CY
will be subtracted from D100 as 4-digit BCD values, and the
D100
result will be output to D120.
D110
D120
0.00
-BCL
When CIO 0.00 is ON in the following example, D111, D110,
and CY will be subtracted from D101 and D100 as 8-digit
D100
BCD values, and the result will be output to D121 and D120.
D110
D120
(BCD)
(BCD)
(BCD)
(BCD)
Mi
(BCD)
Su
CY
(BCD)
R
3. Instructions
3
367

Advertisement

Table of Contents
loading

Table of Contents