intd. MCS@-51PROGRAMMER’SGUIDEAND INSTRUCTION SET
Bytes
Cycles:
Encoding:
Operstion:
TheAccumulatorholdsthe value56H(OIO1OI1OB)representingthepackedBCDdigitsofthe
decimalnumber56.Register 3 containsthe value67H(0110011lB)representingthe packed
BCDdigitsof the decimalnumber67.The carry flagis set. The instructionsequence.
ADDC A,R3
DA A
wdl first performa standard twos-complementbinary addition, resultingin the value OBEH
(10111110)in the Accumulator.The carry and auxiliarycarry flagswillbe cleared.
The Decimal Adjust instruction will then alter the Accumulator to the value 24H
(OO1OO1OOB),indicatingthe packedBCDdigitsofthe decimalnumber24,the low-ordertwo
digitsofthe decimalsum of 56,67, andthe carry-in.The carry tlagwillbeset bythe Decimal
Adjustinstruction,indicatingthat a ddnal overflowoccurred.The true sum 56,67, and 1is
124.
BCDvariablescanbeincrementedor decrementedbyaddingOIHor 99H.If the Accumulator
initiallyholds30H(representingthe digitsof 30decimal),then the instructionsequence,
ADD
A#99H
DA A
willleave the carry set and 29H in the Accumulator,since 30 + 99 = 129.The low-order
byteof the sumcan be interpretedto mean 30 – 1 = 29.
1
1
1101 0100
DA
-contentsof Accumulatorare BCD
IF
[[(A3-13)>91 V [(AC) = 111
THEN(A34)- (A343)+ 6
AND
IF
[[(A7-4)> 9] V [(C) =
111
THEN (A74)- (A74) + 6
2-40