Omron SYSMAC C200HS Operation Manual page 233

Programmable controllers
Hide thumbs Also See for SYSMAC C200HS:
Table of Contents

Advertisement

Binary Calculations
Example 2:
Signed Binary Data
00000
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).
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.)
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.)
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.
Address Instruction
CLC(41)
00000
00001
SBB(51)
00002
LR 20
DM 0010
DM 0020
Mi: LR 20
7
5
4
Su: DM 0010
C
4
7
R: DM 0020
B
0
C
Mi: LR 20
8
A
D
Su: DM 0010
0
B
B
R: DM 0020
7
F
1
Section 5-20
Operands
LD
00000
CLC(41)
SBB(51)
LR
DM
DM
4
A
A
0
8
8
20
0010
0020
223

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents