Omron C28K Video Game Controller User Manual


 
121
If 0002 is ON, the following diagram clears CY with CLC(41), adds the con-
tent of IR 02 to a constant (6103), places the result in DM 01, and then
moves either all zeros or 0001 into DM 02 depending on the status of CY
(1904). 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.
TR 0
MOV(21)
#0001
DM 02
0002
CLC(41)
ADD(30)
02
#6103
DM 01
MOV(21)
#0000
DM 02
1904
1904
Address Instruction Operands
0000 LD 0002
0001 OUT TR 0
0002 CLC(41)
0003 AND(30)
02
# 6103
DM 01
0004 AND 1904
0005 MOV(21)
# 0001
DM 02
0006 LD TR 0
0007 AND NOT 1904
0008 MOV(21)
# 0000
DM 02
Consecutive ADD(30)s can be used to perform eight-digit BCD addition. By
using two ADD(30)s and combining the augend and the addend words of one
ADD(30) with those of the other, two 8-digit values can be added. The result
may or may not be 9 digits depending on whether a carry is generated.
0000 LD 0002
0001 DIFU(13) 1000
0003 LD 1000
0004 OUT TR 0
0005 CLC(41)
0006 AND(30)
DM 00
DM 02
DM 04
0007 AND(30)
DM 01
DM 03
DM 05
0008 AND 1904
0009 MOV(21)
# 0001
DM 06
0010 LD TR 0
0011 AND NOT 1904
0012 MOV(21)
# 0000
DM 06
TR 0
MOV(21)
#0001
DM 06
1000
CLC(41)
ADD(30)
DM 00
DM 02
DM 04
MOV(21)
#0000
DM 06
1904
1904
0002
DIFU(13) 1000
ADD(30)
DM 01
DM 03
DM 05
Address Instruction Operands
In the above program the 8 digit augend consists of two words: DM 00 and
DM 01, with DM 01 being used for the 4 left digits and 00 for the 4 right dig-
its. Similarly the 8-digit addend consist of DM 02 and 03. Three words are
used to hold the results of the addition: DM 04, DM 05, and DM 06. In this
Example
BCD Calculations Section 5-16