
247
In the following example, SBB(51) is used to subtract one 16-bit signed binary
value from another. (The 2’s complement is used to express negative values).
The effective range for 16-bit signed binary values is –32,768 (8000) to +32,767
(7FFF). The overflow flag (OF: SR 25404) is turned ON if the result exceeds
+32,767 (7FFF) and the underflow flag (UF: SR 25405) is turned ON if the result
falls below –32,768 (8000).
CLC(41)
00000
SBB(51)
LR 20
DM 0010
DM 0020
Address
Instruction
Operands
00000
LD
00000
00001
CLC(41)
00002
SBB(51)
LR
20
DM
0010
DM
0020
In the case shown below, 30,020 – (–15,238) = 45,258 (7544 – C47A =
60CA).The OF flag would be turned ON to indicate that this result exceeds the
upper limit of the 16-bit signed binary data range. (In other words, the result is a
positive value that exceeds 32,767 (7FFF), not a negative number expressed as
signed binary data.)
Mi: LR 20
7
5
4
4
Su: DM 0010
C
4
7
A
–
R: DM 0020
B
0
C
A
In the case shown below, –30,000 – 3,000 = –33,000 (8AD0 – 0BB8 = 7F18).The
UF flag would be turned ON to indicate that this result is below the lower limit of
16-bit signed binary data range. (In other words, the result is a negative number
below –32,768 (8000), not a positive number expressed as signed binary data.)
Mi: LR 20
8
A
D
0
Su: DM 0010
0
B
B
8
–
R: DM 0020
7
F
1
8
The absolute value of the true result (80E8=33,000) can be obtained by taking
the 2’s complement of 7F18 using NEG(––).
Note
The status of the CY flag can be ignored when adding signed binary data since it
is relevant only in the addition of normal hexadecimal values.
Example 2:
Signed Binary Data
Binary Calculations
Section 5-20
Summary of Contents for SYSMAC C200HE
Page 1: ...Cat No W303 E1 09 OPERATION MANUAL Programmable Controllers C200HX C200HG C200HE ...
Page 2: ......
Page 3: ...C200HX C200HG C200HE Programmable Controllers Operation Manual Revised August 2004 ...
Page 6: ...vi ...
Page 10: ......
Page 12: ......
Page 380: ......
Page 410: ......
Page 438: ......
Page 464: ......
Page 474: ......
Page 522: ......
Page 538: ......
Page 552: ...534 Programmer Program Date Page Word Contents Notes Word Contents Notes Data Storage ...
Page 554: ......
Page 560: ......
Page 584: ......
Page 585: ......
Page 586: ...W303 E1 09 ...