Omron SYSMAC CJ - REFERENCE MANUAL 08-2008 Reference Manual page 490

Programmable controllers
Hide thumbs Also See for SYSMAC CJ - REFERENCE MANUAL 08-2008:
Table of Contents

Advertisement

Symbol Math Instructions
Precautions
Examples
450
When –CL(413) is executed, the Error Flag will turn OFF.
If as a result of the subtraction, the content of R, R+1 is 00000000 hex, the
Equals Flag will turn ON.
If the subtraction results in a borrow, the Carry Flag will turn ON.
If the result of subtracting a negative number and CY from a positive number
is negative (in the range 80000000 to FFFFFFFF hex), the Overflow Flag will
turn ON.
If the result of subtracting a positive number and CY from a negative number
is positive (in the range 00000000 to 7FFFFFFF hex), the Underflow Flag will
turn ON.
If as a result of the subtraction, the content of the leftmost bit of R+1 is 1, the
Negative Flag will turn ON.
Note To clear the Carry Flag (CY), execute the Clear Carry (CLC(041)) instruction.
When CIO 000000 is ON in the following example, D00111, D00110 and CY
will be subtracted from D00101 and D00100 as 8-digit signed binary 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 2's complement. The Carry Flag (CY) will
turn ON. To convert the 2'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 sub-
traction is negative.
Note 2's Complement
A 2's complement is the value obtained by subtracting each binary digit from 1
and adding one to the result.
Example: The 2's complement for the binary number 1101 is as follows:
1111 (F hex) – 1101 (D hex) + 1 (1 hex) = 0011 (3 hex).
Example: The 2's complement for the 4-digit hexadecimal number 3039 is as
follows:
FFFF hex – 3039 hex + 0001 hex = CFC7 hex.
Accordingly, the 2's complement for the 4-digit hexadecimal value "a" is as fol-
lows:
FFFF hex – a hex + 0001 hex = b hex.
And to obtain the true number "a" hex from the 2's complement "b" hex:
a hex + 10000 hex – b hex.
Example: To obtain the true number from the 2's complement CFC& hex:
10000 hex – CFC7 hex = 3039 hex.
Section 3-11

Advertisement

Table of Contents
loading

This manual is also suitable for:

Sysmac cs seriesSysmac one nsj seriesSysmac cj series

Table of Contents