Omron CS1G/H-CPUxxH Instructions Manual page 422

Sysmac cs series; sysmac cj series
Hide thumbs Also See for CS1G/H-CPUxxH:
Table of Contents

Advertisement

Symbol Math Instructions
Precautions
Examples
Program Example
Name
Equals Flag
=
Carry Flag
CY
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.
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.
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.
Label
ON when the result is 0.
OFF in all other cases.
ON when the subtraction results in a borrow.
OFF in all other cases.
Section 3-11
Operation
401

Advertisement

Table of Contents
loading

Table of Contents