EasyManua.ls Logo

Omron CP - PROGRAMMING MANUAL 05-2007 - Page 397

Omron CP - PROGRAMMING MANUAL 05-2007
1175 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
364
Symbol Math Instructions Section 3-10
Flags
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 0.01 is ON in the following example, D1001 and D1000 will be sub-
tracted from D1101 and D1100 as 8-digit BCD values, and the result will be
output to D1201 and D1200.
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 211 and CIO 210 is sub-
tracted from the content of CIO 201 and CIO 200, and the result is output in
eight-digit BCD to CIO 301 and CIO 300. The result is negative, so the
instruction at (2) will be executed, and the true value will then be output to
CIO 301 and CIO 300.
Name Label Operation
Error Flag ER ON when Mi and/or Mi +1 are not BCD.
ON when Su and/or Su +1 are not BCD.
OFF in all other cases.
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.
0.01
D1000
D1100
D1200

Table of Contents

Related product manuals