Omron SYSMAC CS Series Programming Manual page 51

Hide thumbs Also See for SYSMAC CS Series:
Table of Contents

Advertisement

Basic Concepts
Negative Numbers: A value is negative if the leftmost bit is 1 (ON). In 4-digit
hexadecimal, this is expressed as 8000 to FFFF Hex. The absolute of the
negative value (decimal) is expressed as a two's complement.
Example: If a negative value is –19 in decimal, the two's complement of the
absolute value of 19 (0013 Hex) is FFFF Hex minus 0013 Hex plus 0001 Hex,
which yields FFED Hex.
True number
−)
+)
Two's complement
Complements
Generally the complement of base x refers to a number produced when all
digits of a given number are subtracted from x – 1 and then 1 is added to the
rightmost digit. (Example: The ten's complement of 7556 is 9999 – 7556 + 1 =
2444.) A complement is used to express a subtraction and other functions as
an addition.
Example: With 8954 – 7556 = 1398, 8954 + (the ten's complement of 7556) =
8954 + 2444 = 11398. If we ignore the leftmost bit, we get a subtraction result
of 1398.
Two's Complements
A two's complement is a base-two complement. Here, we subtract all digits
from 1 (2 – 1 = 1) and add one.
Example: The two's complement of binary number 1101 is 1111 (F Hex) –
1101 (D Hex) + 1 (1 Hex) = 0011 (3 Hex). The following shows this value
expressed in 4-digit hexadecimal.
The two's complement b Hex of a Hex is FFFF Hex – a Hex + 0001 Hex =
b Hex. To determine the two's complement b Hex of "a Hex," use b Hex =
10000 Hex – a Hex.
Example: to determine the two's complement of 3039 Hex, use 10000 Hex –
3039 Hex = CFC7 Hex.
Similarly use a Hex = 10000 Hex – b Hex to determine the value a Hex from
the two's complement b Hex.
Example: To determine the real value from the two's complement CFC7 Hex
use 10000 Hex – CFC7 Hex = 3039 Hex.
The CS/CJ Series has two instructions: NEG(160)(2'S COMPLEMENT) and
NEGL(161) (DOUBLE 2'S COMPLEMENT) that can be used to determine the
two's complement from the true number or to determine the true number from
the two's complement.
F
F
F
1111
1111
1111
0
0
1
0000
0000
0001
F
F
E
1111
1111
1110
0
0
0
0000
0000
0000
F
F
E
1111
1111
1110
Section 2-1
F
1111
3
0011
C
1100
1
0001
D
1101
31

Advertisement

Table of Contents
loading

This manual is also suitable for:

Cs1g/h-cpu-ev1 seriesCj1g-cpu seriesSysmac cj series

Table of Contents