Bcd Subtract - Sub(31) - Omron CQM1H - PROGRAM Programming Manual

Programmable controllers; inner boards
Table of Contents

Advertisement

BCD Calculation Instructions
Example
TR 0
00002
25504
25504
5-21-4 BCD SUBTRACT – SUB(31)
Limitations
Description
Flags
318
If 00002 is ON, the program represented by the following diagram clears CY
with CLC(41), adds the content of IR 030 to a constant (6103), places the
result in DM 0100, and then moves either all zeros or 0001 into DM 0101
depending on the status of CY (25504). This ensures that any carry from the
last digit is preserved in R+1 so that the entire result can be later handled as
eight-digit data.
Although two ADD(30) can be used together to perform eight-digit BCD addi-
tion, ADDL(54) is designed specifically for this purpose.
Ladder Symbols
SUB(31)
@SUB(31)
Mi
Su
R
DM 6144 to DM 6655 cannot be used for R.
When the execution condition is OFF, SUB(31) is not executed. When the exe-
cution condition is ON, SUB(31) 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 10's com-
plement of the actual result is placed in R. To convert the 10's complement to
the true result, subtract the content of R from zero (see example below).
Mi − Su − CY
ER:
Mi and/or Su is not BCD.
Indirectly addressed EM/DM word is non-existent.
(Content of *EM/*DM word is not BCD, or the EM/DM area boundary
has been exceeded.)
Address Instruction
00000
LD
00001
OUT
CLC(41)
00002
CLC(41)
00003
AND(30)
ADD(30)
030
#6103
DM 0100
00004
AND
00005
MOV(21)
MOV(21)
#0001
DM 0101
00006
LD
00007
AND NOT
MOV(21)
00008
MOV(21)
#0000
DM 0101
Operand Data Areas
IR, SR, AR, DM, EM, HR, TIM/CNT, LR, #
Su: Subtrahend word (BCD)
Mi
IR, SR, AR, DM, EM, HR, TIM/CNT, LR, #
Su
R
IR, SR, AR, DM, EM, HR, LR
CY
Section 5-21
Operands
00002
TR
0
030
#
6103
DM
0100
25504
#
0001
DM
0101
TR
0
25504
#
0000
DM
0101
Mi: Minuend word (BCD)
R: Result word
R

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the CQM1H - PROGRAM and is the answer not in the manual?

This manual is also suitable for:

Sysmac cqm1h seriesSysmac cqm1h-cpu series

Table of Contents

Save PDF