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


 
2 Instructions
2-176
CP1E CPU Unit Instructions Reference Manual(W483)
Function
–BC
–BC(416) subtracts BCD values in Su and CY from Mi and outputs the result to R. If the result is nega-
tive, 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 comple-
ment 2444: 10000 – 2444 = 7556.
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.
CY
RCY
(BCD)
(BCD)
(BCD)
Mi
Su
CY will turn ON
when there is a
borrow.
R+1
CY
RCY
(BCD)
(BCD)
(BCD)
Mi+1
Su+1
Mi
Su
CY will turn ON
when there is a
borrow.
BC
D100
D110
D120
0.00
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
result will be output to D120.
BCL
D100
D110
D120
0.00
When CIO 0.00 is ON in thefollowing example, D111, D110,
and CY will be subtracted from D101 and D100 as 8-digit
BCD values, and the result will be output to D121 and D120.