i@.
MCS”-51PROGRAMMER’SGUIDEANDINSTRUCTIONSET
SUBB A<sro-byte>
Function:
Deeoription:
SUBB A,Rn
Bytes:
Cycles:
Encoding:
Operation:
SubtractwithbOrrOW
SUBBsubtracts the indicated variableand the carry tlag together from the Accumulator,
lesvingtheresult in the Accumulator.SUBBsetsthe carry (borrow)tlagif a borrowis needed
for bit 7, and cleam C otherwise.(H c was set
bqfors executing a SUBBinstruction,this
indicatesthata borrow was neededforthe previousstepin a multipleprecisionsubtraction,so
the csrry is subtractedfrom the Accumulatoralongwith the source operand.)AC is set if a
borrowisneededforbit 3,andclearedotherwise.
OVissetifa borrowis neededintobit 6,but
not intobit 7, or into bit 7, but not bit 6.
Whensubtraetm“ g signedintegersOVindicatesa negativenumberproduwdwhena negative
value is subtracted from a positivevalue, or a positiveresult when a positivenumber is
subtractedfrom a negativenumber.
The sourceoperandallowsfouraddressingmodes:register,direct, register-indirecLor imme-
diate.
The AccumulatorholdsOC9H(11OO1OO1B),register2 holds54H(O1O1O1OOB),andthe carry
flagis set.The instruction,
SUBB A,R2
willleavethe value74H(O1I1O1OOB)in the accumulator,with the cany flagand AC cleared
but OVset.
Noticethat OC9Hminus54His 75H.The differencebetweemthis and the aboveresult is due
to the carry(borrow)flagbeingset beforethe operation.If the state ofthecarry is not known
beforestartinga singleor multiple-precisionsubtraction,it shouldbe explicitlyclearedby a
CLR C instruction.
1
1
I
1001
Irrr
SUBB
(A) - (A) - (C) - (IQ
2-70