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

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

Advertisement

Symbol Math Instructions
Precautions
Examples
Examples
444
Name
Underflow Flag
Negative Flag
When –L(411) 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 from a positive number is nega-
tive (in the range 80000000 to FFFFFFFF hex), the Overflow Flag will turn
ON.
If the result of subtracting a positive number from a negative number is posi-
tive (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.
When CIO 000000 is ON in the following example, D00111 and D00110 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 the 2's complement and the Carry Flag
(CY) will turn ON to indicate that the result of the subtraction is negative. To
convert the 2's complement to the true number, an instruction which subtracts
the result from 0 is necessary using the Carry Flag (CY) as an execution con-
dition.
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. For example, the 2's complement for 1101 is cal-
culated as follows: 1111 (F hexadecimal) – 1101 (D hexadecimal) + 1 (1 hexa-
decimal) = 0011 (3 hexadecimal). The 2's complement for 3039 (hexadecimal)
is calculated as follows: FFFF (hexadecimal) – 3039 (hexadecimal) + 0001
(hexadecimal) – CFC7 (hexadecimal). Therefore, in case of 4-digit hexadeci-
mal value, the 2's complement can be calculated as follows: FFFF (hexadeci-
mal) – a (hexadecimal) + 0001 (hexadecimal) = b (hexadecimal). To obtain the
true number from the 2's complement b (hexadecimal): a (hexadecimal) =
10000 (hexadecimal) – b (hexadecimal). For example, to obtain the true num-
ber from the 2's complement CFC7 (hexadecimal): 10000 (hexadecimal) –
CFC7 = 3039.
Label
UF
ON when the result of subtracting a positive number from
a negative number is in the range 00000000 to
7FFFFFFF hex.
OFF in all other cases.
N
ON when the leftmost bit of the result is 1.
OFF in all other cases.
Section 3-11
Operation
−L

Advertisement

Table of Contents
loading

This manual is also suitable for:

Sysmac cs seriesSysmac one nsj seriesSysmac cj series

Table of Contents