![Omron CJ1G-CPUxx Instructions Manual Download Page 422](http://html1.mh-extra.com/html/omron/cj1g-cpuxx/cj1g-cpuxx_instructions-manual_742491422.webp)
401
Symbol Math Instructions
Section 3-11
Precautions
If Mi, Mi +1 and/or Su, Su +1 are not BCD, an error is generated and the Error
Flag will turn ON.
If as a result of the subtraction, the content of R, R +1 is 00000000 hex, the
Equals Flag will turn ON.
If an addition results in a borrow, the Carry Flag will turn ON.
Examples
When CIO 000000 is ON in the following example, D00111 and D00110 will
be subtracted from D00101 and D00100 as 8-digit BCD values, and the result
will be output to D00121 and D00120.
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.
Note 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 calcu-
lated 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.
Program Example
9,583,960 – 17,072,641 = –7,488,681.
In this example, the eight-digit BCD content of CIO 0121 and CIO 0120 is
subtracted from the content of CIO 0201 and CIO 0200, and the result is out-
put in eight-digit BCD to D00101 and D00100. The result is negative, so the
instruction at (2) will be executed, and the true value will then be output to
D00101 and D00100.
Equals Flag
=
ON when the result is 0.
OFF in all other cases.
Carry Flag
CY
ON when the subtraction results in a borrow.
OFF in all other cases.
Name
Label
Operation
Summary of Contents for CJ1G-CPUxx
Page 3: ...iv N o t i c e ...
Page 5: ...vi ...
Page 21: ...xxii Conformance to EC Directives 6 ...
Page 35: ......
Page 1131: ...1110 CJ series Instruction Execution Times and Number of Steps Section 4 2 ...