Omron C200HG Computer Hardware User Manual


 
247
In the following example, SBB(51) is used to subtract one 16-bit signed binary
value from another. (The 2s 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
7544
Su: DM 0010
C47A
R: DM 0020
B0CA
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
8AD0
Su: DM 0010
0BB8
R: DM 0020
7F18
The absolute value of the true result (80E8=33,000) can be obtained by taking
the 2s 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