7-22
Section
Binary Calculation Instructions
469
When the execution condition is OFF, SBB(51) is not executed. When the
execution condition is ON, SBB(51) subtracts the contents of Su and CY from Mi
and places the result in R. If the result is negative, CY is set and the 2’s comple-
ment of the actual result is placed in R.
Mi – Su – CY
CY R
SBB(51) can also be used to subtract signed binary data. With the CPM1A,
CPM2A, CPM2C, and SRM1(-V2), the underflow and overflow flags (SR 25404
and SR 25405) indicate whether the result has exceeded the lower or upper lim-
its of the 16-bit signed binary data range.
Flags
ER:
Indirectly addressed DM word is non-existent. (Content of
*
DM word is
not BCD, or the DM area boundary has been exceeded.)
CY:
ON when the result is negative, i.e., when Mi is less than Su plus CY.
EQ
:
ON when the result is 0.
OF
:
ON when the result e32,767 (7FFF).
UF
:
ON when the result is below –32,768 (8000).
Example
The following example shows a four-digit subtraction. When IR 00001 is ON, the
content of LR 00 and CY are subtracted from the content of IR 002 and the result
is written to HR 01.
CY is turned ON if the result is negative. If normal data is being used, a negative
result (signed binary) must be converted to normal data using NEG(––). Refer to
7-20-12 2’s COMPLEMENT – NEG(––)
for details.
CLC(41)
00001
SBB(51)
200
LR00
HR 01
Address
Instruction
Operands
00000
LD
00001
00001
OUT
TR
1
00002
CLC(41)
00003
SBB(51)
200
LR
00
HR
01
In the case below, the content of LR 00 (#7A03) and CY are subtracted from
IR 002 (#F8C5). Since the result is positive, CY is 0.
If the result had been negative, CY would have been set to 1. For normal (un-
signed) data, the result would have to be converted to its 2’s complement.
Mi: IR 002
F
8
C
5
Su: LR 00
7
A
0
3
–
0
0
0
0
–
CY = 0
(from CLC(41))
R: HR 01
7
E
C
2
Note
For signed binary calculations, the status of the UF and OF flags indicate wheth-
er the result has exceeded the signed binary data range (–32,768 (8000) to
+32,767 (7FFF)).
Description