Omron CPM1 - PROGRAMING MANUAL 02-2001 Programming Manual page 487

Hide thumbs Also See for CPM1 - PROGRAMING MANUAL 02-2001:
Table of Contents

Advertisement

Binary Calculation Instructions
Description
Flags
Example
00001
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.
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.
Indirectly addressed DM word is non-existent. (Content of *DM word is
ER:
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 exceeds +32,767 (7FFF).
UF:
ON when the result is below –32,768 (8000).
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.
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.
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)).
Mi – Su – CY
Address Instruction
00000
CLC(41)
00001
00002
SBB(51)
00003
200
LR00
HR 01
Mi: IR 002
F
8
C
5
Su: LR 00
7
A
0
3
0
0
0
0
R: HR 01
7
E
C
2
Section
CY
R
Operands
LD
00001
OUT
TR
CLC(41)
SBB(51)
LR
HR
CY = 0
(from CLC(41))
7-22
1
200
00
01
469

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the CPM1 - PROGRAMING MANUAL 02-2001 and is the answer not in the manual?

Table of Contents